问题
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!
回答1:
[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.
来源:https://stackoverflow.com/questions/16062335/convert-image-in-polar-to-cartesian-coordinates