Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-Affine image transformations in .NET

Are there any classes, methods in the .NET library, or any algorithms in general, to perform non-affine transformations? (i.e. transformations that involve more than just rotation, scale, translation and shear)

e.g.:

alt text

alt text
(source: last100.com)


Is there another term for non-affine transformations?

like image 462
Ian Boyd Avatar asked Feb 10 '09 21:02

Ian Boyd


People also ask

What are non affine transformations?

A non affine transformations is one where the parallel lines in the space are not conserved after the transformations (like perspective projections) or the mid points between lines are not conserved (for example non linear scaling along an axis).

What is an example of a non affine transformation?

example of a non-affine transformation is a "sweep": mapping the [0,1] interval on the x-axis to a given path.

Is Homography an affine transformation?

Homographies are transformations of a Euclidean space that preserve the alignment of points. Specific cases of homographies correspond to the conservation of more properties, such as parallelism (affine transformation), shape (similar transformation) or distances (Euclidean transformation).

What is affine image transformation?

Affine transformation is a linear mapping method that preserves points, straight lines, and planes. Sets of parallel lines remain parallel after an affine transformation. The affine transformation technique is typically used to correct for geometric distortions or deformations that occur with non-ideal camera angles.


2 Answers

I am not aware of anything integrated in .Net letting you do non affine transforms.

I guess you are trying to have some sort of 3D texture mapping? If that's the case you need an homogenous affine transform, which is not available in .Net. I'm also not aware of any integrated way to make pixel displacement transforms in .Net.

However, the currently voted solution might be good for what you are trying to do, just be aware that it won't do perspective correction out of the box.

For instance:

alt text

The picture on the left was generated using the single quad distort library provided by Neil N. The picture on the right was generated using a single quad (two triangles actually) in DirectX.

This may not have any impact on what you are trying to do, but this is something to keep in mind if you want to do 3D stuff, it will look very weird without perspective correct mapping.

like image 162
Coincoin Avatar answered Sep 20 '22 00:09

Coincoin


All of the example images you posted can be done with a Quadrilateral Distortion. Though I cant say for certain that a quad distort will cover ALL non affine transforms.

Heres a link to a not so good implementation of it in C#... it works, but is slow. Poke around Wikipedia for the many different optimizations available for these kinds of calculations

http://www.vcskicks.com/image-distortion.html

-Neil

like image 30
Neil N Avatar answered Sep 18 '22 00:09

Neil N