487/819– Computer Vision and Image Processing Assignment 2 solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

2 Background
The purpose of this assignment is to gain some experience with low-level image features such as edges
and blobs while looking at some interesting applications of those features.
2.1 Assignment Synposis
In Question 1 you’ll use implement the vector gradient algorithm for edge detection in colour images
and use it to develop a measure of image sharpness that can be used to quantify how much an image
has been blurred. In question 2 you’ll practice using the blob detection functions in skimage to solve an
area-of-interest detection problem, and provide a qualitative analysis of the performance.
2.2 Implementing the Vector Gradient
To implement the vector gradient we need to use the equations in Lecture Topic 5. They are repeated here.
First the definitions of gxx, gyy and gxy.
gxx = u · u = u
Tu =

∂R
∂x
2
+

∂G
∂x
2
+

∂B
∂x
2
gyy = v · v = v
Tv =

∂R
∂y
2
+

∂G
∂y
2
+

∂B
∂y
2
gxy = u · v = u
Tv =
∂R
∂x
∂R
∂y
+
∂G
∂x
∂G
∂y
+
∂B
∂x
∂B
∂y
These will manifest themselves in your solution as 2D arrays that are the same size as the input image.
The first step is to compute the horizontal and vertical partial derivatives of the red, green and blue
channels. This is straightforward and can be done by applying the Sobel operators to each colour image
channel. If you then stack the three horizontal filtering results back into an N × M × 3 array (N and M
are the image height and width), the result is u. Do the same for the vertical partial derivatives and you
get v.
gxx is the dot product of u with itself. If you construct u as described above, you can get gxx using the
provided function color_dot_product(). gyy and gxy can be computed similarly.
Once you have gxx, gyy and gxy, in the form of N × M arrays, computation of the gradient direction
and magnitude are as follows:
θ(x, y) = 1
2
tan−1

2gxy
gxx − gyy 
Fθ (x, y) = 
1
2
[(gxx + gyy) + (gxx − gyy) cos(2θ(x, y)) + 2gxy sin(2θ(x, y))]1
2
These can be computed straightforwardly for all pixels at once by using numpy and performing each
mathematical operation on the entire array, avoiding expensive loops. The results will again be 2D arrays
which are the image’s gradient magnitude image and gradient direction image. Note that the direction
image is needed to compute the magnitude image.
2.3 The Kurtosis-based Sharpness Measure
In question 1 we’ll be using a measure of image sharpness based on kurtosis. Kurtosis is a numeric
property of a group of numbers, much like mean or standard deviation.
Given a gradient magnitude image, we can treat each gradient magnitude value in the image as one
sample in a set of samples. The kurtosis of that set of samples is related to image sharpness (i.e. lack of
blurriness). The kurtosis of a set of samples is calculated from statistical moments. The mean of a set of
samples is the first central moment; the standard deviation is the second central moment. The kurtosis is
the fourth central moment divided by the second central moment (standard deviation) minus 3. It turns
out that
sharpness = log(K + 3)
where K is the kurtosis of an image’s set of gradient magnitudes is a reasonable measure of sharpness (the
+3 is to offset the −3 in the definition of kurtosis so we aren’t taking logarithms of negative numbers).
You can compute the kurtosis of a set of samples using the scipy.stats.kurtosis() function (requires
importing the scipy.stats module). To compute a measure of how blurry an image is, you can’t quite
just pass the entire gradient magnitude image to scipy.stats.kurtosis(). The function expects a onedimensional array, so you have to use the numpy.reshape() function to rearrange the gradient magnitude
image into a one-dimensional array of length MN rather than a 2D array with N rows and M columns.
Then you can pass the 1D array to the scipy.stats.kurtosis() function to obtain K. Once you have that,
just add 3 and take the logarithm. And that’s our sharpness measure.
Page 2
3 Problems
Question 1 (32 points):
Detailed instructions are provided asn2-q1.ipynb. Sample outputs are given below.
0 5 10 15 20 25 30
Gaussian blur sigma
1.0
1.5
2.0
2.5
3.0
3.5
4.0
Sharpness (kurtosis)
Kurtosis sharpness measure of mushroom.jpg for increasing blur.
Sample Output for Step 2
0 2 4 6 8
0
1
2
3
4
5
6
7 1.0
1.5
2.0
2.5
3.0
3.5
4.0
Sample Output for Step 3
Page 3
0 5 10 15 20 25 30
Gaussian blur sigma
1.3
1.4
1.5
1.6
1.7
1.8
1.9
Sharpness (kurtosis)
Kurtosis sharpness measure of waterfall.jpg for increasing blur.
0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5
0
2
4
6
8
10
12
14
2
3
4
5
6
Sample Output for Step 4
Page 4
Question 2 (11 points):
Detailed instructions are provided in asn2-q2.ipynb. Sample output is given below.
0 250 500 750 1000 1250 1500 1750 2000
0
100
200
300
400
500
600
700
800
The grading rubric can be found on Moodle.
Ackonwledgement
Thanks to Dr. Kirstin Bett, University of Saskatchewan for providing the lentil field image. Used and
distributed with permission.
Page 5
4 Files Provided
asn2-qX.ipynb: These are iPython notebooks, one for each question, which includes instructions and in
which you will do your assignment.
5 What to Hand In
Hand in your completed iPython notebooks, one for each question.
Page 6