Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
COMP9517: Computer Vision
Assignment Specification
Maximum Marks Achievable: 10
This assignment is worth 10% of the total course marks.
Deliverables: You must submit the following items:
1. A report explaining the approach you have taken in Tasks 1, 2, and 3. The report can be
written in Word, LaTeX, or a similar text processor, but must be submitted as a PDF and
include your name and zID on the first page. It must also show the sample input images
and the intermediate and final output images obtained. No templates are provided, but
the report must be no more than 5 pages (A4), and must be single column, use 11 points
Times New Roman or similar font, and have 2.5 cm margins.
2. Source code and results in the form of a Jupyter notebook (.ipynb) including all output
(see coding requirements below).
Submission: Submit all deliverables in a single zip-file. Instructions for submission will be
posted closer to the deadline. To avoid confusion for the tutor/marker, who may handle
many submissions, put your zID in all file names (e.g. zID_Report.pdf for the report and
zID_Notebook.ipynb for the notebook).
Software: You are required to use OpenCV 3+ with Python 3+ and submit your code as a
Jupyter notebook (see deliverables above and coding requirements below).
Objectives: This assignment is to familiarise you with basic image processing methods. It also
introduces you to common image processing and analysis tasks using OpenCV.
Learning Outcomes: After completing this assignment, you will have learned how to:
1. Open and read image files.
2. Display and write image files.
3. Perform mathematical operations on images.
4. Apply basic image filtering operations.
The assignment files should be submitted online.
Instructions for submission will be posted closer to the deadline.
Deadline for submission is Week 4, Thursday 6 October 2022, 13:00:00.
5. Perform image adjustment and restoration.
Description: Many computer vision applications use image processing techniques to
suppress artifacts and enhance relevant features to prepare images for quantitative analysis.
The goal of this assignment is to write image processing code that can open a digital image,
perform a sequence of pixel manipulation operations (step-by-step as listed under Tasks
below), in order to remove background shading.
Below is an image (on the left) from an astronomy project where the goal is to count and
measure the stars. However, these measurements are impeded by the haze of the Milkyway
in the background. Thus, the shading needs to be removed (as on the right).
Tasks: This assignment consists of three tasks, described below. Each task depends on the
previous one, so you need to do them in the given order.
Task 1 (4 marks): Background Estimation
Open the given image Stars.png. Like the example shown above, it has background shading
patterns that need to be removed. The first step to get rid of the shading is to make an
accurate estimate of the background of the image.
Write an algorithm that performs the following two steps:
1. Create a new image, which we will call image , having the same size (number of pixel
rows and columns) as the input image, which we call image .
2. Go through the pixels of image one by one, and for each pixel (,) find the minimum
gray value in a neighbourhood (see below) centred around that pixel, and then write
that minimum value in the corresponding pixel location (, ) in .
The resulting image is called the min-filtered image of input image .
The neighbourhood is a square of size × pixels, where is a free parameter of the
algorithm and typically has an odd value (3, 5, 7, …), with the pixel (,) under consideration
being the centre pixel. Manually try different values of and mention in your report what is
the smallest value of that causes the stars in to visually disappear altogether in image .
Also explain why this value of , and not smaller values, causes the stars to disappear, and
what is the effect of taking larger values than this smallest value.
The min-filtering causes the gray values in to be smaller than the actual background values
in , so a correction is needed. Extend your algorithm with two more steps:
3. Create another new image, which we call image here, of the same size as and .
4. Go through the pixels of one by one, and for each pixel (,) find the maximum gray
value in a neighbourhood of the same size ( × pixels) centred around that pixel, and
then write that maximum gray value to (,) in .
The resulting image is called the max-filtered image of the image .
In your report, include image computed from Stars.png.
Task 2 (1 mark): Background Subtraction
Now that your algorithm can estimate the background of an image , removing the
shading artifacts from can be done simply by subtracting from pixel by pixel, resulting
in the output image . Extend your algorithm to perform this subtraction.
In your report, include image computed from Stars.png.
Task 3 (5 marks): Algorithm Extensions
Open the given image Nuclei.png. It is a microscopy image showing many cell nuclei (the
dark blobs). Like Stars.png, the image has a background shading pattern (also dark) that
needs to be removed. There are three main differences between the two images:
• The sizes of the images are different.
• The sizes of the objects (stars versus cell nuclei) in the images are different.
• The objects in Nuclei.png are dark and the background is bright (except for the dark
shading pattern), whereas in Stars.png the objects are bright and the background is dark
(except for the bright shading patterns).
Further extend your algorithm as follows:
5. Ensure your algorithm can deal with input images of arbitrary size. This is a matter of
retrieving the number of rows and columns in the beginning of your code and using
and as the limits in the loops when going over the pixels.
6. Put the neighbourhood size parameter at the beginning of your code so that users can
easily find it and adjust the value as needed.
7. Add a parameter (or rather a flag) at the beginning of your code which determines
the order of the min-filtering and max-filtering operations. Specifically:
* If the user sets = 0, the algorithm should first perform min-filtering (image to ),
then max-filtering (image to ), and then pixelwise subtraction ( = − ).
* If the user sets = 1, the algorithm should first perform max-filtering (image to
), then min-filtering (image to ), and then pixelwise subtraction ( = − + 255).
In your report, explain why you must use the = 0 (and not = 1) variant of your
algorithm to make it work for Stars.png, and conversely why you must use the = 1 (and
not = 0) variant to make it work for Nuclei.png. Also explain why the = 1 variant
requires adding 255 (for 8-bit images) to each subtracted pixel value in image (see above).
Furthermore, mention what is a good value of for Nuclei.png and why. And include images
and computed from Nuclei.png in your report.
Coding Requirements
For all three tasks, implement the required algorithms yourself, and do not use existing
library functions (from OpenCV or any other packages) for these tasks. Using these functions
instead of your own implementation will result in deduction of points.
Specifically, you should implement the following operations yourself using plain Python code
without relying on existing functions that perform (part of) these operations directly:
• Minimum filtering and maximum filtering (write your own loops over the pixels).
• Add or subtract images or values to/from images pixelwise (write your own loops).
For other operations you may use existing library functions.
In future labs and in the group project you may use existing library functions, but in this
assignment (like in the first lab) the goal is to learn how basic image processing operations
work at the pixel level and get experience implementing them yourself. Of course, you may
use existing functions to verify the results of your own implementations.
For this assignment (same as for the labs), make sure that in your Jupyter notebook the
input images are readable from the location specified as an argument, and all output images
and other requested results are displayed in the notebook environment. All cells in your
notebook should have been executed so that the tutor/marker does not have to execute the
notebook again to see the results.
Copyright: UNSW CSE COMP9517 Team. Reproducing, publishing, posting, distributing, or
translating this assignment is an infringement of copyright and will be referred to UNSW
Student Conduct and Integrity for action.