SURF And SIFT feature extraction

41 visualizaciones (últimos 30 días)
Monika Lokesh
Monika Lokesh el 19 de Mayo de 2021
Respondida: Omega el 10 de Nov. de 2023
How to display the number of features extracted and features matched using surf and sift algorithm?

Respuestas (1)

Omega
Omega el 10 de Nov. de 2023
Hi Monika,
You can use inbuillt functions from MATLAB's "Computer Vision Toolbox" to extract and match features.
  • "detectSURFFeatures" and "detectSIFTFeatures" functions can be used to detect SURF and SIFT features respectively.
  • "extractFeatures" function can be used to extract feature descriptors.
  • "matchFeatures" function can be used to find matching features.
Here's a reference code to extract and match features using the SURF algorithm. Feel free to tweak it as per your need.
% Read the input images
image1 = imread('scene_left.png');
image2=imread('scene_right.png');
% Convert images to grayscale
grayImage1 = rgb2gray(image1);
grayImage2 = rgb2gray(image2);
% Detect SURF features
points1 = detectSURFFeatures(grayImage1);
points2 = detectSURFFeatures(grayImage2);
% Extract SURF features
[features1, validPoints1] = extractFeatures(grayImage1, points1);
[features2, validPoints2] = extractFeatures(grayImage2, points2);
% Display the number of features extracted
numFeatures1 = size(features1, 1);
numFeatures2 = size(features2, 1);
disp(['Number of features extracted from image 1: ', num2str(numFeatures1)]);
Number of features extracted from image 1: 241
disp(['Number of features extracted from image 2: ', num2str(numFeatures2)]);
Number of features extracted from image 2: 238
% Match features between the images
indexPairs = matchFeatures(features1, features2);
% Display the number of features matched
numMatches = size(indexPairs, 1);
disp(['Number of features matched: ', num2str(numMatches)]);
Number of features matched: 187
To know more, you can refer to the following documentation links:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by