15,849,768 members
See more:
I am writing a C# code where I am using the RotateBilinear(double angle) filter available in the AForge.NET imaging library.
I want a mapping from old pixel co-ordinates (x0,y0) before rotation to the new pixel co-ordinates (x1,y1) after rotation. Is there a way to do find such a mapping ?

Posted
Manfred Rudolf Bihy 13-Dec-13 5:57am
An interesting question, but alas the AForge API doesn't seem to provide any help there.
Cheers!

## Solution 1

There is no one to one mapping since the bilinear rotation has the effect that any one pixel in the resulting image will depend on a 2 x 2 matrix of pixels from the original image. Having a quick look at the AForge API I didn't see any method, that would allow you to find out which pixel in the resulting image was influenced by which pixels from the original image.
You'd have to implement a bilinear rotation yourself and update a list of influencing pixels from the original per pixel in the resulting image as you go.
Depending on the size of your image that may very well consume quite a bit of memory, so beware you don't run into a out of memory exception.

Regards,
— Manfred

v3
Guru Swaroop 14-Dec-13 1:43am
Thanks for the suggestion. I myself browsed the AForge.NET library to see if any such method is available, but I didn't find it. I think so I must do this rotation myself...

## Solution 2

I have found an excellent link where Vincent explains how we can do this bilinear rotation manually

http://polymathprogrammer.com/2008/10/06/image-rotation-with-bilinear-interpolation/[^]

this solved my problem !!!

Guru Swaroop 14-Dec-13 5:19am
Well the code given in the above link does the job pretty well but it takes a lot of time.
I ran the algorithm on a image of dimension 640X490, and it took 3.62 seconds to complete the job. I am using Intel(R)Core(TM)2 Duo CPU E*2000 @ 2.66GHz ; 4GB RAM ; 64bit Windows7 Profesional OS. Any tips on how to improve the code are welcome.