Just only transferring registration

%read model and image
Img=imread(“*.jpg”,'jpg’);
Mdl=imread(“*.jpg”,'jpg’);

%get just only one channel
Img=Img(1:end,1:end,1);
Mdl=Mdl(1:end,1:end,1);

%make the two images have same size
(wid,hgh)=size(Img);
(twid,thgh)=size(Mdl);
mMdl=zeros(wid,hgh);
xstart=(wid-twid)+1;
ystart=(hgh-thgh)+1;
mMdl(xstart:(xstart+twid-1),ystart:(ystart+thgh-1))=Mdl;

%Fourer transform
IF=fft2(Img);
TF=fft2(mMdl);

%in case of overflow
rnumerator=abs(IF.*TF);
tem=(rnumerator==0);
rnumerator=rnumerator+tem;
tem=1-tem;

%get the ratio of registration (re)
Ra=IF.*conj(TF)/rnumerator;
re=ifft(Ra);
re=re.*tem;
Pos=GetMaxPos(re);

發佈了51 篇原創文章 · 獲贊 0 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章