Download - Edge Detection - cs.bu.edu
![Page 1: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/1.jpg)
Edge Detection
Definition:Edges = brightness changes (discontinuities) in an image
due to- occlusion- changes in surface orientation - changes in surface reflectance (material)- illumination discontinuity
CS 585: Image and Video Computing
![Page 2: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/2.jpg)
The Causes of Brightness Changes in an Image
CS 585: Image and Video Computing
1. Occluding boundary2. Changes in surface orientation3. Changes in surface reflectance4. Illumination discontinuity
![Page 3: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/3.jpg)
1D Case: Image E(x) = grey value = brightness
E(x)
dE(x)/dx
d2E(x)/dx2
CS 585: Image and Video Computing
![Page 4: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/4.jpg)
2D Case: E(x,y)
CS 585: Image and Video Computing
Direction and magnitude of brightness change vector:Gradient of brightness
Edge is perpendicular to gradient
![Page 5: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/5.jpg)
Discrete Approximation of Derivatives =Finite Differences
E(r,s+1)
E(r,s) E(r+1,s)
CS 585: Image and Video Computing
E(r+1,s) – E(r,s)
E(r,s+1) – E(r,s)
![Page 6: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/6.jpg)
Discrete Approximation of Derivatives =Finite Differences
E(r,s+1)
E(r,s) E(r+1,s)
CS 585: Image and Video Computing
E(r+1,s) – E(r,s)
E(r,s+1) – E(r,s)
1
-1
-1 1
![Page 7: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/7.jpg)
Which is ∂E/ ∂x? Which ∂E/∂y?
CS 585: Image and Video Computing
![Page 8: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/8.jpg)
Better Approximation of Brightness Derivatives
E(r,s+1) E(r+1, s+1)
E(r,s) E(r+1,s)
CS 585: Image and Video Computing
E(r+1, s+1) – E(r,s+1) + E(r+1,s) – E(r,s)
E(r+1, s+1) – E(r+1,s) + E(r,s+1) – E(r,s)
![Page 9: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/9.jpg)
Better Approximation of Brightness Derivatives
E(r,s+1) E(r+1, s+1)
E(r,s) E(r+1,s)
CS 585: Image and Video Computing
E(r+1, s+1) – E(r,s+1) + E(r+1,s) – E(r,s)
E(r+1, s+1) – E(r+1,s) + E(r,s+1) – E(r,s)
1
-1
-1-1
11
1
-1
![Page 10: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/10.jpg)
Simple Edge Detection Algorithm
• Compute ∂E/ ∂x and ∂E/∂y to determine brightness gradient direction.
• Use |∂E/ ∂x| + |∂E/∂y| or (∂E/ ∂x)2 + (∂E/∂y)2 or magnitude sqrt{(∂E/ ∂x)2 + (∂E/∂y)2} to compute “edge strength” M
IF M > threshold, EdgeMap(x,y) = 1;
ELSE EdgeMap(x,y) = 0;
CS 585: Image and Video Computing
![Page 11: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/11.jpg)
High Threshold on Magnitude of Brightness Change
CS 585: Image and Video Computing
![Page 12: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/12.jpg)
Low Threshold on Magnitude of Brightness Change
CS 585: Image and Video Computing
![Page 13: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/13.jpg)
Low Threshold on Magnitude of Brightness Change
CS 585: Image and Video Computing
![Page 14: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/14.jpg)
High Threshold on Magnitude of Brightness Change
CS 585: Image and Video Computing
![Page 15: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/15.jpg)
Other Commonly Used Edge Masks to Approximate the Brightness Gradient
Approximating Roberts Prewitt Sobel for Measuring:
∂E/∂x vertical edges
∂E/∂y horizontal edges
CS 585: Image and Video Computing
-1 0 1-1 0 1-1 0 1
1 1 10 0 0-1 -1 1
1 2 1
0 0 0
-1 -2 -1
0 1-1 0
1 00 -1
![Page 16: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/16.jpg)
Approximating 2nd Derivatives of Brightness
CS 585: Image and Video Computing
Difference of differences:∂2E/∂x2 = 1/ε2 { [E(r-1,s) – E(r,s)] - [ E(r,s) – E(r+1,s) ] } =
1/ε2 { E(r-1,s) – 2 E(r,s) + E(r+1,s) }∂2E/∂y2 = 1/ε2 { E(r,s-1) – 2 E(r,s) + E(r,s+1) }where
E(r-1,s+1) E(r,s+1) E(r+1,s+1)
E(r-1,s) E(r,s) E(r+1,s)
E(r-1,s-1) E(r,s-1) E(r+1,s-1)
![Page 17: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/17.jpg)
Edge Detection via Laplacian at Center Cell
The Laplacian of E(x,y) is defined as ∂2E/∂x2 + ∂2E/∂y2 .
Approximation of the Laplacian at center cell of 9-pixel window: 4/ ε2 { ¼ [ E(r-1,s) + E(r, s-1) + E(r+1,s) + E(r,s+1) ] - E(r,s) }
Mask:
CS 585: Image and Video Computing
1
-4
1
1 1
![Page 18: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/18.jpg)
Edge Detection via Laplacian at Center CellMask: Mask rotated by 45 degrees:
Accurate approximation of the Laplacian (linear combination of above):
CS 585: Image and Video Computing
1
-4
1
1 11
1
1
1-4
1 4 1
4 -20 4
1 4 1
Edge Detection Algorithm:1) Approximate Laplacian2) Find zero crossings
![Page 19: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/19.jpg)
• PApproximation by
Difference of Gaussians
Or
“Mexican Hat Function”• C1• 4• 1• 4
• -20• 4• 1• 4• 1
CS 585: Image and Video Computing Source: Wikipedia
1 4 1
4 -20 4
1 4 1
![Page 20: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/20.jpg)
Use Image Masks multiple times:or or
Or use a “Gaussian Mask,” for example:
Image Smoothing
CS 585: Image and Video Computing
1 1 11 1 11 1 1
1 1 11 2 11 1 1
1 2 1 2 4 21 2 1
1/9 1/10 1/16
![Page 21: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/21.jpg)
Smoothing Applied to our Example
CS 585: Image and Video Computing
![Page 22: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/22.jpg)
Smoothing Applied to our Example
CS 585: Image and Video Computing
![Page 23: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/23.jpg)
Edge Detection on Smoothed Images
CS 585: Image and Video Computing
![Page 24: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/24.jpg)
Edge Detection on Original and Smoothed
CS 585: Image and Video Computing
![Page 25: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/25.jpg)
Edge Detection on Original and Smoothed
CS 585: Image and Video Computing
![Page 26: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/26.jpg)
Smoothed Image yields “thick” edges
Solution:
We need a “non-maximum suppression algorithm:”
For vertically pointing brightness gradient:
CS 585: Image and Video Computing
10
5
3
10
5
3
10
0
14
10
5
14
![Page 27: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/27.jpg)
Canny Edge Detection1. Smooth image with Gaussian filter2. Compute gradient magnitude map M(x,y) = sqrt((dI/dx)2+(dI/dy)2)
& gradient direction map θ(x,y) = arctan(dI/dx, dI/dy)3. Apply “Nonmaximum Suppression” to M:
a. Reduce number of angles into 4 sectors: θ(x,y) -> α(x,y)b. Scan through M(x,y) with a 3x3 mask & check 3 pixels (A,B,C) along the line
defined by α(x,y): If M(B) ≤ M(A) and M(B) ≤ M(C), then set M(B) to zero.4. Apply “Double Thresholding:”
a. Initialize: Choose τ2 ≈ 2 τ1; Copy M(x,y) into T1(x,y) & T2(x,y) = M(x,y)b. If M(x,y) < τ1 then T1(x,y) = 0. If M(x,y) < τ2 then T2(x,y) = 0. c. Link gaps in T2 by gathering edges from T1 (compare N8 neighbors)
CS 585: Image and Video Computing
![Page 28: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/28.jpg)
How does Canny Edge Detection work?
1. Smoothing removes speckle noise but creates thicker edges3. This step thins edges4. This step performs noise reduction and edge linking:
(a) (b)
CS 585: Image and Video Computing
T1(x,y) T2(x,y) FinalEdgeMap
![Page 29: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/29.jpg)
Active Contours (also called “Snakes”)
Goal: Given an edge image of an object, Find the outline of the object = Find its contour points
Idea: Combine disconnected edges (gaps), allow corners
CS 585: Image and Video Computing
IterativeAlgorithm
--> -->
![Page 30: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/30.jpg)
Iterative Optimization Algorithm
Input: Greyscale image E(x,y); Output: Binary contour map 1. Initial Solution for Contour (e.g., hand drawn or large bounding box)2. Evaluate cost function (or “energy” function) for
• Fit of contour with edge image Eimage• Curvature properties of contour Ecurvature• Distances of contour points to each other Econtinuity
3. Move contour point4. Repeat 2.Possible termination conditions:
Upper bound on # iterations or on points moved OR Lower bound on cost function or change in cost
CS 585: Image and Video Computing
![Page 31: Edge Detection - cs.bu.edu](https://reader031.vdocuments.mx/reader031/viewer/2022011915/61d7dd2fa5413c53284366f6/html5/thumbnails/31.jpg)
“Energy” FunctionContinuous version on boardDiscrete version: Ej = αi Econtinuity, j + βi Ecurvature, j + γi Eimage, j
whereαi , βi, γi control the relative influence of each terme.g., βi =0 at corner point
Explanation of each energy follows
Read the paper by Williams and Shah on active contours
CS 585: Image and Video Computing