SURF And SIFT feature extraction

조회 수: 44 (최근 30일)
Monika Lokesh
Monika Lokesh 2021년 5월 19일
답변: Omega 2023년 11월 10일
How to display the number of features extracted and features matched using surf and sift algorithm?

답변 (1개)

Omega
Omega 2023년 11월 10일
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