⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 新建 文本文档.txt

📁 用相位相关方法做的图象拼接程序,可进行图象拼接
💻 TXT
字号:
a3=imread('a.jpg');%读入图像<br />
a4=imread('b.jpg'); <br />
a1=a3(1:178,1:178);<br />
a2=a4(51:228,51:228);<br />
subplot(2,2,1),imshow(a1)<br />
subplot(2,2,2),imshow(a2) %显示规定大小的图像<br />
b1=a1(:,:,1); %取R分量<br />
b2=a2(:,:,1); <br />
g1=fft2(b1);%求FFT变换<br />
g2=fft2(b2);<br />
g2=conj(g2);<br />
c=ifft2(g1.*g2/norm(g1.*g2));%求户功率谱,求平移量<br />
c=abs(c);&nbsp;&nbsp;%求绝对值<br />
c_max=max(max(c));&nbsp;&nbsp;%求最大值<br />
[m,n]=find(c==c_max);&nbsp;&nbsp;%求最大值处的位置<br />
figure,mesh(abs(c))&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;%创建拼接图,绘二维网线<br />
[heighth,width]=size(a1);<br />
mos_height=height+m-1;<br />
mos_width=width+n-1;<br />
a=uint8(255*ones(mos_height,mos_width))%全1数组<br />
k=1;<br />
for i=1:width&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;%融合<br />
&nbsp;&nbsp;for j=1:heighth<br />
&nbsp; &nbsp; if a1(i,j)==a2(i+m,j+n)<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;if i&lt;k<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; k=i;<br />
&nbsp; &nbsp;&nbsp; &nbsp; a(i,j)=0.5a1(i,j)+a2(i+m,j+n) %显示重叠部分<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; l=j;<br />
&nbsp;&nbsp;end<br />
end<br />
for i=1:width&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
&nbsp;&nbsp;for j=1:height&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
&nbsp; &nbsp; if i&gt;k and j&lt;l<br />
&nbsp; &nbsp;&nbsp; &nbsp;a(i,j)=a1(i,j) %显示属于a1的部分<br />
&nbsp;&nbsp;end<br />
end<br />
for i=1:width<br />
&nbsp;&nbsp;for j=1:heighth<br />
&nbsp; &nbsp; if i&lt;(k+m )and j&gt;l&nbsp;&nbsp;<br />
&nbsp; &nbsp;&nbsp;&nbsp;a(i+m,j+n)=a2(i,j) %显示属于a2的部分<br />
&nbsp;&nbsp;end<br />
end<br />
subplot(2,2,3),imshow(a)<br />
toc<br />
<br />

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -