And now for something more visually comparative.
In the vast landscape of computer vision, the ability to identify and connect corresponding elements between images is a cornerstone of many applications. In this section, we will delve into a method that can discern the hidden connections between images, even when faced with challenges like scale, rotation, and illumination changes.
Feature matching is a fundamental technique in computer vision that involves identifying corresponding points or regions between two or more images. Keypoints from the SIFT are considered features and are thus applicable with feature matching.
The simplest method in SIFT feature matching is brute-force pairing, where each keypoint in the query image is compared to each keypoint in the reference image. This method does so by:
L2 Distance: the Euclidean distance (L2 distance) is calculated between the feature descriptors of the corresponding keypoints.
Nearest Neighbor: the keypoint in the reference image with the smallest L2 distance is considered the best match for the query keypoint.
Best k Pairs: to filter out false matches, the k best pairs (based on L2 distance) are selected.
Another feature matching technique is the ratio test, which filters out incorrect matches and improves the accuracy of the matching process. It is based on the observation that correct matches typically have a significantly smaller distance to their nearest neighbor compared to the distance to their second nearest neighbor.
Compared to brute-force feature matching, the ratio test:
Process: compares the ratio of distance to nearest neighbor and distance to second nearest neighbor, instead of each other image.
Efficiency: is more efficient since it does less work than brute-force, especially for large datasets.
Accuracy: outputs more accurate results by filtering out false matches.
Complexity: involves additional calculations to compute the second nearest neighbot.
This exercise explores the infrastructure of a feature matching algorithm for SIFT outputs. Three separate techniques will be implemented and run sequentially: brute-force matcher using the L2 norm, k-nearest neighbors (KNN) where k equals 2, and ratio test filtering at 75%.
The SIFT function compute() outputs a list of feature descriptors. When combined with detect() to form detectAndCompute(), a list of keypoints and a list of feature descriptors are outputted. To recap, the values in the vector represent the relative weight of each gradient orientation within the cell. A higher value indicates a stronger presence of that orientation.
No more different than how you can run OpenCV transformative functions one by one, a different feature matcher can be executed after the previous matcher.
The output of this SIFT feature matcher is highly accurate, being able to approximately pinpoint the query image's features on the training image. There are little outliers, one of them being the gap between the Bastoncini on the left being paired to the wall edge on the right.
If you want to further improve your feature matching algorithms, consider the following factors that potentially affect its accuracy:
Image Quality: accuracy of SIFT feature matching can be affected by image quality factors such as blur, noise, and occlusion. The images in this example appear to be of relatively good quality, which likely contributes to the reasonable accuracy of the matching.
Scene Complexity: complexity of the scene can also impact matching accuracy. Scenes with many similar objects or repetitive patterns can be more challenging to match.
Parameter Tuning: parameters used in the SIFT algorithm, such as the number of octaves and the contrast threshold, can influence the accuracy of the matching. Fine-tuning these parameters may improve results in certain cases.