Assignment 01 - F19

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

COMPUTER VISION

ASSIGNMENT 01

Due Date: 12th November 2019 Total Marks: 60

INSTRUCTIONS:

 Late submissions will not be accepted.


 You can complete this assignment in a group of 2 students.
 You should write your own code. Code copied from online or from fellow members will not be accepted. Plagiarism
will not be tolerated.
 What do you hand in: A Zip file that has:
a. Images (input and output) clearly labeled
b. Code you used for each question.
c. Finally a report in PDF file with clearly mentioned group members’ names and registration number. The report
must shows all the results you acquired for the problem set.
d. You must upload the assignment on FOIT.LMS in a compressed file.
e. Only one member of the group must upload the files.

IMAGE MANIPULATION
1. Load the image “Q1.tif” into MATLAB. Originally, it will be in the form of a 2D-array of unsigned integers.
Check and report
a. how many bits per integer the image has, and
b. what is its width and height?
2. We would like to bring the image to a more typical average brightness. Apply a scaling factor to all pixels,
so that the minimum pixel value becomes 0 and the max pixel value becomes 255. Include the final image
in your report, as well as the MATLAB code you used to produce it.
3. Next perform the histogram equalization on the image “Q1.tif” and compare the results acquired in the
previous question.
4. Next, we would like to double the contrast of the pixels in the middle brightness range. Specifically, take
your result from Question 03 and replace each pixel's intensity i with a new intensity i  , where

i  2   i  128  128

Threshold i  so that 0  i  255 (you can use the “uint8” function). Include your MATLAB code and the
resulting contrast-boosted image in your report.
IMAGE FILTER

5. Write a function that convolves an image with a given correlation filter


function [img1] = myImageFilter(img0, h)
As input, the function takes a greyscale image (img0) and a correlation filter stored in matrix h. The
output of the function should be an image img1 of the same size as img0 which results from correlating
img0 with h. You can assume that the filter h is odd sized along both dimensions. You will need to handle
boundary cases on the edges of the image. For example, when you place a correlation mask on the top
left corner of the image, most of the filter mask will lie outside the image. One solution is to output a zero
value at all these locations. The better thing to do is to pad the image such that pixels lying outside the
image boundary have the same intensity value as the nearest pixel that lies inside the image. You can
call MATLAB's function to pad array. However, your code can not call on MATLAB's imfilter, conv2,
convn, filter2 functions, or any other similar functions.

EDGE DETECTION

6. Write a function that finds edge intensity and orientation in an image.


function [img1] = myEdgeFilter(img0, sigma)
The function will input a greyscale image (img0) and scalar (sigma). Sigma is the standard deviation of
the Gaussian smoothing kernel to be used before edge detection. The function will output img1, the edge
magnitude image.
First, use your convolution function to smooth out the image with the specified Gaussian kernel.
This helps reduce noise and spurious fine edges in the image. Use fspecial to get the kernel for the
Gaussian filter. The size of the Gaussian filter should depend on sigma (e.g., hsize = 2 * ceil(3 *
sigma) + 1). The edge magnitude image img1 can be calculated from image gradients in the x direction
and y direction. To find the image gradient imgx in the x direction, convolve/correlate the smoothed
image with the x-oriented Sobel filter. Similarly, find image gradient imgy in the y direction by convolving
the smoothed image with the y-oriented Sobel filter. You can also output imgx and imgy if needed. In
many cases, the high gradient magnitude region along an edge will be quite thick. For finding lines its
best to have edges that are a single pixel wide.
Towards this end, make your edge filter implement non-maximum suppression that is for each
pixel look at the two neighboring pixels along the gradient direction and if either of those pixels has a
larger gradient magnitude then set the edge magnitude at the center pixel to zero. Map the gradient angle
to the closest of 4 cases, where the line is sloped at almost 0, 45, 90, and 135. For example, 30 would
map to 45. Your code cannot call on Matlab's edge function, or any other similar functions.

You might also like