I took the 360 degree photo from
http://www.0-360.com/elements.asp and trimmed it to the circle area
Then I followed the instructions and used Photoshop to generate the following polar to rectangular image:
Then I implemented a formula from first principles using IM -fx to try to match that of Photoshop.
This implements:
y=r*cos(theta)-yc
x=r*sin(theta)-xc
where x and y are reversed due to the fact that y increases downward and theta increases from 0 (both + and -) away from the y axis rather than the x axis. Also the result has r going downward and theta horizontally with the middle of the source image at the top center of the output.
Note that this is actually a rectangular to polar transformation as the input is rectangular (x,y) and the output is polar (r,theta) when implemented as an inverse transformation so that one can sequence through the output and find the location in the input, get that color and transfer to the output. Seems like Photoshop has their notation reversed.
Nevertheless, this works fairly closely (but not exactly) to reproduce the results from photoshop for their polar to rectangular option, but only for a square image. I am not sure what tweaking Photoshop is doing otherwise for normalizing the radius. When a square image is used, r=j/2 works likely due to the radius being half the height of the image. Here is the IM function using -fx or as Anthony calls it, a DIY implementation for Do It Yourself.
convert circle_trim.png -monitor \
-fx "yy=(j/2)*cos((2*pi)*(i/(w-1))-(pi))+h/2; xx=(j/2)*sin((2*pi)*(i/(w-1))-(pi))+w/2; u.p{xx,yy}" \
circle_trim_im_polar2rect.png
Here is the image:
