Prev: Matlab code for SVC controller
Next: New Solutions Manuals, Test Banks, Instructor Manuals 2011
From: Ja-yun on 29 May 2010 07:57 I have two template 1. http://img541.imageshack.us/img541/5199/dog90.png 2. http://img231.imageshack.us/img231/7269/dogk.png fig 2 is fig 1 rotated by degree 90. I want to find the rotation angle between them by phase correlation. so far i have these code. %%============================== fig1=rgb2gray(imread('dog.bmp')); fig2=rgb2gray(imread('dog90.bmp')); F1=fft2(double(fig1)); F2=fft2(double(fig2)); PF1=imgpolarcoord(F1); % Transform F1,F2 into polar coordinates system PF2=imgpolarcoord(F2); % P(radius,degree) PhaseCorr=(PF1.*conj(PF2))./(abs(F3.*F4)); result=ifft2(double(PhaseCorr)); result=abs(result); %%=============================== I plot the result and got this http://img175.imageshack.us/img175/5299/phasecorr.jpg The peak values appear at each cornor of this fig Is it because my code's wrong or the process? or it's because this method's not suitable for my fig?(OMG) Can somebody help me, i've been stuck with this for a week
From: Matt J on 29 May 2010 08:30 "Ja-yun " <silodraw(a)gmail.com> wrote in message <htqvei$7r0$1(a)fred.mathworks.com>... > PhaseCorr=(PF1.*conj(PF2))./(abs(F3.*F4)); =============== Shouldn't this be PhaseCorr=(PF1.*conj(PF2))./(abs(PF1.*PF2)); > The peak values appear at each cornor of this fig > Is it because my code's wrong or the process? ======= help fftshift
From: Ja-yun on 29 May 2010 09:29 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <htr1cu$9pa$1(a)fred.mathworks.com>... > "Ja-yun " <silodraw(a)gmail.com> wrote in message <htqvei$7r0$1(a)fred.mathworks.com>... > > > PhaseCorr=(PF1.*conj(PF2))./(abs(F3.*F4)); > =============== > > > Shouldn't this be > > PhaseCorr=(PF1.*conj(PF2))./(abs(PF1.*PF2)); thank you for correcting my code,you're right about it > > > > The peak values appear at each cornor of this fig > > Is it because my code's wrong or the process? > ======= > > help fftshift you mean like this? F1=fftshift(fft2(double(fig1))); F2=fftshift(fft2(double(fig2))); .. .. .. I tried and got this http://img180.imageshack.us/img180/9162/fftshift.jpg I still can't see anything about "90 degrees" did i misunderstand what you meant ? thank you for your help
From: Matt J on 29 May 2010 11:24 The following seems to work fig1=256-double( rgb2gray(imread('dogk.png')) ); fig2=256-double( rgb2gray(imread('dog90.png')) ); F1=radon(fig1); F2=radon(fig2); supp=num2cell(size(F1)); suppc=num2cell(size(F1)+size(F2)); PF1=fft2(F1,suppc{:}); PF2=fft2(F2,suppc{:}); den=abs(PF1.*PF2); PhaseCorr=(PF1.*conj(PF2))./den;PhaseCorr(den==0)=0; result=ifft2(PhaseCorr,supp{:}); result=abs(result);
From: Ja-yun on 29 May 2010 23:14 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <htrbj5$e1q$1(a)fred.mathworks.com>... > The following seems to work > > > fig1=256-double( rgb2gray(imread('dogk.png')) ); > fig2=256-double( rgb2gray(imread('dog90.png')) ); > > F1=radon(fig1); > F2=radon(fig2); > > supp=num2cell(size(F1)); > suppc=num2cell(size(F1)+size(F2)); > PF1=fft2(F1,suppc{:}); > PF2=fft2(F2,suppc{:}); > > den=abs(PF1.*PF2); > > PhaseCorr=(PF1.*conj(PF2))./den;PhaseCorr(den==0)=0; > > > result=ifft2(PhaseCorr,supp{:}); > result=abs(result); wow,it works! Are the backgrounds of two figs have to be black? and i don't quite understand what these steps mean can you please explain these to me? %% supp=num2cell(size(F1)); suppc=num2cell(size(F1)+size(F2)); PF1=fft2(F1,suppc{:}); ^^^^^^ PF2=fft2(F2,suppc{:}); .. ^^^^^^ .. result=ifft2(PhaseCorr,supp{:}); ^^^^^ %% why fft2 PF1 and PF2 in suppc and ifft2 PhaseCorr in supp? if i want to obtain a angle ranges from 0 to 360 degrees how should I modify the code? thank you so much!
|
Next
|
Last
Pages: 1 2 Prev: Matlab code for SVC controller Next: New Solutions Manuals, Test Banks, Instructor Manuals 2011 |