I'm transforming cartesian images into polar images. (x,y) => (angle, radius)
I fill the polar image by iterating on each of its pixels and filling them by doing the reverse polar transform. For a given (angle, radius) pair, I'm interpolating in the source cartesian image at the following location:
xcartesianpoint = cos( angle ) * radius + center.x; ycartesianpoint = sin( angle ) * radius + center.y;
(I do some computation with the polar image)
Then I transform back the polar image in cartesian coordinates. Again, I'm filling the destination image by doing the inverse transformation. For a given (x,y) point, I'm interpolating the value from the polar image point located at:
angle = atan2(ycartesianPxl, xcartesianPxl) + M_PI; radius = getRadius(xcartesianPxl, ycartesianPxl); xpolarpoint = angle /_angleStep; // give the index in the polar image corresponding to the angle ypolarpoint = (polarImage.height / maxRadius) * radius;
The points indexes are floating point values that I use to interpolate in the source image of the given transformation.
This code works well but give artifacts like those (first image is the source, second is the transformed source in polar transformed back in cartesian. The artifacts are more apparent on the pixels far from the center):
What I do with my polar images:
I'm polar transforming the source image with the goal of blurring it. This is done to get zoom/spiral like blurs. The blurring is done by doing an FFT of the polar image which is transformed back. The artifact wouldn't be a problem if the whole image was blurred, but it is possible for the user to specify a gain matte that modulates the blur radius for each pixel. So, some pixels may be fully blurred and others not at all.