0

I am trying to convert an image in polar to cartesian coordinates.

examples to convert image to polar coordinates do it explicitly - want a slick matrix method

I thought using the method used above would be a piece of cake but it really isn't!! If anyone finds an error into my code please let me know!

phi=(0:.01:1)*2*pi;
r=0:.01:2;

psi=r<0.5;



psi_c=cos(phi).'*psi;

[P R z]=find(psi_c);
L=500;

X=R.*cos(P);
Y=R.*sin(P);

Xmin=min(X);Xmax=max(X);
Ymin=min(Y);Ymax=max(Y);


F=TriScatteredInterp(X,Y,z);


[Xi,Yi]=meshgrid(linspace(-Xmax,Xmax,L),linspace(-Ymax,Ymax,L));
Zi=F(Xi,Yi);

What I find very odd is the fact that when I change phi, it makes radical changes and not in the way I expect!

Cheers!

Community
  • 1
  • 1
user2291072
  • 1
  • 1
  • 1

1 Answers1

0
[X,Y] = pol2cart(THETA,RHO)

in case of conversion from polar grid to cartesian.

Likewise,

[X,Y] = pol2cart(THETA,RHO,Z)

to convert a cylindrical grid into the respective cartesian.

But I'm unsure those functions are what you need.

fpe
  • 2,700
  • 2
  • 23
  • 47
  • Unfortunately they are not... pol2cart doesn't handle 2D matrices (Even though the name of the function is pol2cart) – user2291072 Apr 17 '13 at 14:33