目前尚不清楚您要做什么,这就是为什么我要自己举个例子...
因此,给定一张图像,我使用CART2POL将像素 x/y 坐标从笛卡尔坐标转换为极坐标。
在第一个图中,我显示了点的位置,在第二个图中,我绘制了原始图像和带有极坐标的图像。
请注意,我使用的是图像处理工具箱中的WARP函数。在后台,它使用SURF / SURFACE函数来显示纹理映射图像。
% load image
load clown;
img = ind2rgb(X,map);
%img = imread(...); % or use any other image
% convert pixel coordinates from cartesian to polar
[h,w,~] = size(img);
[X,Y] = meshgrid(1:w,1:h);
[theta,rho] = cart2pol(X, Y);
Z = zeros(size(theta));
% show pixel locations (subsample to get less dense points)
XX = X(1:8:end,1:4:end);
YY = Y(1:8:end,1:4:end);
tt = theta(1:8:end,1:4:end);
rr = rho(1:8:end,1:4:end);
subplot(121), scatter(XX(:),YY(:),3,'filled'), axis ij image
subplot(122), scatter(tt(:),rr(:),3,'filled'), axis ij square tight
% show images
figure
subplot(121), imshow(img), axis on
subplot(122), warp(theta, rho, Z, img), view(2), axis square

编辑
正如我最初所说,这个问题并不清楚。您必须以明确定义的方式描述您想要的映射...
一方面,您需要在转换为极坐标之前考虑原点的位置。前面的示例假定原点是位于 的坐标区(0,0)
。假设您想将图像的中心(w/2,h/2)
作为原点,那么您可以这样做:
[X,Y] = meshgrid((1:w)-floor(w/2), (1:h)-floor(h/2));
其余代码不变。为了更好地说明效果,请考虑在笛卡尔坐标中绘制同心圆的源图像,并注意当使用圆心作为原点时它们如何映射到极坐标中的直线:

编辑
这是另一个示例,说明如何按照评论中的要求在极坐标中显示图像。请注意,我们以相反的方向执行映射pol2cart
:
[h,w,~] = size(img);
s = min(h,w)/2;
[rho,theta] = meshgrid(linspace(0,s-1,s), linspace(0,2*pi));
[x,y] = pol2cart(theta, rho);
z = zeros(size(x));
subplot(121), imshow(img)
subplot(122), warp(x, y, z, img), view(2), axis square tight off

再次,如果你给它一个带有直线的输入图像,效果会更好,并查看它们如何在极坐标中映射(垂直线变成圆形,水平线变成从原点发出的光线):
