【问题标题】:Matlab: Extract Image in polar representation from CartesianMatlab:从笛卡尔坐标中提取极坐标表示的图像
【发布时间】:2016-09-23 16:11:35
【问题描述】:

我正在尝试计算一种将笛卡尔坐标中的图像转换为极坐标表示的有效方法。我知道一些功能,如 ImToPolar 正在执行此操作,它运行良好,但对于大图像需要相当长的时间,尤其是当它们需要来回处理时。

这是我的输入图像:

然后我使用以 0 为中心的笛卡尔网格和函数cart2pol() 生成极坐标网格。最后,我使用mesh(theta, r, Input) 绘制我的图像。

这是我得到的:

它正是我需要的图像,它与ImToPolar 相同,或者可能更好。

既然 MATLAB 知道如何计算它,那么有人知道如何从这个输出中提取一个极坐标表示的矩阵吗?或者可能是在 MATLAB 上计算极坐标变换(和逆变换)的快速(如快速傅立叶变换)方式?

【问题讨论】:

  • 您需要将极坐标图像插入到常规网格上吗?您的方法导致非方形“像素”
  • Here 是 OCTAVE 的 cart2pol 来源。它可能需要一些更改才能使用。我不知道它是否会更快。你也许可以适应它。我 MATLAB 有很多开销,你也许可以摆脱它。

标签: image matlab polar-coordinates cartesian


【解决方案1】:

pol2cartmeshgridinterp2 足以创建结果:

I=imread('http://i.stack.imgur.com/HYSyb.png');
[r, c,~] = size(I);
%rgb image can be converted to indexed image to prevent excessive copmutation for each color
[idx, mp] = rgb2ind(I,32);
% add offset to image coordinates
x = (1:c)-(c/2);
y = (1:r)-(r/2);
% create distination coordinates in polar form so value of image can be interpolated in those coordinates
% angle ranges from 0 to 2 * pi and radius assumed that ranges from 0 to 400
% linspace(0,2*pi, 200) leads to a stretched image try it!
[xp yp] = meshgrid(linspace(0,2*pi), linspace(0,400));
%translate coordinate from polar to image coordinates
[xx , yy] = pol2cart(xp,yp);
% interpolate pixel values for unknwon coordinates
out = interp2(x, y, idx, xx, yy);
% save the result to a file
imwrite(out, mp, 'result.png')

【讨论】:

    猜你喜欢
    • 2015-06-17
    • 1970-01-01
    • 1970-01-01
    • 2016-04-14
    • 2013-08-05
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多