Computer Vision Homework 2: Image Processing and Edge Detection - Prof. Pradeep Sen, Assignments of Electrical and Electronics Engineering

Instructions for homework #2 in the computer vision course (ece 516 / cs 532) taught by prof. Sen. The assignment focuses on image processing using matlab, specifically taking the 2-d fourier transform, implementing edge detectors, and using a simple canny edge detector. Students are required to submit three matlab files with the solutions for each problem.

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-3k5
koofers-user-3k5 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 516 / CS 532 - Computer Vision
Prof. Sen
Homework #2
Due: Sunday, March 8, 2009
This homework assignment consists of only programming assignments. You need to submit it by
email before midnight on the due date. It would make things much easier to grade if you create three
different MATLAB files (one for each problem) that automatically runs through all the parts of the
problem and generates the images required (assume that the test images are in the same directory as the
.m files). You can use the command “figure” to generate a new image targets in MATLAB. Work with
the test images provided on the class webpage, and include in your submission the two images of your
own that you use for part (d) of problem 3.
1. In the first problem, you will experiment with taking the 2-D Fourier Transform of images.
(a) Load one of test images provided and compute its 2-D discrete Fourier Transform using the
“fft2()” command in MATLAB. Show your result by displaying the magnitude and phase as
an image. Note that the way that MATLAB takes the fft, the zero frequency will not appear
in the middle of the image. Use the “fftshift()” command to adjust the result of the Fourier
Transform so that it looks more appropriate.
(b) Mix the phase of the Fourier Transform of two images as was done in Figure 7.6 to show
that the phase contains more useful information than the magnitude.
(c) Multiply the Fourier Transform of the image by a box filter (an image that is all zeros
except for a square 1’s in the middle). Take the inverse Fourier transform of the result using
“ifft2(). What has happened to the image?
(d) Try to design a filter that isolates high and low frequencies but suppresses “middle” fre-
quencies. The resulting image should look like a cartoon. Test this on some of the test
images.
2. For this problem, you will implement some simple edge detectors.
(a) First, implement the simple [+1 1] finite differences filter and convolve it across the test
image in the xand ydirections. Combine the results of the two in a way that makes sense
and display the result as an image.
(b) Try your filter on lena noisy.tif to see the result. To improve it, first convolve the image with
a 2-D Gaussian to reduce noise. Experiment with the standard deviation of the Gaussian
to strike a balance between over-blurring the image and suppressing noise. Remember that
you can separate the 2-D Guassian into two 1-D Gaussian functions in xand yand that you
can apply your filter directly to the Gaussian and then apply the result to the image. Use
“conv2()” to convolve the 2D arrays.
(c) Now implement the Laplacian edge detection algorithm we discussed in class. Take the
Laplacian of the image (after blurring with a Gaussian kernel) and look for the zero crossing
pixels that also have a high magnitude gradient. Show your results for the images provided.
1
pf2

Partial preview of the text

Download Computer Vision Homework 2: Image Processing and Edge Detection - Prof. Pradeep Sen and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

ECE 516 / CS 532 - Computer Vision Prof. Sen Homework # Due: Sunday, March 8, 2009

This homework assignment consists of only programming assignments. You need to submit it by email before midnight on the due date. It would make things much easier to grade if you create three different MATLAB files (one for each problem) that automatically runs through all the parts of the problem and generates the images required (assume that the test images are in the same directory as the .m files). You can use the command “figure” to generate a new image targets in MATLAB. Work with the test images provided on the class webpage, and include in your submission the two images of your own that you use for part (d) of problem 3.

  1. In the first problem, you will experiment with taking the 2-D Fourier Transform of images.

(a) Load one of test images provided and compute its 2-D discrete Fourier Transform using the “fft2()” command in MATLAB. Show your result by displaying the magnitude and phase as an image. Note that the way that MATLAB takes the fft, the zero frequency will not appear in the middle of the image. Use the “fftshift()” command to adjust the result of the Fourier Transform so that it looks more appropriate. (b) Mix the phase of the Fourier Transform of two images as was done in Figure 7.6 to show that the phase contains more useful information than the magnitude. (c) Multiply the Fourier Transform of the image by a box filter (an image that is all zeros except for a square 1’s in the middle). Take the inverse Fourier transform of the result using “ifft2().” What has happened to the image? (d) Try to design a filter that isolates high and low frequencies but suppresses “middle” fre- quencies. The resulting image should look like a cartoon. Test this on some of the test images.

  1. For this problem, you will implement some simple edge detectors.

(a) First, implement the simple [+1 −1] finite differences filter and convolve it across the test image in the x and y directions. Combine the results of the two in a way that makes sense and display the result as an image. (b) Try your filter on lena noisy.tif to see the result. To improve it, first convolve the image with a 2-D Gaussian to reduce noise. Experiment with the standard deviation of the Gaussian to strike a balance between over-blurring the image and suppressing noise. Remember that you can separate the 2-D Guassian into two 1-D Gaussian functions in x and y and that you can apply your filter directly to the Gaussian and then apply the result to the image. Use “conv2()” to convolve the 2D arrays. (c) Now implement the Laplacian edge detection algorithm we discussed in class. Take the Laplacian of the image (after blurring with a Gaussian kernel) and look for the zero crossing pixels that also have a high magnitude gradient. Show your results for the images provided.

  1. For the last problem, you will implement a simple Canny edge detector.

(a) First, load the test image and compute the x and y components of the gradient (Fx and Fy) of the image smoothed by a Gaussian. Compute the magnitude of the gradient (√ |∇f | = F (^) x^2 + F (^) y^2 ) and the edge orientation D = arctan(Fy/Fx) at each pixel. Output the image showing the magnitude of the gradient. (b) Now perform the non-maximum suppression as described in class to create a “thinned edge image” I(x, y). For each pixel, pick the direction in { 0 ◦, 45 ◦, 90 ◦, 135 ◦} that is closest to the orientation D at that pixel. If the edge strength (given by the magnitude of the gradient |∇f | at that pixel) is greater than both of its neighbors along this angle, then set I(x, y) = |∇f (x, y)|, else make it 0. Output this thinned image. (c) Now perform the hysteresis thresholding. First, create an array M that labels all the pixels as “unmarked.” Then implement the following algorithm:

Algorithm 0.1: HYSTERESIS THRESHOLDING(I, M )

for each  unmarked pixel in M   

  

if I(x, y) > Th

then

while { I(x, y) > Tl mark pixel as edge and as visited update (x, y) to follow the direction of the edge mark the pixel

(d) Now test your algorithm on the images provided as well as two of your own. For each, identify the width of the Gaussian for smoothing and the high and low threshold values Th and Tl. Compare these with the results from the Laplacian edge detector in problem 2.