基于 SIFT 对图像进行局部特征匹配(Matlab代码实现)

简介: 基于 SIFT 对图像进行局部特征匹配(Matlab代码实现)

💥1 概述

为了提高特征点匹配的准确率,提出了一种基于改进混合滤波、特征描述符降维、SIFT特征匹配、RANSAC剔除误匹配点以及PSO算法的特征点匹配。首先将场景图像进行滤波处理达到去噪效果,然后通过特征描述符降维以减少计算量,再通过RANSAC对基于SIFT的特征点匹配进行误匹配的剔除,最后使用PSO算法进行优化以寻找到最佳的Ratio值。通过在模糊、较暗、较亮和遮挡4种以机械手为背景的场景下的图像,进行4种算法的对比实验,最后表明SIFT特征匹配算法的误匹配率最小,精确度最高。在本文章中,我们实现了哈里斯角检测器来获取与角像素相对应的兴趣点。设计用于检测图像多个比例的角落。实现了 SIFT 算法,用于获取之前找到的角点的局部特征描述符。每个角点都使用其周围图像块的梯度直方图(HoG)进行描述。使用最近距离匹配实现特征匹配,并使用 k-d 树实现 KNN 搜索。


📚2 运行结果

部分代码:

% Local Feature Stencil Code
% CS 4476 / 6476: Computer Vision, Georgia Tech
% Written by James Hays
% This script 
% (1) Loads and resizes images
% (2) Finds interest points in those images                 (you code this)
% (3) Describes each interest point with a local feature    (you code this)
% (4) Finds matching features                               (you code this)
% (5) Visualizes the matches
% (6) Evaluates the matches based on ground truth correspondences
tic
close all
%% 1) Load stuff
% There are numerous other image sets in the supplementary data on the
% project web page. You can simply download images off the Internet, as
% well. However, the evaluation function at the bottom of this script will
% only work for three particular image pairs (unless you add ground truth
% annotations for other image pairs). It is suggested that you only work
% with the two Notre Dame images until you are satisfied with your
% implementation and ready to test on additional images. A single scale
% pipeline works fine for these two images (and will give you full credit
% for this project), but you will need local features at multiple scales to
% handle harder cases.
  image1 = imread('../data/Notre Dame/921919841_a30df938f2_o.jpg');
  image2 = imread('../data/Notre Dame/4191453057_c86028ce1f_o.jpg');
  eval_file = '../data/Notre Dame/921919841_a30df938f2_o_to_4191453057_c86028ce1f_o.mat';
 %image1 = imread('../data/agra_fort.jpg');
 %image2 = imresize(image1,0.5);
% %This pair is relatively easy (still harder than Notre Dame, though)
% image1 = imread('../data/Mount Rushmore/9021235130_7c2acd9554_o.jpg');
% image2 = imread('../data/Mount Rushmore/9318872612_a255c874fb_o.jpg');
% eval_file = '../data/Mount Rushmore/9021235130_7c2acd9554_o_to_9318872612_a255c874fb_o.mat';
%This pair is relatively difficult
% image1 = imread('../data/Episcopal Gaudi/4386465943_8cf9776378_o.jpg');
% image2 = imread('../data/Episcopal Gaudi/3743214471_1b5bbfda98_o.jpg');
% eval_file = '../data/Episcopal Gaudi/4386465943_8cf9776378_o_to_3743214471_1b5bbfda98_o.mat';
image1 = single(image1)/255;
image2 = single(image2)/255;
%make images smaller to speed up the algorithm. This parameter gets passed
%into the evaluation code so don't resize the images except by changing
%this parameter.
scale_factor = 0.5; 
image1 = imresize(image1, scale_factor, 'bilinear');
image2 = imresize(image2, scale_factor, 'bilinear');
% You don't have to work with grayscale images. Matching with color
% information might be helpful.
image1_bw = rgb2gray(image1);
image2_bw = rgb2gray(image2);
feature_width = 16; %width and height of each local feature, in pixels. 
toc 
%% 2) Find distinctive points in each image. Szeliski 4.1.1
% !!! You will need to implement get_interest_points. !!!
% Harris Corner Detection
% [x1, y1] = get_interest_points(image1_bw, feature_width, 1);
% [x2, y2] = get_interest_points(image2_bw, feature_width, 1);
% % Adaptive non-maximal detection
% [x1, y1] = get_interest_points_anms(image1_bw, feature_width);
% toc
% [x2, y2] = get_interest_points_anms(image2_bw, feature_width);
% % Scaling with harris corner detection
[x1, y1, confidence1, scale1] = get_interest_points_scaling(image1_bw, feature_width);
[x2, y2, confidence2, scale2] = get_interest_points_scaling(image2_bw, feature_width);
toc
%show_correspondence(image1, image2, x1, y1, x2, y2);
% % Use cheat_interest_points only for development and debugging!
% [x1, y1, x2, y2] = cheat_interest_points(eval_file, scale_factor);
%show_correspondence(image1, image2, x1, y1, x2, y2);
%% 3) Create feature vectors at each interest point. Szeliski 4.1.2
% !!! You will need to implement get_features. !!!
% SIFT
% [image1_features] = get_features(image1_bw, x1, y1, feature_width);
% [image2_features] = get_features(image2_bw, x2, y2, feature_width);
% SIFT with scaling
[image1_features] = get_features_scaling(image1_bw, x1, y1, feature_width, scale1);
[image2_features] = get_features_scaling(image2_bw, x2, y2, feature_width, scale2);
toc
%% 4) Match features. Szeliski 4.1.3
% !!! You will need to implement get_features. !!!
% % Exhaustive search
 [matches, confidences] = match_features(image1_features, image2_features);
% % Knnsearch with kdTree
%[matches, confidences] = match_features_knnsearch(image1_features, image2_features);
%matches = matchFeatures(feat1, feat2);
toc
%% 5) Visualization
% You might want to set 'num_pts_to_visualize' and 'num_pts_to_evaluate' to
% some constant (e.g. 100) once you start detecting hundreds of interest
% points, otherwise things might get too cluttered. You could also
% threshold based on confidence.
% There are two visualization functions. You can comment out one of both of
% them if you prefer.
num_pts_to_visualize = size(matches,1);
show_correspondence(image1, image2, x1(matches(1:num_pts_to_visualize,1)), ...
                                    y1(matches(1:num_pts_to_visualize,1)), ...
                                    x2(matches(1:num_pts_to_visualize,2)), ...
                                    y2(matches(1:num_pts_to_visualize,2)));
show_correspondence2(image1, image2, x1(matches(1:num_pts_to_visualize,1)), ...
                                     y1(matches(1:num_pts_to_visualize,1)), ...
                                     x2(matches(1:num_pts_to_visualize,2)), ...
                                     y2(matches(1:num_pts_to_visualize,2)));
%% 6) Evaluation
% This evaluation function will only work for the Notre Dame, Episcopal
% Gaudi, and Mount Rushmore image pairs. Comment out this function if you
% are not testing on those image pairs. Only those pairs have ground truth
% available. You can use collect_ground_truth_corr.m to build the ground
% truth for other image pairs if you want, but it's very tedious. It would
% be a great service to the class for future years, though!
num_pts_to_evaluate = size(matches,1);
good_matches = evaluate_correspondence(image1, image2, eval_file, scale_factor, ... 
                        x1(matches(1:num_pts_to_evaluate,1)), ...
                        y1(matches(1:num_pts_to_evaluate,1)), ...
                        x2(matches(1:num_pts_to_evaluate,2)), ...
                        y2(matches(1:num_pts_to_evaluate,2)));


🎉3 参考文献

部分理论来源于网络,如有侵权请联系删除。

[1]林曦蕾.图像局部特征匹配算法发展综述[J].现代计算机(专业版),2019(09):89-93.

[2]徐澳,华云松,夏春蕾.,陈诗雨.一种基于SIFT的改进特征点匹配算法[J].软件,2022,43(09):83-86+119.

🌈4 Matlab代码实现

相关文章
|
5天前
|
算法 数据安全/隐私保护 计算机视觉
基于FPGA的图像双线性插值算法verilog实现,包括tb测试文件和MATLAB辅助验证
本项目展示了256×256图像通过双线性插值放大至512×512的效果,无水印展示。使用Matlab 2022a和Vivado 2019.2开发,提供完整代码及详细中文注释、操作视频。核心程序实现图像缩放,并在Matlab中验证效果。双线性插值算法通过FPGA高效实现图像缩放,确保质量。
|
1月前
|
算法 数据安全/隐私保护 计算机视觉
基于Retinex算法的图像去雾matlab仿真
本项目展示了基于Retinex算法的图像去雾技术。完整程序运行效果无水印,使用Matlab2022a开发。核心代码包含详细中文注释和操作步骤视频。Retinex理论由Edwin Land提出,旨在分离图像的光照和反射分量,增强图像对比度、颜色和细节,尤其在雾天条件下表现优异,有效解决图像去雾问题。
|
1月前
|
算法 人机交互 数据安全/隐私保护
基于图像形态学处理和凸包分析法的指尖检测matlab仿真
本项目基于Matlab2022a实现手势识别中的指尖检测算法。测试样本展示无水印运行效果,完整代码含中文注释及操作视频。算法通过图像形态学处理和凸包检测(如Graham扫描法)来确定指尖位置,但对背景复杂度敏感,需调整参数PARA1和PARA2以优化不同手型的检测精度。
|
1月前
|
移动开发 算法 计算机视觉
基于分块贝叶斯非局部均值优化(OBNLM)的图像去噪算法matlab仿真
本项目基于分块贝叶斯非局部均值优化(OBNLM)算法实现图像去噪,使用MATLAB2022A进行仿真。通过调整块大小和窗口大小等参数,研究其对去噪效果的影响。OBNLM结合了经典NLM算法与贝叶斯统计理论,利用块匹配和概率模型优化相似块的加权融合,提高去噪效率和保真度。实验展示了不同参数设置下的去噪结果,验证了算法的有效性。
|
6月前
|
安全
【2023高教社杯】D题 圈养湖羊的空间利用率 问题分析、数学模型及MATLAB代码
本文介绍了2023年高教社杯数学建模竞赛D题的圈养湖羊空间利用率问题,包括问题分析、数学模型建立和MATLAB代码实现,旨在优化养殖场的生产计划和空间利用效率。
272 6
【2023高教社杯】D题 圈养湖羊的空间利用率 问题分析、数学模型及MATLAB代码
|
4月前
|
算法 数据安全/隐私保护
织物图像的配准和拼接算法的MATLAB仿真,对比SIFT,SURF以及KAZE
本项目展示了织物瑕疵检测中的图像拼接技术,使用SIFT、SURF和KAZE三种算法。通过MATLAB2022a实现图像匹配、配准和拼接,最终检测并分类织物瑕疵。SIFT算法在不同尺度和旋转下保持不变性;SURF算法提高速度并保持鲁棒性;KAZE算法使用非线性扩散滤波器构建尺度空间,提供更先进的特征描述。展示视频无水印,代码含注释及操作步骤。
|
5月前
|
算法 数据可视化 数据安全/隐私保护
基于LK光流提取算法的图像序列晃动程度计算matlab仿真
该算法基于Lucas-Kanade光流方法,用于计算图像序列的晃动程度。通过计算相邻帧间的光流场并定义晃动程度指标(如RMS),可量化图像晃动。此版本适用于Matlab 2022a,提供详细中文注释与操作视频。完整代码无水印。
|
6月前
|
数据采集 存储 移动开发
【2023五一杯数学建模】 B题 快递需求分析问题 建模方案及MATLAB实现代码
本文介绍了2023年五一杯数学建模竞赛B题的解题方法,详细阐述了如何通过数学建模和MATLAB编程来分析快递需求、预测运输数量、优化运输成本,并估计固定和非固定需求,提供了完整的建模方案和代码实现。
139 0
【2023五一杯数学建模】 B题 快递需求分析问题 建模方案及MATLAB实现代码
|
6月前
|
存储 算法 搜索推荐
【2022年华为杯数学建模】B题 方形件组批优化问题 方案及MATLAB代码实现
本文提供了2022年华为杯数学建模竞赛B题的详细方案和MATLAB代码实现,包括方形件组批优化问题和排样优化问题,以及相关数学模型的建立和求解方法。
162 3
【2022年华为杯数学建模】B题 方形件组批优化问题 方案及MATLAB代码实现
|
9月前
|
数据安全/隐私保护
耐震时程曲线,matlab代码,自定义反应谱与地震波,优化源代码,地震波耐震时程曲线
地震波格式转换、时程转换、峰值调整、规范反应谱、计算反应谱、计算持时、生成人工波、时频域转换、数据滤波、基线校正、Arias截波、傅里叶变换、耐震时程曲线、脉冲波合成与提取、三联反应谱、地震动参数、延性反应谱、地震波缩尺、功率谱密度

热门文章

最新文章