Tom Wright
Tom Wright

Reputation: 11489

Are there any .NET tools for distorting/warping images?

I'd like to be able to programmatically distort an image in C#. Specifically, I'd like to re-weight an image spatially, such that the central pixels are expanded and peripheral pixels occupy proportionately less space. Think fish-eye lens. Kinda.

Are there any .NET tools that can do this? I don't mind whether they're built into the .NET core, or an addon.

Upvotes: 5

Views: 2073

Answers (3)

Lou Franco
Lou Franco

Reputation: 89222

Disclaimer: I work for Atalasoft

Our free imaging SDK DotImage Photo Free, can do this:

http://www.atalasoft.com/free-dotnet-image-sdk

Look at Atalasoft.Imaging.ImageProcessing.Transforms.LensTransform. You would do something like

AtalaImage img = new AtalaImage("file.jpg");
LensTransform cmd = new LensTransform();
cmd.Radius = 100;
cmd.Offset = new Point(100, 100); // set the center
AtalaImage img2 = cmd.Apply(img).Image;

Upvotes: 1

user180326
user180326

Reputation:

You can achieve such effects quite easily with WPF shader effects.

If you haven't heard about them, the idea is that you can run Direct3D pixel shader effects over any image. This will make it very easy to do effects like you describe at realtime framerates.

In many way this is easier than writing the them in C# or C, because you don't need to worry about adressing the color samples in an image buffer, range checks, and or correctly looping over your data as all of this is handled by the video card hardware.

Here's a link to a channel9 video showcasing the example effects in the wpffx sample library.

I think the "smooth magnify" is very close to what you want.

Upvotes: 1

ravibhagw
ravibhagw

Reputation: 1740

Hmm... you could try using ImageMagick's API to perform any operation you need.

http://www.imagemagick.org/script/api.php

They have two .NET solutions available. You should be able to investigate and find one that best suits your needs. One of their features includes generalized pixel distortion, which you may be able to use to suit your needs.

Upvotes: 1

Related Questions