Results 1 to 11 of 11
 10052015, 10:30 PM #1Member
 Join Date
 Mar 2015
 Location
 A Place With Windows
 Posts
 71
 Rep Power
 0
Pixel Transform: Cartesian to Polar
Hey guys, I'm working on a project where I need to transform a traditional image into a polar image (Rectangular>Circular).
Suggestions? Anyone have experience with this type of idea? It's my assumption there is some known algorithm that I could apply here, or some method that I am unaware of.
Thanks!
 10052015, 11:17 PM #2Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 6,226
 Rep Power
 14
Re: Pixel Transform: Cartesian to Polar
If you want to rotate the image a certain number or radians you can apply a rotational transform to a graphics instance.
Regards,
JimThe Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
 10062015, 01:28 AM #3Member
 Join Date
 Mar 2015
 Location
 A Place With Windows
 Posts
 71
 Rep Power
 0
Re: Pixel Transform: Cartesian to Polar
Not to rotate, but instead mutate/transform.... I want to go from an image that is rectangular to circular. [ ] > ( )
 10062015, 01:58 AM #4Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 6,226
 Rep Power
 14
Re: Pixel Transform: Cartesian to Polar
The Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
 10062015, 02:13 AM #5Member
 Join Date
 Mar 2015
 Location
 A Place With Windows
 Posts
 71
 Rep Power
 0
Re: Pixel Transform: Cartesian to Polar
Something like this
 10062015, 03:33 AM #6Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 6,226
 Rep Power
 14
Re: Pixel Transform: Cartesian to Polar
I have never done that before (it looks similar to an anamorphic projection). Here is a link I found which has some code (not Java). It may offer some help.
Polar To/From Rectangular Transform of Images  File Exchange  MATLAB Central
Regards,
JimThe Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
 10062015, 12:33 PM #7
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 28
Re: Pixel Transform: Cartesian to Polar
Rectangular coordinates (x,y) can be written in polar form as (r*sin(phi), r*cos(phi); you want coordinates (r, phi); note that r^2 == x^2+y^2 and phi == atan(y/x)
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
 10062015, 05:29 PM #8Member
 Join Date
 Mar 2015
 Location
 A Place With Windows
 Posts
 71
 Rep Power
 0
Re: Pixel Transform: Cartesian to Polar
Assuming I wrote it that way, all of my pixles will stay in the same place...they'll just be described in a polar form where r^2=x_max^2+y_max^2 and phi ranges from [0,90].
I want to actually mutate the image. To move the pixel in (0,0)Javacart(note: (0,0) is in the top left corner) to (r_max,0)polar
 10062015, 06:23 PM #9
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 28
 10062015, 07:08 PM #10Member
 Join Date
 Mar 2015
 Location
 A Place With Windows
 Posts
 71
 Rep Power
 0
Re: Pixel Transform: Cartesian to Polar
It seems to me that is I preserve the height of yaxis as the radius then all I have to do is "bend" the xaxis 360°. But in doing so I'd have gaps in my image, and I'm not sure how to handle that gradience.
 10072015, 04:20 AM #11Moderator
 Join Date
 Feb 2009
 Location
 New Zealand
 Posts
 4,716
 Rep Power
 17
Re: Pixel Transform: Cartesian to Polar
If I understand correctly you want to take each pixel in your source image and interpret its ycoordinate as r and its xcoordinate as phi. (You would scale the xcoordinate by 2*pi/width so that phi ends up going from 0>2*pi. You might also want to scale the ycoordinate to keep the final radius a reasonable size.). In other words your source image is telling you the colour of each pixel (r,phi) in the destination image.
The tricky bit is that the pixels in the destination image don't lie *exactly* at places (r,phi) for integer r and phi.
I can imagine two ways of dealing with this: The first is to simply round values. So, for each value in the destination image (1) calculate what r and phi is associated with that pixel, (2) scale these values if desired, (3) round the result to a pair of integers, (4) look up the value for the pixel in the original image.
The more complicated way recognises that each pixel of the destination image really represents a region of the source image. Take the (weighted) mean of all the pixels in this region and use this for the colour of the target image pixel.

As an aside CAT scanners face a similar problem. The values from the scanner are 1d fourier transformed and assembled to make a 2d image (whose pixel values are given for polar positions ie regularly spaced values of r and phi). This 2d image is then inverse 2d fourier analysed to reveal a section of the patient's inside. The problem is that the inverse transform wants the values at cartesian positions (ie regularly spaced values of x and y).
[Edit: from a computational standpoint it makes no difference whether you view the problem as the mutation of an image or merely as a change of coordinate system.]Last edited by pbrockway2; 10072015 at 04:45 AM.
Similar Threads

Scanning Image Pixel by Pixel
By the_transltr in forum Advanced JavaReplies: 5Last Post: 08282012, 05:01 PM 
Cartesian coordinate system (X > 0, Y>0)
By cselic in forum Java 2DReplies: 0Last Post: 07022010, 02:54 PM 
compare two images pixel by pixel
By java_bond in forum Advanced JavaReplies: 6Last Post: 03022010, 12:27 PM 
[SOLVED] Bouncing ball with polar coordinates
By Ypsilon IV in forum New To JavaReplies: 4Last Post: 04222009, 01:19 AM 
Conversion between polar and rectangular coordinates
By Java Tip in forum java.langReplies: 0Last Post: 04162008, 11:55 PM
Bookmarks