Edge Detection
Roadmap Introduction to image analysis (computer vision) Its connection with psychology and neuroscience Why is image analysis difficult? Theory of edge detection Gradient operator Advanced operators Applications Road/sign detection in intelligent driving systems Pupil detection in iris recognition systems
Computer Vision: the Grand Challenge Teach a computer to see is nontrivial at all Unlike binary images, grayscale/color images acquired by the sensor are often easy to understand by human being but difficult for a machine or a robot There are lots of interesting problems in the field of computer vision (image analysis) Image segmentation, image understanding, face detection/recognition, object tracking 3
How does Human Vision System work? Top-down school I see a human body I expect to see a human face Bottom-up school pixels components (such as edges, lines etc.) I expect to see two eyes and a nose objects Two hypothesis and nobody knows the answer yet! 4
An Amazing Image Example Person A: I see an old man with a fancy earring and a strange hand Person B: I see two people on the street and a dog lying beside If you try really hard, you will be able to locate at least eight different faces from this image 5
Gestalt Theory (the Berlin School) Emergence: the dog is perceived as a whole, all at once 6
Reification 7
Multistability (or Multistable Perception) 8
Invariance 9
Application: Face Detection You are strongly encouraged to try the interactive demo out yourself http://vasc.ri.cmu.edu/demos/faceindex/
Edge Detection Gradient operator Advanced operators Why detect edge? Edges characterize object boundaries and are useful features for segmentation, registration and object identification in scenes. What is edge (to human vision system)? No rigorous definition exists Intuitively, edge corresponds to singularities in the image (i.e. where pixel value experiences abrupt change)
Edge detection Idea (continuous-space): Detect local gradient Digital image: use finite differences instead
Practical edge detectors Edges can have any orientation Typical edge detection scheme uses K= edge templates Some use K> 3
Gradient Operators Motivation: detect changes change in the pixel value large gradient image f(m,n) Gradient operator g m, n = f x + f y θ g = tan f y f x Thresholding g(m,n) edge map I(m,n) MATLAB function: > help edge I( m, n) g( m, n) th otherwise 4
Common Operators Gradient operator g( m, n) g ( m, n) g ( m, n) Examples:. Roberts operator g g 5
6 Common Operators (cont d). Prewitt operator 3. Sobel operator vertical horizontal
Edge detection filters 7
Examples horizontal edge vertical edge original image Prewitt operator (th=48) Sobel operator (th=48) 8
Sobel detector 9
Prewitt detector
Magnitude of Sobel at threshold = {45, 4, 3,,, 5}, g =[,87]
Effect of Thresholding Parameters small threshold large
3 Compass Operators ) }, ( max{ ), ( n m g m n g k k
Examples Compass operator (th=48) 4
(Laplacian operator) Zero-crossings mark edge location 5 Laplacian Operators Gradient operator: first-order derivative sensitive to abrupt change, but not slow change second-order derivative: y f x f f x f local extreme in f 4 8 Discrete Laplacian operator =>Isotropic (rotationally invariant) operator a= a=.5 a a a a a a a a a 4
-d illustration of nd derivative edge detector zero crossing f f f image Laplacian edge zero-crossing operator map x(m,n) g(m,n) I(m,n) 6
Examples original image zero-crossings Question: why is it so sensitive to noise (many false alarms)? Answer: a sign flip from. to -. is treated the same as from to - Sensitive to very fine detail and noise => blur image first Responds equally to strong and weak edges => suppress zero-crossings with low gradient magnitude 7
Ideas to Improve Robustness Linear filtering Use a Gaussian filter to smooth out noise component Laplacian of Gaussian Spatially-adaptive (Nonlinear) processing Apply different detection strategies to smooth areas (low-variance) and non-smooth areas (highvariance) Robust Laplacian edge detector Return single response to edges (not multiple edge pixels) Hysteresis thresholding Canny s edge detector 8
Laplacian of Gaussian Blurring of image with Gaussian and Laplacian operator can be combined into convolution with Laplacian of Gaussian (LoG) operator ( m n ) m n h( m, n) c[ ]exp( Gaussian Laplacian image edge LPF () operator map x(m,n) g(m,n) I(m,n) ) Pre-filtering: attenuate the noise sensitivity of the Laplacian 9
Laplacian of Gaussian Continuous function and discrete approximation 5 5 5 5 5 5 4 5 5 5 5 5 5 σ = 3
Zero crossings of LoG at difference scale σ =.5 σ = 3 σ = 6 3
Examples Better than Laplacian alone but still sensitive due to zero crossing 3
Robust Laplacian-based Edge Detector estimate local variance image Laplacian operator zero crossing? No not an edge point >th No not an edge point yes edge point 33
Examples More robust but return multiple edge pixels (poor localization) 34
Canny Edge Detector Low error rate of detection Well match human perception results Good localization of edges The distance between actual edges in an image and the edges found by a computational algorithm should be minimized Single response The algorithm should not return multiple edges pixels when only a single one exists 35
Canny Edge Detector. Smooth image with a Gaussian filter. Compute gradient magnitude and angle (Sobel, Prewitt...) g x, y = f x + f y f, θ x, y = tan y f x 3. Apply nonmaxima suppression to gradient magnitude image 4. Double thresholding to detect strong and weak edge pixels 5. Reject weak edge pixels not connected with strong edge pixels 36
Flow-chart of Canny Edge Detector (J. Canny 986) Original image Smoothing by Gaussian convolution Differential operators along x and y axis Non-maximum suppression finds peaks in the image gradient Hysteresis thresholding locates edge strings Edge map 37
Canny nonmaxima suppression Quantize edge normal to one of four directions: If g(x,y) is smaller than either of its neighbors in edge normal direction suppress; else keep. Double-thresholding of gradient magnitude. Typical setting: θ high θ low =,3,4, Region labeling of edge pixels Reject regions without strong edge pixels 38
Canny Edge Detector Example original image vertical edges horizontal edges norm of the gradient after thresholding after thinning 39
Marr and Hildreth s Method* Edge is scale-dependent A different edge map can be generated at different scale Scale space representation f ( x, y; s) f ( x, y;) g( x, y; s) coarse-scale image fine-scale image Gaussian kernel with width of s g( x, y; s) s exp( x y s ) 4
Importance of Scale 4
Scale-Space Edge Detection Examples fine coarse 4
Marr/Hildreth and Canny Edge Detection 43
Marr/Hildreth and Canny Edge Detection 44