# ImageTransformation: polar to cartesian

I am working on something that requires the polar transformation of some images. I implemented this transformation with ImageTransformation:

img = Import["http://i.stack.imgur.com/9cV4T.jpg"]


{center, radius} = ComponentMeasurements[MorphologicalComponents[img, 0.2],
polar = ImageTransformation[img, center + {Cos[#[[1]]], Sin[#[[1]]]}*#[[2]] &,
PlotRange -> {{0, 360 \[Degree]}, {1, radius}}]


After some processing I would like to transform the image back into the original coordinate system. This step is where I ran into problems. The transformation of the coordinates isn't really the problem but I couldn't figure out how to center the transformation properly and what PlotRange I have to provide.
So the question is how to reverse the transformation:

ImageTransformation[img, center + {Cos[#[[1]]], Sin[#[[1]]]}*#[[2]] &,
PlotRange -> {{0, 360 \[Degree]}, {1, radius}}]


One of my failed attempts:

ImageTransformation[imgNorm, {0, Pi radius} + {Sqrt[#[[1]]^2 + #[[2]]^2],

-

This seems to work:

ImageTransformation[polar,

• Don't call ArcTan[y/x]. You'd only get an angle between -90°..90°. There's an overload ArcTan[x,y] that returns an angle from -180°..180°
• Somewhat unintuitively, PlotRange->Full isn't the same as PlotRange->(* dimensions of output image*), it uses the input image's dimensions. If in doubt, give explicit ranges.
Thanks this is exactly what i was looking for. Replacing the 1 in the DataRange option with 0 gets rid of the black dot in the middle. – paw Aug 30 '14 at 7:52
@paw: The black dot is there because the polar image contains no data for that location. If you use 0 in the DataRange of the inverse transform, but used 1 in the PlotRange of the polar transform, the result will be slightly skewed (by 1 pixel at the center). You can either use 0 for both, or use Padding -> "Fixed" to get rid of the black dot in the center. – nikie Aug 31 '14 at 11:11