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

img = Import["https://i.sstatic.net/9cV4T.jpg"]

enter image description here

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

enter image description here

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]] &, 
    {2 Pi radius, radius}, DataRange -> Full,
    PlotRange -> {{0, 360 \[Degree]}, {1, radius}}]

One of my failed attempts:

ImageTransformation[imgNorm, {0, Pi radius} + {Sqrt[#[[1]]^2 + #[[2]]^2], 
    ArcTan[#[[2]]/#[[1]]]} &, {2 radius, 2 radius}, DataRange -> Full]

1 Answer 1


This seems to work:

 {ArcTan @@ (radius - #), Norm[# - radius]} &, 
 {2 radius, 2 radius}, 
 DataRange -> {{-180 \[Degree], 180 \[Degree]}, {1, radius}}, 
 PlotRange -> {{0, 2 radius}, {0, 2 radius}}]


  • 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.


  • 1
    $\begingroup$ 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. $\endgroup$
    – paw
    Aug 30, 2014 at 7:52
  • $\begingroup$ @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. $\endgroup$ Aug 31, 2014 at 11:11
  • $\begingroup$ @paw and @nikie : Thanks a lot for both of your code examples that are very helpful to me. However, could you please explain why ({x,y} + {Cos[#[[1]]], Sin[#[[1]]]}*#[[2]] &) does what it is doing in ImageTransormation? Because I tried to understand the transformation by using a list of pixel positions, e.g. {{1,1},{1,2},...,{2,1},{2,2}...} and the transformed pixel positions on which I applied the above equation and displayed the results using ListPlot`. Thanks a lot! $\endgroup$
    – Quit007
    Dec 22, 2016 at 22:08
  • $\begingroup$ @paw and @nikie : My motivation is that I want to use an arbitrary vector center={x,y} about which to tranform the image in polar coordinates. But I get problems with the settings I need to use for PlotRange in order to display the whole transformed image. Thank you! $\endgroup$
    – Quit007
    Dec 22, 2016 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.