2022 T2 Lab 2 Specification
Objective: This lab revisits important concepts covered in the lectures of Week 3 and aims to make you familiar with implementing specific algorithms.
Materials: The sample image as well as template code to be used in the tasks of this lab is available in WebCMS3. You are required to use OpenCV 3+ with Python 3+.
Submission: The tasks are assessable after the lab. Submit your source code as a Jupyter notebook (.ipynb) with output images (.png) in a single zip file by the above deadline. The submission link will be announced in due time.
The sample image Cathedral.png is to be used for all questions.
SIFT: Scale-Invariant Feature Transform
A well-known algorithm in computer vision to detect and describe local features in images is the scale-invariant feature transform (SIFT). Its applications include object recognition, mapping and navigation, image stitching, 3D modelling, object tracking, and others.
A SIFT feature of an image is a salient keypoint with an associated descriptor. SIFT computation is commonly divided into two steps:
1) detection,
2) description.
At the end of the detection step, for each keypoint the SIFT algorithm computes the:
• keypoint spatial coordinates (x, y),
• keypoint scale (in the scale space),
• keypoint dominant orientation.
The subsequent description step computes a distinctive 128-dimensional feature vector for each keypoint. SIFT is designed in such a way that this descriptive feature vector is invariant to scaling and rotation. Moreover, the algorithm offers decent robustness to noise, illumination gradients, and affine transformations.
Task 1 (0.5 mark): Compute the SIFT features of the given image.
a) Extract SIFT features with default parameters and show the keypoints on the image.
b) To achieve better visualization of the keypoints, reduce the number of keypoints. Hint: Vary the parameter contrastThreshold or nfeatures so that the number of keypoints becomes about 10% of all default keypoints.
Submit the images obtained in a) and b) and briefly describe in your Jupyter notebook the approach you used for b).
Task 2 (1 mark): Change the scale of the image and recompute the SIFT features.
a) Enlarge the given image with a scaling factor of 115%.
b) Extract the SIFT features and show the keypoints on the scaled image using the same parameter setting as for Task 1 (for the reduced number of keypoints).
c) Inspect the keypoints visually: Are the keypoints of the scaled image roughly the same as those of the original image? What does this imply?
d) Match the SIFT descriptors of the keypoints of the scaled image with those of the original image using the nearest-neighbour distance ratio method. Show the keypoints of the 5 best-matching descriptors on both the original and the scaled image. Hint: Brute-force matching is available in OpenCV for feature matching.
Submit the images obtained in b) and d) and include in your Jupyter notebook your answers to the questions in c).
Task 3 (1 mark): Rotate the image and recompute the SIFT features.
a) Rotate the given image clockwise by 60 degrees and by 120 degrees.
b) For each rotated image, extract the SIFT features and show the keypoints on the image using the same parameter setting as for Task 1 (for the reduced number of keypoints).
c) For each rotated image, inspect the keypoints visually: Are the keypoints of the rotated image roughly the same as those of the original image? What does this imply?
d) For each rotated image, match the SIFT descriptors of the keypoints with those of the original image using the nearest-neighbour distance ratio method. Show the keypoints of the 5 best-matching descriptors on both the original and the rotated image.
Submit the images obtained in b) and d) and include in your Jupyter notebook your answers to the questions in c).