Docsity

Computer Vision Assignment, Assignments of Computer Vision

Toggle sidebar
bg1
Homework 2
Due by 03-04-2020 (11:59 PM)
Q.1. [8+7=15]
a) Write a MATLAB function โ€˜my2DConvolutionโ€™ for convolving a given grayscale image I with
a 2D convolution mask M. Your function should take care of the image boundary by mirroring the
image content appropriately. You cannot use the built in MATLAB functions like conv or conv2.
b) Convolve the given image using your function above with a 3x3 Gaussian mask.
Q.2. [5+5+5=15]
You can blur an image using a filter โ€˜Bโ€™ and find ๐‘”๐‘ฆof an image using the filter โ€˜Gโ€™, where โ€˜Bโ€™ and
โ€˜Gโ€™ are given as follows:
B = [1/4 1/4
1/4 1/4]
G = [โˆ’1 1
โˆ’1 1]
a) Are the above operations linear? If so, why?
b) You are asked to apply B to an image to generate a blurred image and then apply G to the
result to find the gradient of the blurred image. How would the output change if you apply G
first and then B?
c) If you are asked to apply one single filter S, instead of two filters in succession, how would
you find S?
Q.3. [5+5+5=15]
a) Write a function โ€˜my2DGaussian(S)โ€™ to generate a 2D symmetric Gaussian blurring mask of a
given size โ€˜Sโ€™. You should appropriately normalize the mask before returning it to the user.
b) Using the function in Q.1. (a) and the filter in Q.3.(a) above, convolve the given image
โ€˜pattern.tifโ€™ with the following mask sizes: 9ร—9, 11ร—11, and 13ร—13. Display the original
image and all the blurred images in juxtaposition.
c) Give your analysis of the results in (b).
Q.4. [5+5+5+5+5=25]
a) Refer to figure 3.10(a) in your book. Using the coordinates (๐‘Ÿ1,๐‘ 1) = (100,50) and (๐‘Ÿ2,๐‘ 2) =
(200,230), give expression for the piecewise linear transform ๐‘‡(๐‘Ÿ) to stretch the contrast of a
given grayscale image.
b) Write a MATLAB script to adjust contrast of the given image โ€˜pollen.pngโ€™ using the above
transformation.
c) Now use (๐‘Ÿ1,๐‘ 1) = (๐‘Ÿ๐‘š๐‘–๐‘›,0) and (๐‘Ÿ2,๐‘ 2) = (๐‘Ÿ๐‘š๐‘Ž๐‘ฅ,255) to stretch contrast of the image.
d) Lastly, use histogram equalization to reset the contrast.
e) Show the results, i.e. the original image and the three contrast adjusted images in juxtaposition
and comment on your results.
pf2

Partial preview of the text

Download Computer Vision Assignment and more Assignments Computer Vision in PDF only on Docsity!

Homework 2

Due by 03-04-2020 ( 11 :59 PM)

Q.1. [8+7=15]

a) Write a MATLAB function โ€˜my2DConvolutionโ€™ for convolving a given grayscale image I with

a 2D convolution mask M. Your function should take care of the image boundary by mirroring the

image content appropriately. You cannot use the built in MATLAB functions like conv or conv2.

b) Convolve the given image using your function above with a 3x3 Gaussian mask.

Q.2. [5+5+5=15]

You can blur an image using a filter โ€˜Bโ€™ and find ๐‘”

๐‘ฆ

of an image using the filter โ€˜Gโ€™, where โ€˜Bโ€™ and

โ€˜Gโ€™ are given as follows:

B = [

]

G = [

]

a) Are the above operations linear? If so, why?

b) You are asked to apply B to an image to generate a blurred image and then apply G to the

result to find the gradient of the blurred image. How would the output change if you apply G

first and then B?

c) If you are asked to apply one single filter S, instead of two filters in succession, how would

you find S?

Q.3. [5+5+5=15]

a) Write a function โ€˜my2DGaussian(S)โ€™ to generate a 2D symmetric Gaussian blurring mask of a

given size โ€˜Sโ€™. You should appropriately normalize the mask before returning it to the user.

b) Using the function in Q.1. (a) and the filter in Q.3.(a) above, convolve the given image

โ€˜pattern.tifโ€™ with the following mask sizes: 9 ร— 9 , 11 ร— 11 , and 13 ร— 13. Display the original

image and all the blurred images in juxtaposition.

c) Give your analysis of the results in (b).

Q.4. [5+5+5+5+5= 2 5]

a) Refer to figure 3.10(a) in your book. Using the coordinates (๐‘Ÿ

1

1

) = ( 100 , 50 ) and (๐‘Ÿ

2

2

( 200 , 230 ), give expression for the piecewise linear transform ๐‘‡(๐‘Ÿ) to stretch the contrast of a

given grayscale image.

b) Write a MATLAB script to adjust contrast of the given image โ€˜pollen.pngโ€™ using the above

transformation.

c) Now use (๐‘Ÿ 1

1

๐‘š๐‘–๐‘›

, 0 ) and (๐‘Ÿ

2

2

๐‘š๐‘Ž๐‘ฅ

, 255 ) to stretch contrast of the image.

d) Lastly, use histogram equalization to reset the contrast.

e) Show the results, i.e. the original image and the three contrast adjusted images in juxtaposition

and comment on your results.

Q.5. [5+ 5 +2+3=1 5 ]

a) Write a MATLAB function โ€˜showImageBitPlanes()โ€™ that would take an 8 - bit grayscale image

along with the optional argument to show some specific bit-planes of the given image. If no

argument is specified, the function should return all bit-planes. Note: You are required to write

transformation relations of the bit-planes using the sample template โ€˜templateBitPlanes.mโ€™.

b) Using only the two and four most significant bit-planes respectively, reconstruct the given

image โ€˜dollar.tifโ€™ and save it as โ€˜reconstructedDollar 2 .tifโ€™ and โ€˜reconstructedDollar 4 .tifโ€™.

c) Display both the original and the reconstructed images in a single figure window.

d) Given the original and the reconstructed image above, compute the mean squared error (MSE)

and the peak signal-to-noise ratio (PSNR) using the following formulae:

2

๐‘

๐‘—= 1

๐‘€

๐‘–= 1

10

2

Q.6. [5+5+5=15]

Using the provided image โ€˜moon.tifโ€™, do the following:

i) Compute the Laplacian of the image with 90 - deg and 45 - deg isotropic filters and display the

results with proper scaling.

ii) Sharpen the original image by using the outputs of part (i) above.

iii) Display the original as well as the sharpened images from part (ii) and comment on your

results.

Note: Submit your homework as a zip file at course email by the due date.

Don't forget to include the code as attachment.