Created and recorded by Yiming Cai, October 2021
Music: Usina (https://lmms.io/lsp/?action=show&file...) by Yure16 (https://lmms.io/lsp/?action=browse&us...) License: Creative Commons
Outline
Introduce Feature Matching
Sample pictures
How to match features in Matlab
In this video, I would like to talk about feature matching. Feature matching a very useful skill in graphic processing. Suppose we have several images of the same place taken from different angles, feature matching can help us find common features in the images very quickly. Whether the photo is zoomed in or out, or is a photo taken after another photo is translated or rotated, feature matching can help us quickly locate the obvious features associated between the pictures and connect them.
Script
Before matching features, find features from images will be the first step. There are multiple algorithms for feature detection. In this video, I will use the Harris algorithm for feature detecting.
So let's import our files. To make sure the feature matching works, it's important to make sure two images contain the same features. Meaning they are images for the same object from different directions. After reading images, let's find the corner
Find the corners.
points1 = detectHarrisFeatures(I1);
points2 = detectHarrisFeatures(I2);
Extract the neighborhood features.
[features1,valid_points1] = extractFeatures(I1,points1);
[features2,valid_points2] = extractFeatures(I2,points2);
Match the features.
indexPairs = matchFeatures(features1,features2);
Retrieve the locations of the corresponding points for each image.
matchedPoints1 = valid_points1(indexPairs(:,1),:);
matchedPoints2 = valid_points2(indexPairs(:,2),:);
Visualize the corresponding points. You can see the effect of translation between the two images despite several erroneous matches.
figure;
showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2);
By using the built-in Matlab functions, it's very easy to find features inside two images. The idea of Harris corner detection is detecting sudden changes such as angles within a range of small sections of pixels. Also, Matlab offers an option called detectSURFFeatures.
In this video, we went through how to use built-in Matlab feature detecting functions for feature matching. After locating matching points, it won’t be difficult to stitch two images together as a larger image. With this skill, we can combine two images into a larger view. Hope this video is helpful.