資源簡介
zw_PhaseCorrelationRegistration.zip

代碼片段和文件信息
function?[diracSignal_2DtranslationVector_PixtranslationVector_SubpeakValue]?=?PhaseCorrelationRegistration(imageInput_PreimageInput_Cur)
%?%?This?function?estimates?the?(pixel?and?subpixel?level)?motion?vector?using?the?phase?correlation?method;
%?%?The?frame?which?will?be?interpolated?matches?the?first?variable
%?%?Compare?the?size?of?two?images
[row_Precol_Predimen_Pre]?=?size(imageInput_Pre);
%?[row_Curcol_Curdimen_Cur]?=?size(imageInput_Cur);
%?if?(row_Pre~=row_Cur)|(col_Pre~=col_Cur)|(dimen_Pre~=dimen_Cur)
%?????error(‘The?two?images?input?should?be?of?the?same?size!‘);
%?????return;
%?end
%?%?Convert?the?RGB?images?to?gray?images
if?dimen_Pre==3
????gray_Pre?=?rgb2gray(imageInput_Pre);
????gray_Cur?=?rgb2gray(imageInput_Cur);
elseif?dimen_Pre==1
????gray_Pre?=?imageInput_Pre;
????gray_Cur?=?imageInput_Cur;
else
????error(‘Not?the?proper?image?format!‘);
????return;
end
%?%?To?reduce?the?computational?cost
%截取圖象大小128*128
?%???gray_Pre?=?gray_Pre(51:178101:228);
?%???gray_Cur?=?gray_Cur(51:178101:228);
?%???row_Pre?=?128;
?%???col_Pre?=?128;
?
?%下采樣圖象大小256*256
%??for?u=1:256
%??????for?v=1:256
%??????????gray_Pre1(uv)?=?gray_Pre(u*2v*2);
%??????????gray_Cur1(uv)?=?gray_Cur(u*2v*2);
%??????end
%??end
?
%???gray_Pre?=?gray_Pre1;
%???gray_Cur?=?gray_Cur1;
????
%???row_Pre?=?256;
%???col_Pre?=?256;
?%chipping?is?end.???
%?%?Fourier?transform?of?the?two?images?
spectrum_Pre?=?fft2(double(gray_Pre));
spectrum_Cur?=?fft2(double(gray_Cur));
%?%?Acquire?the?CPS(Cross?Power?Spectrum)
%?CPS?=?ones(row_Precol_Pre);
CPS?=?spectrum_Cur./spectrum_Pre;?
%?Shift?the?spectrum?centre?so?the?(00)?vector?will?be?at?(N/2N/2)
for?u=1:row_Pre
????for?v=1:col_Pre
????????CPS(uv)?=?CPS(uv)*power(-1u+v);?%?MATLAB?offers?fftshift?function?
%?%?-----------------------------------------------------------------------
%?Experiment?of?new?method?which?is?used?to?remove?the?content?varying?effect
%?????????if?abs(spectrum_Pre(uv))<50
%?????????????CPS(uv)?=?0*CPS(uv);
%?????????end
%?%?-----------------------------------------------------------------------
????end
end
%?%?Inverse?DFT?of?CPS?to?get?the?diracSignal_2D?
diracSignal_2D?=?ifft2(CPS);?
%?%?Acquire?the?peak?value?of?2D?dirac?signal?and?the?pixel?level?translation?vector
peakValue?=?diracSignal_2D(11);
translationVector_Pix?=?[1?1];
for?u=1:row_Pre
????for?v=1:col_Pre
????????if?diracSignal_2D(uv)>peakValue
????????????translationVector_Pix?=?[u?v];
????????????peakValue?=?diracSignal_2D(uv);
????????end
????end
end
%?%?Acquire?the?subpixel?level?traslation?vector
%?tv_Row?=?translationVector_Pix(1);
%?tv_Col?=?translationVector_Pix(2);
%?temp_Row?=?0;?%?To?record?row?neigbour?peak?value???
%?temp_Col?=?0;?%?To?record?column?neigbour?peak?value
%?flag_Row?=?1;?%?To?record?the?direction?of?the?row?neigbour?peak?value
%?flag_Col?=?1;?%?To?record?the?direction?of?the?column?neigbour?pea
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????4216??2019-03-09?20:48??\PhaseCorrelationRegistration.m
?????文件??????????36??2019-03-09?20:48??\no.txt
評論
共有 條評論