Presentation is loading. Please wait.

Presentation is loading. Please wait.

Digital Image Processing Lecture 17: Segmentation: Canny Edge Detector & Hough Transform Prof. Charlene Tsai.

Similar presentations


Presentation on theme: "Digital Image Processing Lecture 17: Segmentation: Canny Edge Detector & Hough Transform Prof. Charlene Tsai."— Presentation transcript:

1 Digital Image Processing Lecture 17: Segmentation: Canny Edge Detector & Hough Transform Prof. Charlene Tsai

2 2 Review Detection of discontinuity using  1 st derivative Providing gradient and magnitude  Zero crossing (2 nd derivative using Laplacian) For edge location No gradient information Sensitive to noise Smoothing using Gaussian filter (LoG)

3 3 What is missing? Q1: Is a pixel an edge element or not?  Canny Edge Detection Q2: If the edge elements are not connect, how to establish the boundary between regions?  Hough Transform

4 4 Canny Edge Detector Canny edge detector answers the first question. Characteristics of the edge detector:  Low error rate -- finding all edges and nothing but edges.  Localization of edges – distance between edges found and actual edges should be minimized.  Single response – no multiple edge pixels when only a single edge exists.

5 5 Steps for Canny Edge Detector Step 1: generating edge image.  Create 1D Gaussian filter g (for smoothing)  Create 1D filter dg (derivative of the Gaussian) What for?  Convolve g with dg to obtain gdg.  Apply gdg to image x producing x1  Apply gdg’ to image x producing x2  Edge magnitude image is

6 6 (con’d) Step 2: marking the edge element using non- maximum suppression  A pixel p is an edge if its magnitude is greater than its neighbors in direction (edge gradient)  Edge gradient image is

7 7 Non-maximum Suppression See any difficulty with step2?  Qantization issue 0 degrees 45 degrees 90 degrees 135 degrees

8 8 (con’d) Any edge direction falling within the yellow range is set to 0. Any edge direction falling in the green range is set to 45. Any edge direction falling in the blue range is set to 90. And any edge direction falling within the red range is set to 135. 0 to 22.5 157.5 to 180 22.5 to 67.5 67.5 to 112.5 112.5 to 157.5

9 9 Hysteresis Thresholding (final step) After non-max suppression, threshold to produce a binary edge image. Hysteresis thresholding has two values:  Low value t L and  High value t H Conditions under which p is marked as edge:  If xe(p) > t H,  If p is adjacent to an edge pixel, and

10 10 Edge Function in Matlab I intensity image, BW binary image THRESH is a two-element vector in which the first element is the low threshold, and the second element is the high threshold. The Canny method uses 2 thresholds, to detect strong and weak edges, and includes the weak edges in the output only if they are connected to strong edges.  This method is therefore less likely than the others to be "fooled" by noise, and more likely to detect true weak edges. BW = edge(I,'canny') BW = edge(I,'canny',thresh) BW = edge(I,'canny',thresh,sigma) Syntax sensitivity thresholds smoothing

11 11 I = imread(‘Will.jpg’); bw = edge(I,'canny'); I = imread(‘Lena.tif’); bw = edge(I,'canny');

12 12

13 13

14 14 A =edge(I,'canny',[], 1); B =edge(I,'canny',[], 2); C =edge(I,'canny',[], 3); D =edge(I,'canny',[], 4); E =[A B C D]; imshow(E) sigma

15 15 Summary of Canny Algorithm The Canny Edge Detection Algorithm has the following steps: Smooth the image with a Gaussian filter, Compute the gradient magnitude and orientation using finite- difference approximations for the partial derivatives, Apply non-maximum suppression to the gradient magnitude, Use the double thresholding algorithm to detect and link edges.

16 16 Why is Canny so dominant? Still widely used after 20 years. Theory is nice (but end result same). Details good (magnitude of gradient). Hysteresis an important heuristic. Code was distributed. Perhaps this is about all you can do with linear filtering.

17 17 Hough Transform Results of edge-detection methods may contain sparse points, instead of straight lines or curves. Therefore, need to fit a line to the edge points. Efficient solution: Hough Transform  Originally for finding lines  Easily varied to find other shapes

18 18 Simple Example Consider a point (x i,y i ) and the general equation of a straight line in slope-intercept form:  Q: How many lines may pass through (x i,y i )? Re-writing the equation in ab-plane  How many lines do we get for a fixed (x i,y i )? slope intercept

19 19 Finding (a,b) Now given another point (x j, y j ), how to find the parameter (a’,b’) which defines the line that contains both points?

20 20 (con’d) All points on this line have lines in parameter space that intersect at (a’,b’).

21 21 What is the problem? How about a vertical line?  Gradient/slope is infinite Need another parameterization scheme. Now consider r is the shortest distance from the line to the origin, and is the angle New parameterization:

22 22 Computation for Hough Transform Choosing a discrete set of values of r and. Construct an accumulator array, initialized with 0 for each entry. Picture this process as a voting process r min r max r

23 23 (con’d) For each edge point (x,y) in the image,  we compute for each  Increment the counter for the cell of the resulting (r, ) At the end, the (r, ) with highest count correspond to strongest line in the image.


Download ppt "Digital Image Processing Lecture 17: Segmentation: Canny Edge Detector & Hough Transform Prof. Charlene Tsai."

Similar presentations


Ads by Google