EN161 - Image Processing and Understanding
Lab 5 - Edge Detection & Image Warping
Due Monday 10/15
NOTE: Problems should be done in MATLAB.  Type up your solutions for each one including: (1) The answer to any questions posed, (2) any resulting images (include in document), and (3) the name of any functions you used. 

Zip or tar your document with your source code (m-files) into a file called [Lastname_FirstInitial_Lab5.zip/tar] and email it to mcchang@lems.brown.edu with the subject "EN161 Lab5".

Overview:
This lab will introduce you to various methods of edge detection and image warping.
Problem 1:
Edge detection by kernel convolution.
Refer to the handout of edge detection kernels (p1). Use the Matlab convolution function (conv2) to convolve the kernels over the input image to detect edges on it. Use kernels of:
  • Prewitt
  • Sobel
  • Laplacian
on Image A and Image B.  Determine the strengths and weaknesses of one relative to the other. 
Specifically look for the success of each algorithm with respect to corners, curved edges, noise inclusion/exclusion, etc. 
Which of the edge types above are most easily detected; which are more difficult.
Provide specific examples and images to illustrate your findings.
 
                                                           Image A                                                                                                                        Image B

 
Problem 2:
Gradient edge detection.
In this problem you will explore a very simple edge detector.

a. Load Image A and smooth it with a Gaussian filter to eliminate noise.
b. Use the gradient function to compute the 1st derivatives in the x and y direction:

[dy,dx]=gradient(A);

c. Look at the magnitude of the gradient image using imshow, M=sqrt(dx^2+dy^2)
d. Now use the command quiver(dy,dx) to view the actual gradient vectors; you may want to zoom in.  (The image will be upside down, don't worry about it).  It is very important that you understand what is going on here for this and the next lab.
e. Create a binary edge image by thresholding the gradient magnitude image.  Pick a value that gives you few gaps in the edges.
f. Finally thin the edges using the following process:

   1.  Visit every edge pixel in the binary image.  For each one, look at the gradient direction at that point (dy,dx) and round it to the nearest of the 8 pixel directions.
   2.  Look at the gradient magnitude of the pixel in that direction and also at the pixel in the oposite direction.
   3.  If the pixel in question has a gradient magnitude less than either of those two neighbors, set its value in the binary image to 0.

Submit the thinned and unthinned images.  Also try it on image B.


 
Problem 3:
Image Warping.
Refer to the handout of Beyond Photography. pp. 34-72. Create an image warping function.  The function should take in as input a greyscale image array and output a warped version of the image.  You can implement any of the algorithms on the warping handout, for example (Function 1). You are welcome to implement all of them. It's fun!

         
                                                                                   Input (eien.jpg)                                                         Output

Test your warping function on eien.jpg and the image you took with the digital camera.


Problem 4:

Image Warping.
Implement the polynomial warping function described on page 430 of the Geometrical Image Modification Handout.  To do this, you will need to:
1.  Choose control points in the original image and the warped version.  This defines your warping function, by choosing around 10-12 points in the original image and then choosing where they will end up in the warped image.
2.  Use the formulations on page 432 to determine the mapping functions.
3.  Input all the points of the original image and generate the warped version.

[Hint: In order to get a result like the one in figure 14.2-3, the image must be centered about the origin.  However, matricies in MATLAB cannot be zero or negative.  Think about how you might get around this.]

Test on Image C and the image you took with the digital camera. 

Image C