You are on page 1of 12

ECOE 508

Computer Vision
Spring 2009

Binary Morphology

Mathematical Morphology

• Stands as a relatively separate part of image analysis


• Based on the algebra of non-linear operators operating on
object shape
• Supersedes the linear convolution
• Yields fast algorithms

A binary morphological operation


Applications

• Binary morphology (2D or 3D)


­ Shape simplification
­ Shape enhancing
­ Skeletonizing
­ Thinning and thickening

• Gray-scale morphology
­ Image segmentation
­ Noise filtering

Basic operations

Binary mathematical morphology consists of two


basic operations:

dilation and erosion

and several composite relations:

closing and opening


hit or miss transformation
...
Dilation

Dilation expands the connected sets of 1s of a binary image.

It can be used for

1. expanding shapes:

2. filling holes, gaps and gulfs:

Erosion

Erosion shrinks the connected sets of 1s of a binary image.

It can be used for

1. shrinking shapes:

2. removing bridges, branches and small protrusions:


Structuring Elements

A structuring element is a shape mask used in


the basic morphological operations.

Can be of any shape and size, that is


digitally representable, and each has an origin.

box
hexagon disk any shape

box(length,width) disk(diameter)

Dilation with Structuring Elements

The arguments to dilation and erosion are


1. a binary image X
2. a structuring element S

dilate(X,S) takes binary image X, places the origin of structuring


element S over each 1-pixel, and ORs the structuring element S
with X to produce the output image at the corresponding position.

0000 dilate 0110


1
0110 ⊕ 0111
11
0000 0000
S
X origin X⊕S
Erosion with Structuring Elements

erode(X,S) takes a binary image X, places the origin of


structuring element S over every pixel position, and puts a binary
1 into that position of the output image only if every position of
S (with a 1) covers a 1 in X.

origin
0 0 1 1 0 0 0 0 0 0
1 erode
0 0 1 1 0 0 0 1 1 0
1
0 0 1 1 0 0 0 1 1 0
1
1 1 1 1 1 0 0 0 0 0

X S X S

Dilation and Erosion as a Set Operations

A binary image can be thought of as a set of points on the


Euclidean space ε2. 00000
0 0 1 1 0 X={(2,1),(2,2),(3,2),(3,3)}
Binary image Set X 00110
00000

1
Structuring element Set S S={(0,0),(0,1),(1,0)}
11

{
Dilation: X ⊕ S = p ∈ ε 2 : p = x + s, ∀x ∈ X , ∀s ∈ S }
p = ( p1 , p2 ) = x + s = ( x1 + s1 , x2 + s2 )

{
Erosion: X S = p ∈ ε 2 : p + s ∈ X , ∀s ∈ S }
Opening and Closing

• Closing is the compound operation of dilation followed by


erosion (with the same structuring element)
X •S =( X ⊕S ) S
Has similar effects with dilation; but preserves global shape.
(filling holes, gaps and gulfs)

• Opening is the compound operation of erosion followed by


dilation (with the same structuring element)
X DS =( X S )⊕ S
Has similar effects with erosion; but preserves global shape.
(removing bridges, branches and small protrusions)

Opening and closing are idempotent, i.e., successive


application does not change the result.

Example

Opening
Structuring
element

Dilation

Closing

Erosion
Example

Opening
Structuring
element

Dilation

Closing

Erosion

Example

Original

Opening

Closing
Boundary extraction

Contours can be extracted by subtraction of the eroded image


from the original.

Skeletonization

Skeletonization: Converting a 2D or 3D object to a stick figure that


represents its internal structure.

2D skeletons 3D skeletons

9 Homotopic skeletons preserve connectivity and topology,


9 Can be used for example in shape matching via graph matching
algorithms.
Skeleton by Maximal Balls

The ball B included in a set X is maximal iff there is no larger


ball included in X that contains B:

The skeleton by maximal balls S(X) of a set X is the set of centers


of maximal balls:

Remark: In practice, a skeleton defined in this way is not


necessarily homotopic and not necessarily of one pixel wide in the
discrete plane.

Homotopic Skeletons

• A homotopic skeleton can be obtained by morphological operations.


• We need to define two composite operations:
hit-or-miss and thinning

using a composite structuring element S:

S = (S1, S2) such that S1∩ S2 = Ø


Hit-or-miss

A variant of template matching that finds collections of pixels


with certain shape properties (such as corners, border pixels).

Gives a part
X ⊗ S = (X S1 ) ∩ (X c S 2 ) of the object
boundary
9 X S1: locus of object pixels similar to S1
c
9 X S2: locus of background pixels similar to S2

S S1 S2
Example:
Detection of “endpoints”
from the left.

Thinning

When thinning, a part of the boundary of the object is


subtracted from it by the set difference operation:

X S = X / (X ⊗ S)

A homotopic skeleton can be found by sequential thinning:

Number n of iterations
X {Si } = ((( X S1 ) S 2 ) " S n ) depends on the object
type.

Golay alphabet of rotated elements

{Li }8i =1repeat in order till convergence


Skeletonization by Sequential Thinning

Sequential thinning using element L after five iterations

Homotopic skeleton after convergence

Skeleton Smoothing

The skeleton is usually jagged; it can be smoothed by further


sequential thinning with another series of structuring elements

After five iterations of sequential thinning by element E


Example- Morphological Processing of Handwritten Digits

Gray-scale Morphology

• Binary morphological operations are easily extendible to gray-


scale images using min and max operations.
• Erosion (respectively, dilation) of an image is the operation of
assigning to each pixel the minimum (maximum) value found over
a neighborhood of the corresponding pixel.
• Application areas: Segmentation, noise removal, etc.

Example:
Segmentation of cell
boundaries in the
images of human cornea.

You might also like