2016-09-23 27 views
0

デカルト座標系の画像を極座標表現に変換する効率的な方法を計算しようとしています。私はImToPolarのようないくつかの関数がそれをやっていることは知っていますが、それは完璧に動作しますが、大きな画像にはかなりの時間がかかります。Matlab:デカルト画像をデカルトの極座標で抽出

Here's私の入力画像:

input image

と、私は0を中心と直交メッシュと機能cart2pol()を用いて極性メッシュを生成します。最後に、mesh(theta, r, Input)を使用して画像をプロットします。

そして、私が得る何here's:

output image

その正確画像は私が必要とImToPolarまたは多分より良いと同じit's。

MATLABは計算方法を知っているので、誰もこの出力から極座標で行列を抽出する方法を知っていますか?あるいは、高速(高速フーリエ変換のような)の方法で、MATLAB上の極座標変換(および逆行列)を計算する方法はありますか?

+0

あなたが規則的なグリッド上にあなたの極性の画像を補間する必要がありますか?あなたの方法は非正方形のピクセルになります – Suever

+0

[ここ](https://fossies.org/dox/octave-4.0.3/cart2pol_8m_source.html)は、OCTAVEのcart2polのソースです。使用するにはいくつかの変更が必要な場合があります。私はそれがより速くなるかどうかわからない。あなたはそれを適応させることができるかもしれません。私は_guess_ MATLABにはあなたが取り除くことができるかもしれないオーバーヘッドがたくさんあります。 – chessofnerd

答えて

0

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

ありがとう、それは完璧に動作します! – Marko

関連する問題