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')
你需要你的插值極座標圖象到規則的網格?你的方法導致非方形「像素」 – Suever
[這裏](https://fossies.org/dox/octave-4.0.3/cart2pol_8m_source.html)是OCTAVE的cart2pol的來源。它可能需要一些更改才能使用。如果速度會更快,我不知道。你可能會適應它。我會_guess_ MATLAB有很多開銷,你可能會擺脫。 – chessofnerd