Non-Affine image transformations in .NET

前端 未结 3 1707
后悔当初
后悔当初 2021-01-12 10:23

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 ro

相关标签:
3条回答
  • 2021-01-12 11:01

    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.

    0 讨论(0)
  • 2021-01-12 11:16

    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

    0 讨论(0)
  • 2021-01-12 11:18

    You can do this in wpf using a the Viewport3d control and a non-affine transform matrix. Rendering this to a bitmap again may be interesting.... Which I "fixed" by including an invisible <image> control with the same image as on my textured plane... (Also, I've had to work around the max texture size issues by splitting up the plane and cropping images...)

    http://www.charlespetzold.com/blog/2007/08/060605.html

    In my case I wanted the reverse of this (transform so arbitrary points on the warped become the corners of my rectangular window), which is the Inverse of the matrix to do the opposite.

    0 讨论(0)
提交回复
热议问题