Вы находитесь на странице: 1из 34

Edge Detection

Phil Mlsna, Ph.D.

Dept. of Electrical Engineering


Northern Arizona University
Some Important Topics in Image Processing
• Contrast enhancement
• Filtering (both spatial and frequency domains)
• Restoration
• Segmentation
• Image Compression
etc.
EE 460/560 course, Fall 2003
(formerly CSE 432/532)

Edge Detection uses spatial filtering to extract


important information from a scene.
Types of Edges
• Physical Edges
– Different objects in physical contact
– Spatial change in material properties
– Abrupt change in surface orientation
• Image Edges
– In general: Boundary between contrasting regions
in image
– Specifically: Abrupt local change in brightness
Image edges are important clues for identifying
and interpreting physical edges in the scene.
Goal: Produce an Edge Map

Original Image Edge Map


Edge Detection Concepts in 1-D

f (x )

f (x )

f (x)

Edges can be characterized as either:


• local extrema of f (x )
• zero-crossings of f (x)
Continuous Gradient
f ( x, y) ˆ f ( x, y ) ˆ
f ( x, y)  i j
x y
But f is a vector.

We really need a scalar that gives a measure of edge


“strength.”
2
 f ( x, y )   f ( x, y ) 
2

f ( x, y )      
 x   y 
This is the gradient magnitude. It’s isotropic.
Classification of Points
Let points that satisfy f ( x, y)  T be edge points.

PROBLEM:

T
f
Non-zero edge width

Stronger gradient magnitudes produce thicker edges.

To precisely locate the edge, we need to thin. Ideally,


edges should be only one point thick.
Practical Gradient Algorithm

1. Compute  f for all points.


2. Threshold f to produce candidate edge points.
3. Thin by testing whether each candidate edge point
is a local maximum of f along the direction of
f . Local maxima are classified as edge points.
Cameraman
image

Thresholded Thresholded and


Gradient Thinned
Directional Edge Detection
f ( x, y )
T Horizontal operator
x (finds vertical edges)
f ( x, y )
T Vertical operator
y (finds horizontal edges)

f ( x, y ) f ( x, y )
cos  sin   T
x y
finds edges perpendicular to the  direction
Directional Examples

Horizontal Difference Vertical Difference


Operator Operator
Discrete Gradient Operators
Pixels are samples on a discrete grid.
Must estimate the gradient solely from these samples.

STRATEGY: Build gradient estimation filter kernels and


convolve them with the image.

Two basic filter concepts


First difference:  1 1
Central difference:  1 0 1
Simple Filtering Example in 1-D

Convolving  1 1 with

[ 5 5 5 8 20 25 25 22 12 4 3 3 ]
 1 1

[ 0]
Simple Filtering Example in 1-D

Convolving  1 1 with

[ 5 5 5 8 20 25 25 22 12 4 3 3 ]
 1 1

[ 0 0]
Simple Filtering Example in 1-D

Convolving  1 1 with

[ 5 5 5 8 20 25 25 22 12 4 3 3 ]
 1 1

[ 0 0 3]
Simple Filtering Example in 1-D

Convolving  1 1 with

[ 5 5 5 8 20 25 25 22 12 4 3 3 ]
 1 1
produces:
[ 0 0 3 12 5 0 -3 -13 -8 -1 0 ]
Gradient Estimation
1. Create orthogonal pair of filters,
h1 (n1 , n2 ) h2 (n1 , n2 )
2. Convolve image with each filter:
f1 (n1 , n2 )  f (n1 , n2 )  h1 (n1 , n2 )
f 2 (n1 , n2 )  f (n1 , n2 )  h2 (n1 , n2 )
3. Estimate the gradient magnitude:
ˆ f (n , n ) 
 f12 (n1 , n2 )  f 22 (n1 , n2 )
1 2
Roberts Operator

 0 1 1 0 
h1 (n1 , n2 )    h2 (n1 , n2 )   
  1 0 0  1

• Small kernel, relatively little computation


• First difference (diagonally)
• Very sensitive to noise
• Origin not at kernel center
• Somewhat anisotropic
Noise
• Noise is always a factor in images.
• Derivative operators are high-pass filters.
• High-pass filters boost noise!

• Effects of noise on edge detection:


– False edges
– Errors in edge position

Key concept:
Build filters to respond to edges and suppress noise.
Prewitt Operator

 1 0 1 1 1 1
 1 0 1 0 0 0
   
 1 0 1  1  1  1

• Larger kernel, somewhat more computation


• Central difference, origin at center
• Smooths (averages) along edge, less sensitive to
noise
• Somewhat anisotropic
Sobel Operator

  1 0 1 1 2 1
  2 0 2 0 0 0 
  
  1 0 1  1  2  1

• 3 x 3 kernel, same computation as Prewitt


• Central difference, origin at center
• Better smoothing along edge, even less sensitive to
noise
• Still somewhat anisotropic
Discrete Operators Compared

Original Roberts
Roberts Prewitt
Prewitt Sobel
T=5 T = 10

Roberts

T = 20 T = 40
Continuous Laplacian

 f ( x, y )  f ( x, y )
2 2
 f ( x, y )    f ( x, y ) 
2

x 2
y 2
This is a scalar. It’s also isotropic.

Edge detection: Find all points for which


 f ( x, y)  0
2

No thinning is necessary.
Tends to produce closed edge contours.
Discrete Laplacian Operators
0 1 0  1 1 1  1 2  1
1  4 1 1  8 1  2 4 2 
     
0 1 0 1 1 1  1 2  1
ˆ
 f (n1 , n2 )  f (n1 , n2 )  h(n1 , n2 )
2

• Origin at center
• Only one convolution needed, not two
• Can build larger kernels by sampling Laplacian of
Gaussian
Laplacian of Gaussian
(Marr-Hildreth Operator)
 x2  y2 
Gaussian: g ( x, y)  exp   
 2 
2

Let:
x  y  2
2 2

2
x y 
2 2
h( x, y)   g ( x, y) 
2
exp   
 4
 2 
2

Then:  2 f ( x, y)   2 g ( x, y)  f ( x, y)
 h ( x , y )  f ( x, y )
LoG Filter Impulse Response

  g ( x, y)
2
LoG Filter Frequency Response

{ g ( x, y)}
2
Laplacian of Gaussian Examples

 = 1.5

 = 1.0  = 2.0
LoG Properties
• One filter, one convolution needed
• Zero-crossings are very sensitive to noise (2nd deriv.)
• Bandpass filtering reduces noise effects
• Edge map can be produced for a given scale
• Scale-space or pyramid decomposition possible
• Found in biological vision!!

Practical LoG Filters:


• Kernel at least 3 times width of main lobe, truncate
• Larger kernel  more computation
Summary

• Edges can be detected from the derivative:


– Extrema of gradient magnitude
– Zero-crossings of Laplacian
• Practical filter kernels; convolve with image
• Noise effects
– False edges
– Imprecise edge locations
– Correct filtering attempts to control noise
• Edge map is the goal
Questions?

Вам также может понравиться