pptx

advertisement
CS-467 Digital Image Processing
SPATIAL DOMAIN FILTERING
EDGE DETECTION
1
Edges
• Edge pixels are pixels at which the intensity
changes abruptly
• Edges are sets of connected edge pixels
• Often edges are called points of discontinuity
of the intensity function
• To detect edges, differentiation in a local
neighborhood should be used
2
Importance of Edge Detection
• Edge detection is important for localization of
image details, especially the smallest details
• It can be used, for example, in non- destructive
inspection, to localize possible defects; in medical
imaging, to localize important details
• Edge detection is also used in image
segmentation – a process that partitions an
image into disjoint regions corresponding to
different textures
3
High-Pass Filtering
• In terms of filtering, edge detection is a spatial
domain high-pass filtering
• Differentiating an image, high-pass filters
eliminate low and medium frequencies,
passing and possibly enhancing high
frequencies.
4
Three Major Types of Intensity Change
Step
© 1992-2008 R.C. Gonzalez & R.E. Woods
Ramp
Roof
5
Derivatives of Digital Functions
• The derivatives of a digital image function are
defined in terms of differences. They have to
meet the following requirements:
• A 1st derivative
1) Must be 0 in areas of constant intensity
2) Must be nonzero at the onset of an intensity
step or ramp;
3) Must be nonzero along ramps
6
Derivatives of Digital Functions
• The derivatives of a digital image function are
defined in terms of differences. They have to
meet the following requirements:
• A 2nd derivative
1) Must be 0 in areas of constant intensity
2) Must be nonzero at the onset and end of an
intensity step or ramp;
3) Must be zero along ramps of constant slope
7
Derivatives of 1-D Digital Functions
• A basic definition of the first-order derivative
of the digital function f  x 
f
 f  x  1  f  x 
x
• A basic definition of the second-order
derivative of the digital function f  x 
2 f
  f  x  1  f  x     f  x   f  x  1  
2
x
 f  x  1  f  x  1  2 f  x 
8
Derivatives of 1-D Digital Functions
© 1992-2008 R.C. Gonzalez & R.E. Woods
9
Derivatives of 2-D Digital Functions
• A basic definition of the first-order derivatives
of the function f  x, y 
f
f
 f  x  1, y   f  x, y  ;  f  x, y  1  f  x, y 
x
y
• A basic definition of the second-order
derivatives of the function f  x, y 
2 f
 f  x  1, y   f  x  1, y   2 f  x, y  ;
2
x
2 f
 f  x, y  1  f  x, y  1  2 f  x, y 
2
y
10
The Laplacian and Second Order
Derivative Edge Detection
• The Laplacian (as it is known from calculus
and partial differential equations) is
2
2

f

f
2
 f  x, y   2  2
x
y
• Hence, Laplacian of the image intensity
function f  x  (“Laplacian 1”)
 2 f  x, y   f  x  1, y   f  x  1, y   f  x, y  1 
 f  x, y  1  4 f  x, y 
11
The Laplacian
• A global edge detector must be spatially
isotropic, it should not depend on any rotation
of an image and particular gradient direction
• To detect diagonal edges, we should involve
f
f
the diagonal second-order derivatives
,
xy yx
(Laplacian 2)
 2 f  x, y   f  x  1, y   f  x  1, y   f  x, y  1  f  x, y  1 
 f  x  1, y  1  f  x  1, y  1  f  x  1, y  1  f  x  1, y  1 
8 f  x, y 
12
Laplacian Edge Detector
Downward
Upward
• Laplacian 1
© 1992-2008 R.C. Gonzalez & R.E. Woods
Laplacian 2
13
Laplacian Detector of Lines
Oriented in Various Directions
© 1992-2008 R.C. Gonzalez & R.E. Woods
14
First- and Second- Order
Derivatives and Edge Detection
• Laplace edge detectors are based on secondorder derivatives
• There are also edge detectors based on firstorder derivatives
• Second-order derivatives better detect edges
corresponding to the smallest details, they
also detect and enhance isolated pixels
• First-order derivatives detect and possibly
enhance the brightness jumps “as they are”
15
First- and Second- Order
Derivatives and Edge Detection
© 1992-2008 R.C. Gonzalez & R.E. Woods
16
Distinction between First- and SecondOrder Derivatives in Edge Detection
© 1992-2008 R.C. Gonzalez & R.E. Woods
17
First-Order Derivatives in
Edge Detection
• First-order derivatives in image processing are
implemented using the magnitude of the gradient
 f 
 g x   x 
f  grad ( f )      
 g y   f 
 y 
• The magnitude (length) of vector f is
M  x, y   mag  f   g x2  g y2  g x  g y
18
Gradient and Edge
© 1992-2008 R.C. Gonzalez & R.E. Woods
19
First-Order Derivatives by Roberts
(1965)
g x   z8  z5  ; g y   z6  z5 
 z1

 z4
z
 7
z2
z5
z8
z3 

z6 
z9 
M  x, y   z8  z5  z8  z5
Robert’s derivatives and gradients
g x   z9  z5  ; g y   z8  z6 
M  x, y   z9  z5  z8  z6
Disadvantage: no center of symmetry
20
First-Order Derivatives by Prewitt
(1970)
 z1

 z4
z
 7
z2
z5
z8
z3 

z6 
z9 
f
gx 
  z7  z8  z9    z1  z2  z3 
x
f
gy 
  z3  z6  z9    z1  z4  z7 
y
M  x, y    z7  z8  z9    z1  z2  z3  
  z3  z6  z9    z1  z4  z7 
21
First-Order Derivatives by Sobel (1970)
 z1

 z4
z
 7
z2
z5
z8
f
gx 
  z7  2 z8  z9    z1  2 z2  z3 
x
f
gy 
  z3  2 z6  z9    z1  2 z4  z7 
y
z3 

z6 
z9  M  x, y    z7  2 z8  z9    z1  2 z2  z3  
  z3  2 z6  z9    z1  2 z4  z7 
22
Roberts, Prewitt, and Sobel masks
© 1992-2008 R.C. Gonzalez & R.E. Woods
23
Some Disadvantages of Classical Edge
Detectors
• They do not differ (except Laplace) between
upward (from “dark” to “bright”) and downward
(from “bright” to “dark”) brightness jumps
• This is resulted in “bold” (“thick”) edges where
the same brightness jump can be detected twice
• All of them (except Prewitt) give a preference to
the pixel of interest (the symmetry center). This
may help to suppress noise, to avoid its
detection, but simultaneously some edges can be
emphasized, while some other can be suppressed
24
Nonlinear Edge Detectors
• In fact, even Sobel and Prewitt edge detectors
are nonlinear, because they operate with
absolute values of gradients. |…| function is
only piecewise-linear; thus, it is nonlinear.
• Nonlinear edge detectors are based either on
nonlinear operation applied to digital
derivatives or nonlinear transformation of an
image followed by some kind of
differentiation
25
Threshold Boolean Filtering
• Let X be (M+1)-valued gray scale image
1 , if x(i, j )  k
x (i, j )  
; k  1,..., M
0 , otherwise
• Let
be a binary
plane
• Then filtering operation
is determined by
M
y  i, j    F  X ij( k ) 
(k )
k 1
(k )
X
where F is the processing Boolean function, ij
is a local window around a pixel of interest
26
Edge Detecting Boolean Functions
• The Boolean function for detection of upward
brightness jumps
 x1

Fu  f  x4
x
 7
x2
x5
x8
x3 

x6   x5 &  x1  x2  x3  x4  x6  x7  x8  x9 
x9 
• The Boolean function for detection of
downward brightness jumps
 x1

Fd  f  x4
x
 7
x2
x5
x8
x3 

x6   x5 &  x1  x2  x3  x4  x6  x7  x8  x9 
x9 
27
Edge Detecting Boolean Functions
 0 1 1


 0 1 1
 1 0 1


 0 0 1


 0 0 1
 1 1 1


Upward Edge passes through the center of
the window, there is no downward edge
Downward Edge passes through the center
of the window, there is no upward edge
28
TBF (Stack) Edge Detection Filter
• Detection of upward brightness jumps is
equivalent to

m  max  f  x, y   f  x  1, y  1 ,if m  0 
g  x, y   
0,
otherwise


• Detection of downward brightness jumps is
equivalent to

m  max  f  x  1, y  1  f  x, y  ,if m  0 
g  x, y   
0,
otherwise


29
TBF Edge Detection
 35 210 100 

 Upward Edge pass through the center of the
112
120
80

 window, its intensity is 120-35=85
100 221 220 


 35 210 100 


112
120
80


100 221 220 


Downward Edge pass through the center of
the window, its intensity is 221-120=101
30
Edge Detection using Stack Filter
• Simultaneous detection of downward and
upward brightness jumps
g  x, y   max f  x, y   f  x  1, y  1
• This is resulted in “bold” (“thick”) edges
31
Image Break-up Into Binary Planes
• Each intensity value in the range 0…255 is
presented by one byte, which consists of 8 bits
• Breaking up these bytes into bits, we break up
the entire image into 8 binary planes
© 1992-2008 R.C. Gonzalez & R.E. Woods
32
Precise Edge Detection
• Algorithm:
1) Breaking up the image into binary planes;
2) Detection of edges using edge detecting
Boolean function;
3) Assembling the resulting image from the
binary planes
33
Precise Edge Detection
• Upward Edge Detecting Boolean function
 x1

f  x4
x
 7
x2
x5
x8
x3 

x6  
x9 
x5  ( x1  x2  x3  x4  x6  x7  x8  x9 )
• Downward Edge Detecting Boolean function
 x1

f  x4
x
 7
x2
x5
x8
x3 

x6  
x9 
x5  ( x1  x2  x3  x4  x6  x7  x8  x9 )
• “Global” Edge Detecting Boolean function
 x1

f  x4
x
 7
x2
x5
x8
x3 

x6  
x9 
 x5 & ( x1  x2  x3  x4  x6  x7  x8  x9 )  
 x5 & ( x1  x2  x3  x4  x6  x7  x8  x9 )
34
Edged Segmentation using
Precise Edge Detection
• Edged Segmentation is edge detection with
simultaneous emphasizing of areas with different
textures bounded by edges
• To make segmentation using precise edge
detection, it is necessary to detect edges in some
binary planes preserving some other binary
planes unchanged. For example, a good
segmentational effect can be achieved by
detecting edges in binary planes 0,1,2,3,4,7 and
preserving binary planes 5,6 unchanged
35
Noise and Edge Detection
• Noise prevents detecting clean edges because edge detectors
don’t care of what is behind particular intensity jump – noise
or useful detail
© 1992-2008 R.C. Gonzalez & R.E. Woods
36
Download