Computer Engineering Dept.
Faculty of Engineering Cairo University Digital Image Processing Lab
Lab 7 Edge Detectors
Notes: All the images used are in the folder MatlabRoot\toolbox\images\imdemos. Before doing any mathematical operation on the image, you must convert it to double. Before displaying the image after mathematical operations, you must convert it to uint8. Write each experiment as an M-file to test it. 1. Using the image circuit.tif a. Apply sobel filter to calculate the gradient in x Display the result b. Apply sobel filter to calculate the gradient in y Display the result c. Calculate the magnitude of the gradient as |G| = |Gx| + |Gy| Display the result
Hints
To construct the filter use the function fspecial(sobel) to get the filters Gx and Gy
To apply the filter use one of the 3 functions i. filter2() ii. imfilter() iii. conv2() 2. Using the image cameraman.tif apply Canny edge detection algorithm: a. Using thresholds [0.5 0.9] and sigma = 1 b. Using thresholds [0.04 0.1] and sigma = 1 (BONUS) c. Using thresholds [0.04 0.1] and sigma = 3 (BONUS)
Hints use the function edge():
o BW = edge(I, 'canny', thresh, sigma) where: thresh is a two-element vector in which the first element is the low threshold, and the second element is the high threshold. sigma is the standard deviation of the Gaussian filter.
Computer Engineering Dept. Faculty of Engineering Cairo University Digital Image Processing Lab
Original Image
Sobel Edges
Canny Edges with thresholds [0.5 0.9] and sigma = 1
Canny Edges with thresholds [0.04 0.1] and sigma = 1 (BONUS)
Canny Edges with thresholds [0.04 0.1] and sigma = 3 (BONUS)