基于SIFT特征提取的图像特征提取配准和拼接matlab仿真

1.算法描述

      SIFT 是一种从图像中提取独特不变特征的方法,其特点为基于图像的一些局部特征,而与图像整体的大小和旋转无关。并且该方法对于光照、噪声、仿射变换具有一定鲁棒性,同时能生成大量的特征点。SIFT (Scale-invariant feature transform), 尺度不变特征转换,是一种图像局部特征提取算法,它通过在不同的尺度空间中寻找极值点(特征点,关键点)的精确定位和主方向,构建关键点描述符来提取特征。

 

       SIFT提取的关键点具有尺度不变性、旋转不变性,而且不会因光照、仿射变换和噪音等因素而干扰。SIFT所查找到的关键点是一些十分突出、不会因光照、仿射变换和噪音等因素而变化的点,如角点、边缘点、暗区的亮点及亮区的暗点等。

 

1. SIFT特征是图像的局部特征,其对旋转、尺度缩放、亮度变化保持不变性,对视角变化、仿射变换、噪声也保持一定程度的稳定性;

 

2. 独特性(Distinctiveness)好,信息量丰富,适用于在海量特征数据库中进行快速、准确的匹配;

 

3. 多量性,即使少数的几个物体也可以产生大量的SIFT特征向量;

 

4. 高速性,经优化的SIFT匹配算法甚至可以达到实时的要求;

 

5. 可扩展性,可以很方便的与其他形式的特征向量进行联合。

 

2.仿真效果预览

matlab2022a仿真结果如下:

 

 

 

 

 

 

 

 

3.MATLAB核心程序

 

function [matchLoc1 matchLoc2] = siftMatch(img1, img2)
 
 
[des1, loc1] = sift(img1);
[des2, loc2] = sift(img2);
 
distRatio = 0.6;   
 
% For each descriptor in the first image, select its match to second image.
des2t = des2';                          % Precompute matrix transpose
matchTable = zeros(1,size(des1,1));
for i = 1 : size(des1,1)
   dotprods = des1(i,:) * des2t;        % Computes vector of dot products
   [vals,indx] = sort(acos(dotprods));  % Take inverse cosine and sort results
 
   % Check if nearest neighbor has angle less than distRatio times 2nd.
   if (vals(1) < distRatio * vals(2))
      matchTable(i) = indx(1);
   else
      matchTable(i) = 0;
   end
end
 
img3 = appendimages(img1,img2);
 
% Show a figure with lines joining the accepted matches.
figure('Position', [100 100 size(img3,2) size(img3,1)]);
colormap('gray');
imagesc(img3);
hold on;
cols1 = size(img1,2);
for i = 1: size(des1,1)
  if (matchTable(i) > 0)
    line([loc1(i,2) loc2(matchTable(i),2)+cols1], ...
         [loc1(i,1) loc2(matchTable(i),1)], 'Color', 'c');
  end
end
hold off;
num = sum(matchTable > 0);
fprintf('Found %d matches.\n', num);
 
idx1 = find(matchTable);
idx2 = matchTable(idx1);
x1 = loc1(idx1,2);
x2 = loc2(idx2,2);
y1 = loc1(idx1,1);
y2 = loc2(idx2,1);
 
matchLoc1 = [x1,y1];
matchLoc2 = [x2,y2];

 

  

 

posted @ 2023-03-18 22:02  我爱C编程  阅读(58)  评论(0编辑  收藏  举报