FIT5221辅导 、讲解 Python语言编程
            
                FIT5221 - Assignment 1 
There are four tasks in this assignment:
- Harris corner detection (8 marks)
- Homography estimation (2 marks)
- RANSAC (6 marks)
- Image stitching (4 marks)
Available: 14-Mar-2025.
Submission due: 11.55 PM, 9-April-2025.
Instructions:
1. All code should be in Python (>=3.7.x). You should write appropriate comments through the code.
2. For tasks requiring self-implementation, you are only allowed to use Numpy, SciPy, skimage, matplotlib, 
and Python built-in libraries.
3. Late submission penalty: 5% marks per day or part thereof.
4. Submission is to be made only on Moodle.
5. Plagiarism cases will be dealt with following Monash policy.
6. AI & Generative AI tools MUST NOT BE USED within this assessment.
Submission: 
- You need to submit a single zip file containing: 
o A notebook file of the code (named as `StudentName_ID.ipynb`) with inputs and outputs of 
each task presented. You are required to mention your full name and student ID in the notebook 
file. 
o A report file (named as `Report_StudentName_ID.pdf`) where to present your approaches for 
all the tasks. You are required to mention your full name and student ID in the report file. 
o Input and Output images.
- The zip file should be named “A1_.zip” (e.g. A1_12345678.zip). 
- You need to make sure the notebook is runnable, and the results are reproducible given your input images. 
- For each task, the runtime of the code should be less than 5 minutes. 
Image stitching is a technique to combine multiple images with overlapping fields of view to produce a panorama 
photo.
 
=>
2
The panorama stitching algorithm consists of four steps:
Step 1: Detect keypoints (e.g., DoG, Harris) and compute a local descriptor for each keypoint (e.g., SIFT, 
SURF) from the two input images.
Step 2: Match the descriptors between the two images.
Step 3: Use the RANSAC algorithm to estimate a homography matrix using the matches obtained from 
Step 2.
Step 4: Perform image warping using the homography matrix obtained from Step 3 to transform one of 
the two images, then generate the stitched image.
In this assignment, students are required to implement some specific steps of the image stitching process and use 
their implemented code to generate a stitched image as the final output. The details of each task are provided 
below.
Task 1. Harris corner detection (8 marks)
Write your own Harris corner detector.
You will use the 6 images (skimage.data.astronaut(), skimage.data.checkerboard(), and the 4 provided 
images) as input. Write your own Harris corner detector as a function my_harris_corner_detector(…). This 
function should implement all steps in Harris corner detection from scratch and generate the required outputs for 
each input image.
Marking: 
1. my_harris_corner_detector(...) in the notebook template. On running the code, it should generate the 
following items for each input image. Note that the generated items should also be presented in the report. 
(7 marks). 
o On the same input image, display corners detected by your implementation with red ‘+’ markers 
and corners detected by the function corner_peaks(harris_response,…), where harris_response 
= corner_harris(grayscale_input_image, …), with blue ‘o’ markers. The corner_peaks and 
corner_harris functions are from the skimage library. 
o Display the number of corners detected by your implementation and the number of corners 
detected by the function corner_peaks(harris_response, …). Display the number of overlapped 
corners detected by the two methods. 
2. In the report, discuss: How do you decide the parameters? What are your observations? Discuss any 
“interesting” implementation you made. (1 mark).
3. You need to make sure the notebook is runnable, and the results are reproducible given input images.
You are only allowed to use Numpy, SciPy, skimage (only for convolution function, gaussian filter),
matplotlib, and Python built-in libraries in this task. 
Task 2. Homography estimation (2 marks)
Write the code to estimate the homography given matches. 
Given matches in which matched points’ coordination are stored in two arrays 𝑋1 and 𝑋2, which have the same 
size, i.e., 𝑁 × 2, in which 𝑁 is the number of matches (𝑁 ≥ 4). Each row of 𝑋1 is the coordination (𝑥, 𝑦) of a 
point. The 𝑖
𝑡ℎ point of 𝑋1 (i.e., 𝑖
𝑡ℎ
row of 𝑋1) matches to the corresponding point in 𝑋2 (i.e., 𝑖
𝑡ℎ
row in 𝑋2). 
Below is an example of 𝑋1 and 𝑋2. 
3
 𝑋1 = [
2
2
6
6
2
6
6
2
], 𝑋2 = [
16
20
10
8 10
18
12
14 ]
In the above example, the number of matches is 4. Point (2,2) in 𝑋1 matches to point (8,10) in 𝑋2; point (2,6) in 
𝑋1 matches to point (10,14) in 𝑋2 and so on. Note that the number of matches could be greater than or equal to 4. 
Marking:
1. Complete the function my_homography_estimation(X1, X2) in the notebook template to estimate the 
homography 𝐻 that maps points in 𝑋1 to the corresponding points in 𝑋2. Print out the estimated 
homography in the form:
 [
ℎ11 ℎ12 ℎ13
ℎ21 ℎ22 ℎ23
ℎ31 ℎ32 ℎ33
]
2. Note that:
o You are only allowed to use Numpy, SciPy, skimage, matplotlib, and Python built-in libraries 
in this task.
o You are not allowed to use built-in functions that estimate the homography from libraries, but 
you are allowed to use built-in functions that calculate the eigenvalues and eigenvectors or 
perform Singular Value Decomposition of a matrix.
o You need to make sure the notebook is runnable, and the results are reproducible given inputs.
Task 3. RANSAC (6 marks)
Write a program to implement the RANSAC algorithm for estimating a homography matrix (using 
my_homography_estimation (…) implemented in task 2).
Given a list of matching points coordination, which are stored in two arrays 𝑃1 and 𝑃2. 𝑃1 and 𝑃2 have the same 
size, i.e., 𝑁 × 2, in which 𝑁 is the number of matches (𝑁 ≥ 4). Each row of 𝑃1 is coordination (𝑥, 𝑦) of a point. 
The 𝑖
𝑡ℎ point of 𝑋1 (i.e., 𝑖
𝑡ℎ
row of 𝑋1) matches to the corresponding point in 𝑋2 (i.e., 𝑖
𝑡ℎ
row in 𝑋2). 
Marking: 
1. Complete the function my_ransac(P1, P2) and test this function with given input 𝑃1 and 𝑃2 in the 
notebook template to return the best homography H with the largest number of inliers. For each iteration 
in RANSAC, print out the number of inliers, and the number of outliers. Finally print out the best 
transformation matrix H and the coordination of the inlier matches corresponding to that best 
transformation. (5 marks)
2. Write a report describing each step of the RANSAC algorithm you implemented, how to choose inliers 
and outliers. Report the best homography matrix H with the corresponding number of inliers. (1 mark).
3. Note that you are only allowed to use Numpy, SciPy, skimage, matplotlib, and Python built-in libraries 
in this task. You need to make sure the notebook is runnable, and the results are reproducible given 
inputs.
4
Task 4. Image stitching (4 marks)
Given two images as shown in the notebook template, use the functions implemented in Task 1, Task 2, and 
Task 3 to develop an image stitching algorithm following the steps below:
● Step 1: Detect keypoints in both image 1 and image 2 using the Harris corner detection implemented in 
Task 1. (0.5 marks)
● Step 2: Extract local descriptors for the detected keypoints using SIFT (from a library). (1 marks)
● Step 3: Match keypoints between image 1 and image 2 based on the descriptors obtained in Step 2 (use a 
library for matching algorithm) and visualize matches (0.5 marks)
● Step 4: Estimate the homography matrix using the RANSAC algorithm (implemented in Task 3) on the 
list of matching points from Step 3 and visualize the inlier matches corresponding to the best homography 
matrix (0.5 marks)
● Step 5: Apply a warping transformation (from a library) using the homography matrix obtained in Step 
4 to transform image 2. (0.5 marks)
● Step 6: Merge image 1 and the transformed image 2 from Step 5 to obtain the final stitched image. (1
mark)
Marking:
1. You must complete and display the output of each step (with suitable parameters) for each pair of input 
images.
2. If a step requires using a self-implemented function (e.g., steps 1 and 4), you will not receive marks if 
you substitute it with a library function. However, you will still get marks for other steps that rely on the 
results of those implementations. For example, if you use a library function for Harris corner detection, 
you will not receive marks for step 1; however, as long as the keypoint locations are obtained using the 
Harris corner detector, you can still earn marks for the subsequent steps. The objective of Task 4 is to 
implement Image Stitching.
3. Note that there is no restriction on the libraries you can use for this task. You need to make sure the 
notebook is runnable, and the results are reproducible given inputs.
Here is an example of output in each step, note that the outputs of your implementation may differ from the 
example provided below:
Example 1:
5
6
Example 2:
7
================== End ==================