Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
convert to polar coordinate

Subject: convert to polar coordinate

From: Ibtesam Saleh

Date: 20 May, 2010 15:45:19

Message: 1 of 3

hi...
I want to make sure if my way is correct to convert my image to polar coordinate or not,
If not please tell me the correct way.

img=imread(imageName);
img= imresize(img, [500 500]);
% find the Cartesian coordinate
[x,y]=find(img);
% convert from Cartesian to polar
[theta,radius]=cart2pol(x,y); %The arrays X and Y must be the same size that why I use imresize


1- but how I know the best size for all my images to resize them??
2- how can I get the polar image as a matrix from [theta,radius] because I want use the image after get its polar coordinate?

Subject: convert to polar coordinate

From: Roger Stafford

Date: 20 May, 2010 17:49:04

Message: 2 of 3

"Ibtesam Saleh" <bossy_4me@yahoo.com> wrote in message <ht3lef$jt6$1@fred.mathworks.com>...
> hi...
> I want to make sure if my way is correct to convert my image to polar coordinate or not,
> If not please tell me the correct way.
>
> img=imread(imageName);
> img= imresize(img, [500 500]);
> % find the Cartesian coordinate
> [x,y]=find(img);
> % convert from Cartesian to polar
> [theta,radius]=cart2pol(x,y); %The arrays X and Y must be the same size that why I use imresize
>
>
> 1- but how I know the best size for all my images to resize them??
> 2- how can I get the polar image as a matrix from [theta,radius] because I want use the image after get its polar coordinate?
- - - - - - - - -
  Cartesian coordinates as applied to an image unquestionably refer to pixel positions x and y. You will not generate these using the 'find' function. Presumably you would do this:

 [m,n] = size(img);
 [x,y] = meshgrid(1:n,1:m);

Resizing is not called for in doing this.

  However, before converting to polar coordinate you need to decide where the origin is to be located for these. Suppose you want the center of the image to be the origin for this purpose. Then you would do this:

 c = ((m+1)/2,(n+1)/2);
 [theta,rho] = cart2pol(x-c,y-c);

Or, if the origin is to be the upper lefthand corner, use
 [theta,rho] = cart2pol(x-1,y-1);

Roger Stafford

Subject: convert to polar coordinate

From: Eric

Date: 14 Mar, 2013 18:28:15

Message: 3 of 3


> Cartesian coordinates as applied to an image unquestionably refer to pixel positions x and y. You will not generate these using the 'find' function. Presumably you would do this:
>
> [m,n] = size(img);
> [x,y] = meshgrid(1:n,1:m);
>
> Resizing is not called for in doing this.
>
> However, before converting to polar coordinate you need to decide where the origin is to be located for these. Suppose you want the center of the image to be the origin for this purpose. Then you would do this:
>
> c = ((m+1)/2,(n+1)/2);
> [theta,rho] = cart2pol(x-c,y-c);
>
> Or, if the origin is to be the upper lefthand corner, use
> [theta,rho] = cart2pol(x-1,y-1);
>
> Roger Stafford

Roger,
I agree with you regarding the resizing, but I still have a big problem using the method you described. Doing a
figure, pcolor(theta,rho,img), shading interp

gives a weird result, and doing a

figure, surf(theta,rho,img), shading interp

clearly shows why the pcolor looks weird... however I don;t really understand what's happening and as Ibtesam in his previous message, I am still looking for a way to get a matrix out of the polar transformation, that I could "imagesc".
Do you think I need to go for an interpolation method using IriIcatterInterp, or do you have a solution from the method you described earlier ?

Thank you
Eric

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us