Edge detection Gradient-based edge operators Prewitt Sobel Roberts Laplacian zero-crossings Canny edge detector Hough transform for detection of straight lines Circle Hough Transform Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 1
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection Gradient-based edge detection Idea (continous-space): local gradient magnitude indicates edge strength grad f x, y,, f x y f x y x y Digital image: use finite differences to approximate derivatives Edge templates difference central difference Prewitt -1 1-1 1 1 1 1 1 1 1 1 1 Sobel 1 1
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 3 Practical edge detectors Edges can have any orientation Typical edge detection scheme uses K= edge templates Some use K> e x y 1, s x, y e x y, Combination, e.g., k e k k or x, y Max e x, y k edge magnitude M x, y ek x, y xy, (edge orientation)
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 4 Gradient filters (K=) Central 1 Difference 1 1 1 1 1 1 1 1 Prewitt 1 1 1 1 1 1 1 Roberts 1 1 1 1 1 1 1 1 Sobel 1 1 1 1
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 5 Kirsch operator (K=8) 5 5 5 3 5 5 3 3 5 3 3 3 Kirsch 3 3 3 5 3 5 3 5 3 3 3 3 3 3 3 3 5 3 5 5 3 3 3 3 3 3 5 3 35 5 3 3 3 5 3 5 3 5 3 5 5 5 5 5 3 5 3 3 3 3 3
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 6 Prewitt operator example Magnitude of image filtered with 1 1 1 1 1 1 (log display) Original 14x71 Magnitude of image filtered with 1 1 1 1 1 1 (log display)
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 7 Prewitt operator example (cont.) Sum of squared horizontal and vertical gradients (log display) threshold = 9 threshold = 45 threshold = 7
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 8 Sobel operator example Sum of squared horizontal and vertical gradients (log display) threshold = 16 threshold = 8 threshold = 18
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 9 Roberts operator example Magnitude of image filtered with 1 1 Original 14x71 Magnitude of image filtered with 1 1
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 1 Roberts operator example (cont.) Sum of squared diagonal gradients (log display) threshold = 1 threshold = 5 threshold = 8
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 11 y-component y-component Edge orientation Central Difference 1 1 1 1 Gradient scatter plot x-component Roberts 1 1 1 1 x-component
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 1 y-component y-component Edge orientation Prewitt 1 1 1 1 1 1 1 1 1 1 1 1 Gradient scatter plot Sobel 1 1 1 1 1 1 1 1 x-component x-component
y-component Edge orientation Gradient scatter plot 5x5 consistent gradient operator [Ando, ] x-component -.64 -.163.163.64 -.486-1.1335 1.1335.486 -.7448-1.961 1.961.7448 -.486-1.1335 1.1335.486 -.64 -.163.163.64 -.64 -.486 -.7448 -.486 -.64 -.163-1.1335-1.961-1.1335 -.163.163 1.1335 1.961 1.1335.163.64.486.7448.486.64 Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 13
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 14 Gradient consistency problem Calculate this value using gradient field Same result, regardless of path? Known gray value
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 15 Laplacian operator Detect edges by considering second derivative Isotropic (rotationally invariant) operator Zero-crossings mark edge location,, f x y f x y f x, y x y Detect zero crossing Edge profile f(x) f (x) f (x)
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 16 Approximations of Laplacian operator by 3x3 filter 1 1 4 1 1 1 1 1 1 8 1 1 1 1 8 15 H 6 4 H 1 5 - - - - y x y x
Zero crossings of Laplacian Sensitive to very fine detail and noise blur image first Responds equally to strong and weak edges suppress zero-crossings with low gradient magnitude Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 17
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 18 Laplacian of Gaussian Filtering of image with Gaussian and Laplacian operators can be combined into convolution with Laplacian of Gaussian (LoG) operator x y 1 x y LoG x, y 1 e 4. -. -.4 -.6 1-1 - -.8-3 -.1 4-4 4 Y - -4-4 - X 4 Y -
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 19 Discrete approximation of Laplacian of Gaussian 1 1. 3 5 5 5 3 1 1 3 5 3 3 5 3 1 -. 5 3-1 -3-1 3 5 -.4 5-3 -4-3 5 -.6 5 3-1 -3-1 3 5 -.8 1 3 5 3 3 5 3 1 -.1 3 5 5 5 3-4 4 4 1 1 4 - - - Y -4-4 X Y -4-4 -1 - -3 - X 4 H 15 1 5 y - - x
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection Zero crossings of LoG 4 8
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 1 Zero crossings of LoG gradient-based threshold 4 8
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection Canny edge detector 1. Smooth image with a Gaussian filter. Approximate gradient magnitude and angle (use Sobel, Prewitt...) M x, y f f x y f f y x 1 xy, tan 3. Apply nonmaxima suppression to gradient magnitude 4. Double thresholding to detect strong and weak edge pixels 5. Reject weak edge pixels not connected with strong edge pixels [Canny, IEEE Trans. PAMI, 1986]
Canny nonmaxima suppression Quantize edge normal to one of four directions: horizontal, -45 o, vertical, +45 o If M[x,y] is smaller than either of its neighbors in edge normal direction suppress; else keep. [Canny, IEEE Trans. PAMI, 1986] Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 3
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 4 Canny thresholding and suppression of weak edges Double-thresholding of gradient magnitude Typical setting: high Strong edge: M x, y Weak edge: M x, y high Region labeling of edge pixels Reject regions without strong edge pixels low...3 high low [Canny, IEEE Trans. PAMI, 1986]
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 5 Canny edge detector 4
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 6 Hough transform Problem: fit a straight line (or curve) to a set of edge pixels Hough transform (196): generalized template matching technique Consider detection of straight lines y mx c x m y edge pixel c
Hough transform (cont.) Subdivide (m,c) plane into discrete bins, initialize all bin counts by Draw a line in the parameter space [m,c] for each edge pixel [x,y] and increment bin counts along line. Detect peak(s) in [m,c] plane x m detect peak y c Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 7
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 8 Hough transform (cont.) Alternative parameterization avoids infinite-slope problem x edge pixel y xcos ysin Similar to Radon transform
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 9 Hough transform example 1 3 4 5 6 7 8 4 6 8 Original image
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 3 Hough transform example 1 3 4 5 6 7 8 4 6 8 Original image
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 31 Hough transform example 1 3 4 5 6 7 8 4 6 8 Original image
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 3 Hough transform example -4 15-1 Paper De-skewed (364x448) Paper 5-81.8 deg 4-5 5-81.8 deg Global thresholding
Circle Hough Transform Find circles of fixed radius r x Circle center x y edge pixel Equivalent to convolution (template matching) with a circle y Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 33
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 34 Circle Hough Transform for unknown radius 3-d Hough transform for parameters -d Hough transform aided by edge orientation spokes in parameter space x x, y, r Circle center x y edge pixel y
Digital Image Processing: Bernd Girod, 13-14 Stanford University -- Edge Detection 35 Original coins image Example: circle detection by Hough transform Prewitt edge detection Detected circles