Convert image in polar to cartesian coordinates

a 夏天 提交于 2019-12-12 03:55:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!