1 / 23

Digital Image Processing Lecture 17: Segmentation: Canny Edge Detector & Hough Transform

Digital Image Processing Lecture 17: Segmentation: Canny Edge Detector & Hough Transform. Prof. Charlene Tsai. Review. Detection of discontinuity using 1 st derivative Providing gradient and magnitude Zero crossing (2 nd derivative using Laplacian) For edge location

Download Presentation

Digital Image Processing Lecture 17: Segmentation: Canny Edge Detector & Hough Transform

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  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. 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. 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. (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. Non-maximum Suppression • See any difficulty with step2? • Qantization issue 45 degrees 135 degrees 0 degrees 90 degrees

  8. (con’d) 67.5 to 112.5 112.5 to 157.5 22.5 to 67.5 0 to 22.5 157.5 to 180 Any edge direction falling within the yellow rangeis set to 0. Any edge direction falling in thegreen rangeis set to 45. Any edge direction falling in theblue rangeis set to 90 . And any edge direction falling within thered rangeis set to 135.

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

  10. Edge Function in Matlab sensitivity thresholds • 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 smoothing

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

  12. sigma 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)

  13. 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.

  14. 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.

  15. 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

  16. Simple Example • Consider a point (xi,yi) and the general equation of a straight line in slope-intercept form: • Q: How many lines may pass through (xi,yi)? • Re-writing the equation in ab-plane • How many lines do we get for a fixed (xi,yi)? intercept slope

  17. Finding (a,b) • Now given another point (xj, yj), how to find the parameter (a’,b’) which defines the line that contains both points?

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

  19. 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:

  20. 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 rmin rmax r

  21. (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.

More Related