Está en la página 1de 19

Boundary Extraction

and
Edge Detection

Doug Daniels
CIS 467 Spring ‘05
04/26/2005
Boundary Extraction
Introduction
„ Boundary extraction is one of the basic Morphological algorithms
„ It is used in Binary images to extract the boundary or edge of objects by
highlighting their borders.
„ Recall that a boundary is defined as a region R (white pixels) that has
one or more of its neighbors not in R (black pixels).
Boundary Extraction
Applications
„ The boundary of an object is very
useful in:
„ Image Recognition – To recognize
identifying features of an object.
„ Image segmentation – To identify objects
of interest.
„ Shape Coding – To compress images or
video.
Set Operations
•2 Sets A, B.
•Union is all the pixels
shared in A OR B
(A|B)
•Intersection is all the pixels
shared in A AND B
(A&B)
•Complement is the pixels
NOT in A (~A)
•Difference is the pixels in A
AND NOT B. (A & ~B)
Binary Image
Operations
•NOT operation acts like set
complement on a binary
image
•AND operation acts like set
intersection on a binary image
•A AND NOT(B) acts like set
difference operation (A-B), on
a binary image.
Boundary Extraction
Definition

β(A) = A− (imerode(A, B))


• Boundary Extraction is defined on image A, using
structure element B, as the difference between the
original image and the B eroded image.

β(A) = A & ~ (imerode(A, B))


• For binary images Boundary Extraction can be defined
using logical operators.
Boundary Extraction
Implementation

A & ~ (imerode(A,B)) = β ( A)

•B is a 3x3 structuring element


Implementation
Example Cont.
„ If we use a bigger structuring element to
erode image we get a thicker boundary
extracted.

B=3X3 B=4X4 B=7X7


MATLAB Project
•MATLAB function returns the
function extim=boundextract(img, elem) boundary extracted image using
the parameter elem as the
%Convert to binary black and white image
level = graythresh(img); structuring element to erode the
im = im2bw(img,level); image by.

%Erode image using structuring element


erodeIm = imerode(im, elem);

%Set complement for binary image is logical NOT


erodeImCompl = ~erodeIm;

%Boundary extracted image is


%A - (A erode B)
%or A intersect ~(A erode B)
%Because we're using a binary image set intersect is logical AND
%and set complement is logical NOT
extim=im & erodeImCompl;
end
Edge Detection
„ Is used in grayscale images to detect meaningful
discontinuities in gray level.
„ Uses 1st and 2nd order derivatives to detect edges.
Edge Detection
cont.

•An edge is intuitively a set of


connected components that lie between
the boundary of 2 regions.
•Derivatives give distinct transition edge
locations.
•Can use midpoint as pixel edge
location
Gradient 1st Order
Derivative

 ∂f 
Gx   ∂x 
∇f =   =  ∂f 
G y   
 ∂y 
∇f = mag (∇f) = [G 2 x + G 2 y ]1/ 2
 Gx 
α ( x, y ) = tan  
−1

 Gy  Gx Gy

Gx = ( z7 + 2 z8 + z9 ) − ( z1 + 2 z 2 + z3 )
G y = ( z3 + 2 z6 + z9 ) − ( z1 + 2 z 4 + z7 )
Noise difficulties
•Noise in an image is almost imperceptible
in the initial image, but it can make it
almost impossible to detect edges even
with small amounts of noise.
•It is important to use smoothing to reduce
noise before edge detection.
Edge Detection
examples
Gx
f

Gy Gx + G y
Edge Linking and
Boundary Detection
„ Finding edges in an image seldom characterize a
complete edge because of the noise and the gaps in
the image.
„ We use edge linking procedures to assemble edge
pixels into meaningful edges.
„ To link edges we analyze a small neighborhood (3x3,
5x5) that has an edge detected point.
„ We check if it is a similar point with its neighbors if it
is we link it.
„ Similar points are defined according to the edge
point’s derivative characteristics (Magnitude, and
direction)
Edge Linking criteria
„ We use the following criteria to link points of an edge where
(x0, y0) is the edge point and (x,y) are the surrounding
neighborhood points.
1. Strength of response of gradient that produced edge.
∇f ( x, y ) − ∇f ( x0 , y 0 ) ≤ E
E is a threshold

2. Direction of gradient vector.


α ( x, y ) − α ( x0 , y 0 ) ≤ A
A is an angle threshold:
Grayscale Boundary
example
Vertical Gy image
• The horizontal and vertical
similar edges are combined.
(Thresholds E=25, A=15º)
• We remove smaller segments
which represent noise or
unwanted details.
• We can use this technique to
identify the location of the
license plate, because we
know the plate is a distinct
rectangle with 2:1 width to
height ratio.
• Then we can further process the
original image now that we
detected the plate location Horiz Gx image Edge Linked: Gx + G y
Conclusion
„ Boundary Extraction and Edge
Detection are useful techniques used
to:
„ Recognize distinct object’s, or shape’s
edges.
„ Compressing an image by only storing
specific edge information.
References
Gonzalez and Woods, Digital Image Processing 2nd
Edition, Prentice Hall 2002, ISBN 0201180758,
http://www.imageprocessingplace.com/

También podría gustarte