Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image Matlab:从笛卡尔坐标系中提取极坐标表示的图像_Image_Matlab_Polar Coordinates_Cartesian - Fatal编程技术网

Image Matlab:从笛卡尔坐标系中提取极坐标表示的图像

Image Matlab:从笛卡尔坐标系中提取极坐标表示的图像,image,matlab,polar-coordinates,cartesian,Image,Matlab,Polar Coordinates,Cartesian,我试图计算一种有效的方法,将笛卡尔坐标系下的图像转换为极坐标表示。我知道ImToPolar之类的一些功能正在这样做,它工作得非常完美,但对于大图像来说需要相当长的时间,特别是当它们需要来回处理时 这是我的输入图像: 然后我使用以0为中心的笛卡尔网格和函数cart2pol()生成一个极轴网格。最后,我使用网格(θ,r,Input)绘制图像 以下是我得到的: 这正是我需要的图像,它与ImToPolar相同,或者更好 既然MATLAB知道如何计算它,有人知道如何从这个输出中提取极坐标表示的矩阵吗?

我试图计算一种有效的方法,将笛卡尔坐标系下的图像转换为极坐标表示。我知道ImToPolar之类的一些功能正在这样做,它工作得非常完美,但对于大图像来说需要相当长的时间,特别是当它们需要来回处理时

这是我的输入图像:

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

以下是我得到的:

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


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

pol2cart
meshgrid
interp2
足以创建结果:

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')

pol2cart
meshgrid
interp2
足以创建结果:

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')

是否需要将极轴图像插值到规则栅格上?您的方法产生的非方形“像素”是cart2pol的倍频程源。它可能需要一些更改才能使用。我不知道它是否会更快。你也许能适应它。我猜MATLAB有很多开销,你可能可以摆脱。你需要把你的极坐标图像插值到一个规则的网格上吗?您的方法产生的非方形“像素”是cart2pol的倍频程源。它可能需要一些更改才能使用。我不知道它是否会更快。你也许能适应它。我猜MATLAB有很多开销,你可以摆脱它们。