【图像拼接】基于Harris角点检测实现图像拼接含Matlab源码

本文介绍了Harris角点检测算法,它是基于Moravec算法的改进,通过计算窗口内灰度变化和使用自相关函数的M矩阵来确定特征点。在图像拼接中,算法用于找到稳定特征点进行匹配,代码示例展示了如何进行图像融合。最终,通过Matlab实现了一种图像拼接方法,结合Harris角点检测实现了平滑过渡的图像融合效果。
摘要由CSDN通过智能技术生成

1 简介

Harris 角点检测算法是由 ​C.Harris 和 J.Stephens 在 1988 年提出,此算法的原理是建立在 ​Moravec 算法的基础上进行大幅改进的,相比之前的算法更具明显的优势。​Moravec如上文中的介绍说明,相比 Harris 检测算法而言,

Moravec 检测算法仅仅只是是在水平、垂直、对角线和反对角线四个方向上对灰度变化的信息进行处理,而 Harris 检测算法受到数学理论泰勒(Taylor

)级数的启发,以此展开思路,已不只是限定于四个方向,而是计算窗口内沿任意方向的灰度变化情况,最终利用数学解析式进一步确定所需特征点。并且算法引入高斯平滑算子,更加优化了算法自身的鲁棒性。不仅如此,Harris 

检测算法还受到信号处理中自相关函数的启迪,从而使用了自相关函数相关联的 M 矩阵。​

该算法中 M 矩阵的特征值即自相关函数的一阶求导函数,判断该点是否为特征点即看​此处像素点的曲率值是否够高。

正在上传…重新上传取消正在上传…重新上传取消正在上传…重新上传取消

正在上传…重新上传取消正在上传…重新上传取消

2 部分代码

function [imgout]=warpTheImage(H,img1,img2)tform = maketform('projective',H');img21 = imtransform(img2,tform); % reproject img2% [M1 N1 dim] = size(img1);[M2 N2 dimk1] = size(img2);% do the mosaicpt = zeros(3,4);pt(:,1) = H*[1;1;1];pt(:,2) = H*[N2;1;1];pt(:,3) = H*[N2;M2;1];pt(:,4) = H*[1;M2;1];x2 = pt(1,:)./pt(3,:);y2 = pt(2,:)./pt(3,:);up = round(min(y2));Yoffset = 0;if up <= 0  Yoffset = -up+1;  up = 1;endleft = round(min(x2));Xoffset = 0;if left<=0  Xoffset = -left+1;  left = 1;end[M3 N3 dimk2] = size(img21);rowBegin=max(up,Yoffset+1); %overlap AreacolumnBegin=max(left,Xoffset+1);rowEnd=min(up+M3-1,Yoffset+M1);columnEnd=min(left+N3-1,Xoffset+N1);imgout(up:up+M3-1,left:left+N3-1,:) = img21;overlapAreaP2=imgout(rowBegin:rowEnd,columnBegin:columnEnd,:);%pixel values of overlap area from P2% img1 is above img21imgout(Yoffset+1:Yoffset+M1,Xoffset+1:Xoffset+N1,:) = img1;overlapAreaP1=imgout(rowBegin:rowEnd,columnBegin:columnEnd,:); overlapArea=imgout(rowBegin:rowEnd,columnBegin:columnEnd); [overRowLength,overColumnLength]=size(overlapArea);%overlap Row and Column length distFromBound1OneLine=(overColumnLength-1:-1:0);%this is just one line distFromBound1=repmat(distFromBound1OneLine,overRowLength,1);  %Replicate and tile it to the size of the overlapArea. Because the same column has the same distance to the boundary distFromBound2OneLine=(0:overColumnLength-1); distFromBound2=repmat(distFromBound2OneLine,overRowLength,1);%this the dist from boundary 2 % blending%  blendingImg(:,:,:)=(overlapAreaP2(:,:,:).*distFromBound2+overlapAreaP1(:,:,:).*distFromBound1)/(overColumnLength-1);% imshow(blending)overlapAreaP2=double(overlapAreaP2);overlapAreaP1=double(overlapAreaP1);blendingImg=zeros(overRowLength,overColumnLength,3);for i=1:3blendingImg(:,:,i)=(overlapAreaP2(:,:,i).*distFromBound2+overlapAreaP1(:,:,i).*distFromBound1)/(overColumnLength-1);endblendingImg=uint8(blendingImg);% imshow(blendingImg);title('after blending'); imgout(rowBegin:rowEnd,columnBegin:columnEnd,:)=blendingImg;end

3 仿真结果

4 参考文献

[1]贾莹. 基于Harris角点检测算法的图像拼接技术研究[D]. 吉林大学.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值