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, 013 Stanford University -- Edge Detection 1
Gradient-based edge detection Idea (continous-space): local gradient magnitude indicates edge strength Digital image: use finite differences to approximate derivatives Edge templates Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection
Practical edge detectors Edges can have any orientation Typical edge detection scheme uses K= edge templates Some use K> e 1 x, y s[ x, y] e x, y Combination, k e k e.g., x, y or edge magnitude M x, y Max k e k x, y e K x, y α x, y (edge orientation) Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 3
Gradient filters (K=) Central Difference 0 0 0 1 [ 0] 1 0 0 0 0 1 0 0 [ 0] 0 0 1 0 Roberts [ 0] 1 1 0 [ 1] 0 0 1 Prewitt 1 0 1 1 [ 0] 1 1 0 1 1 1 1 0 0 [ ] 0 1 1 1 Sobel 1 0 1 [ 0] 1 0 1 1 1 0 0 [ ] 0 1 1 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 4
Kirsch operator (K=8) Kirsch +5 +5 +5 3 [ 0] 3 3 3 3 3 +5 +5 3 [ 0] +5 3 3 3 3 3 +5 3 [ 0] +5 3 3 +5 3 3 3 3 [ 0] +5 3 +5 +5 3 3 3 3 [ 0] 3 +5 +5 +5 3 3 3 +5 [ 0] 3 +5 +5 3 +5 3 3 +5 [ 0] 3 +5 3 3 +5 +5 3 +5 [ 0] 3 3 3 3 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 5
Prewitt operator example Magnitude of image filtered with 1 0 1 1 [ 0] 1 1 0 1 (log display) Original 104x710 Magnitude of image filtered with 1 1 1 0 0 [ ] 0 1 1 1 (log display) Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 6
Prewitt operator example (cont.) Sum of squared horizontal and vertical gradients (log display) threshold = 900 threshold = 4500 threshold = 700 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 7
Sobel operator example Sum of squared horizontal and vertical gradients (log display) threshold = 1600 threshold = 8000 threshold = 1800 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 8
Roberts operator example Magnitude of image filtered with Original 104x710 Magnitude of image filtered with Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 9
Roberts operator example (cont.) Sum of squared diagonal gradients (log display) threshold = 100 threshold = 500 threshold = 800 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 10
Edge orientation Central Difference 0 0 0 1 [ 0] 1 0 0 0 0 1 0 0 [ 0] 0 0 1 0 y-component Gradient scatter plot x-component Roberts [ 0] 1 1 0 [ 1] 0 0 1 y-component x-component Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 11
Edge orientation Prewitt 1 0 1 1 [ 0] 1 1 0 1 1 1 1 0 0 [ ] 0 1 1 1 y-component Gradient scatter plot x-component Sobel 1 0 1 [ 0] 1 0 1 1 1 0 0 [ ] 0 1 1 y-component x-component Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 1
Edge orientation Gradient scatter plot 5x5 consistent gradient operator [Ando, 000] y-component x-component Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 13
Gradient consistency problem Calculate this value using gradient field Same result, regardless of path? Known gray value Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 14
Laplacian operator Detect edges by considering second derivative Isotropic (rotationally invariant) operator Zero-crossings mark edge location Detect zero crossing Edge profile f(x) f (x) f (x) Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 16
Approximations of Laplacian operator by 3x3 filter 0 1 0 1 4 1 0 1 0 1 1 1 1 8 1 1 1 1 8 15 H 6 4 H 10 5 0 0 0 - - 0 0 - - 0 ω y ω x ω y ω x Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 17
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, 013 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 σ = LoG( x, y)= 1 1 x + y πσ 4 σ e x + y σ 0.0 0-0.0-0.04-0.06-0.08-0.1 4 0 Y - -4-4 - X 0 4 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 19
Discrete approximation of Laplacian of Gaussian σ = 0 0 1 1 0 0 0 3 5 5 5 3 0 10 00 1 3 5 3 0 3 5 3 1 5 3-1 -3-1 3 5 5 0-3 -40-3 0 5 5 3-1 -3-1 3 5 1 3 5 3 0 3 5 3 1 0 3 5 5 5 3 0 0 0 1 1 0 0 0-10 -0-30 -40 4 0 Y - -4-4 - X 0 4 H 150 100 50 0 0 ω y - - ω x 0 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 0
Zero crossings of LoG σ = σ = σ = 4 σ = 8 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 1
Zero crossings of LoG gradient-based threshold σ = σ = σ = 4 σ = 8 Digital Image Processing: Bernd Girod, 013 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 x + f y f α x, y tan 1 y f x 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] Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 3
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, 013 Stanford University -- Edge Detection 4
Canny thresholding and suppression of weak edges Double-thresholding of gradient magnitude Typical setting: Region labeling of edge pixels Reject regions without strong edge pixels [Canny, IEEE Trans. PAMI, 1986] Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 5
Canny edge detector σ = σ = σ = 4 Digital Image Processing: Bernd Girod, 013 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 edge pixel y c Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 8
Hough transform (cont.) Subdivide (m,c) plane into discrete bins, initialize all bin counts by 0 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, 013 Stanford University -- Edge Detection 9
Hough transform (cont.) Alternative parameterization avoids infinite-slope problem θ ρ edge pixel x ρ y xcosθ + ysinθ = ρ π π π θ Similar to Radon transform Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 30
Hough transform example 100 00 300 400 500 600 700 800 00 400 600 800 Original image Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 31
Hough transform example 100 00 300 400 500 600 700 800 00 400 600 800 Original image Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 3
Hough transform example 100 00 300 400 500 600 700 800 00 400 600 800 Original image Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 33
Hough transform example -4000 1500-000 ρ 1000 Paper De-skewed (364x448) Paper 0 000 500-81.8 deg 4000 0-50 0 50 θ -81.8 deg Global thresholding Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 34
Circle Hough Transform Find circles of fixed radius r x Circle center x 0 y edge pixel Equivalent to convolution (template matching) with a circle y 0 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 35
Circle Hough Transform for unknown radius 3-d Hough transform for parameters ( x 0, y 0,r) -d Hough transform aided by edge orientation spokes in parameter space x x 0 Circle center y edge pixel y 0 Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 36
Original coins image Example: circle detection by Hough transform Prewitt edge detection Detected circles Digital Image Processing: Bernd Girod, 013 Stanford University -- Edge Detection 37