Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

img = Import[""]

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]
share|improve this question
up vote 10 down vote accepted

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.


share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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