Results 1 to 11 of 11
- 10-05-2015, 10:30 PM #1
Member
- 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!
- 10-05-2015, 11:17 PM #2
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
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 JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 10-06-2015, 01:28 AM #3
Member
- 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. [ ] ----> ( )
- 10-06-2015, 01:58 AM #4
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: Pixel Transform: Cartesian to Polar
The JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 10-06-2015, 02:13 AM #5
Member
- Join Date
- Mar 2015
- Location
- A Place With Windows
- Posts
- 71
- Rep Power
- 0
Re: Pixel Transform: Cartesian to Polar
Something like this
- 10-06-2015, 03:33 AM #6
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
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 JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 10-06-2015, 12:33 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
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.
- 10-06-2015, 05:29 PM #8
Member
- 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)Java-cart(note: (0,0) is in the top left corner) to (r_max,0)polar
- 10-06-2015, 06:23 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
- 10-06-2015, 07:08 PM #10
Member
- 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 y-axis as the radius then all I have to do is "bend" the x-axis 360°. But in doing so I'd have gaps in my image, and I'm not sure how to handle that gradience.
- 10-07-2015, 04:20 AM #11
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,716
- Rep Power
- 18
Re: Pixel Transform: Cartesian to Polar
If I understand correctly you want to take each pixel in your source image and interpret its y-coordinate as r and its x-coordinate as phi. (You would scale the x-coordinate by 2*pi/width so that phi ends up going from 0->2*pi. You might also want to scale the y-coordinate 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 1-d fourier transformed and assembled to make a 2-d image (whose pixel values are given for polar positions ie regularly spaced values of r and phi). This 2-d image is then inverse 2-d 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; 10-07-2015 at 04:45 AM.
Similar Threads
-
Scanning Image Pixel by Pixel
By the_transltr in forum Advanced JavaReplies: 5Last Post: 08-28-2012, 05:01 PM -
Cartesian coordinate system (X > 0, Y>0)
By cselic in forum Java 2DReplies: 0Last Post: 07-02-2010, 02:54 PM -
compare two images pixel by pixel
By java_bond in forum Advanced JavaReplies: 6Last Post: 03-02-2010, 12:27 PM -
[SOLVED] Bouncing ball with polar coordinates
By Ypsilon IV in forum New To JavaReplies: 4Last Post: 04-22-2009, 01:19 AM -
Conversion between polar and rectangular coordinates
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 11:55 PM
Bookmarks