Description
Assignment
- Design a C (or C++) program that detects keypoints from an image and compare two images based on SIFT descriptors.
- The assignment can be completed by either individuals or a group of two students.
Task
Recent research has revealed that keypoint-based descriptors are effective to characterize both individual objects and entire images. Such descriptors are widely used in object detection and image comparison. In this assignment, you are required to develop a program in C/C++ using OpenCV 3.4.1 to detect and display keypoints from an image and to compare two images based on SIFT descriptors.
The program should be able to take one or multiple image files. When a single image file, e.g. A.jpg, is supplied to the program, it should
- Rescale the image to a size comparable to VGA size (480(rows) x 600(columns)) to reduce the computation. Note that the aspect ratio of the image should be kept when the image is rescaled.
- Extract SIFT keypoints from the Y component of the image
- For each detected keypoint, draw a cross “+” at the location of the key point and a circle around the keypoint whose radius is proportional to the scale of the keypoint.
- Both the original image and the image with highlighted keypoints should be displayed in a window as follow
| Original Image (rescaled) | Image with highlighted keypoints |
- In the command window, the program should output the number of detected keypoints, e.g.
# of keypoints in A.jpg is 3180
When multiple image files, say A.jpg, B.jpg, C.jpg, D.jpg and E.jpg, are supplied to the program as commend auguments, the program will compare each pair of the images using a Bag-of-Words model constructed from SIFT descriptors. Specifically, the program shall
- Rescale all images to sizes comparable to VGA size (480×600) to reduce the computation. Note that the aspect ratio of the images should be kept when the image is rescaled, but there is no need to rescale all images to the same size.
- Extract SIFT keypoints and descriptors from the Y-components of all scaled images.
- Cluster the SIFT descriptors from ALL images into K-clusters using K-means algorithm. The values of K should be specified as a percentage of the total number of keypoints. Each cluster represents a visual word.
- For each image, construct a histogram of the occurrence of the visual words. This should be done by classifying each SIFT descriptor of the image into one of the K-clusters (words) and continuing how many time each word occurred in the image.
- For each pair of images, calculate the 2 distance between the histograms of the images. This 2 distance is a measurement of the dissimilarity of the pair of images.
- The program should output the following information
- Number of keypoints for each image and the total number of keypoints of all images, e.g.
# of keypoints in A.jpg is 2138
# of keypoints in B.jpg is 923
# of keypoints in A.jpg is 780
# of keypoints in B.jpg is 1300
# of keypoints in A.jpg is 1578
- Dissimilarity matrices for K=5%, 10% and 20% of the total number of keypoints from all images. Note: please arrange the dissimilarity matrices in a readable format, e.g.
K=5%*(total number of keypoionts)=250
Dissimilarity Matrix
A B C D E
- 0 0.01 0.9
- 0
- 0
- 0 0.85
- 0
K=10%*(total number of keypoionts)=500
Dissimilarity Matrix
A B C D E
- 0 0.01 0.9
- 0
- 0
- 0 0.85
- 0
K=20%*(total number of keypoionts)=1000
Dissimilarity Matrix
A B C D E
- 0 0.01 0.9
- 0
- 0
- 0 0.85
- 0
However, the program neither needs to display the original images nor the images with highlighted keypoints in this case.
Fifteen images covering different scenarios are provided for testing your program.
Requirements on coding
- The program should be named as “siftImages” and shall take one or multiple image files as input, e.g. siftImages imagefile1 [, imagefile2, imagefile3,…].
- No other third-party libraries should be used in the program except OpenCV 3.4.1. The code has to be in C/C++.
- The code should be modularized with detail comments AND all source code should be placed in a single file “cpp” or “siftImages.c”.



