Top Banner
Chapter 9
47

Chapter 9. Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape. Boundaries, skeletons,

Dec 30, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Chapter 9

Page 2: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Mathematical morphology:◦ A useful tool for extracting image components in

the representation of region shape. Boundaries, skeletons, and convex hull.

Set theory is usually used to describe mathematical morphology.◦ Sets represent objects in a binary image.

Black: representing object, denoted by 1. White: representing background , denoted by 0.

Page 3: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.1 Preliminaries9.1 Preliminaries

• Our interest in this chapter is sets in Z2, where each element denotes the coordinates of an object pixel.– If a=(a1, a2), we write if a is an element in A.

– if a is not an element in A.

• The null or empty set is denoted by .

• We use braces, {·}, to specify the content of a set. For example, C={w|w=-d, for }.

Aa

Aa

Dd

Page 4: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Operations of SetsOperations of Sets

c

c

BABwAwwBA

AwwA

BABA

BwAwwBA

BwAwwBA

} ,|{

} |{

) if exclusivemutually or disjoint be tosaid are and (

} and |{

}or |{

Page 5: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Additional DefinitionsAdditional Definitions

• Translation: –

• Reflection: –

}for ,|{)( AazaccA Z

}for ,|{ˆ BbbwwB

Page 6: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.1.2 Logic Operations Involving Binary Images9.1.2 Logic Operations Involving Binary Images

• The logic operations discussed in this section involve binary images.– Black pixel: 1.– White pixel: 0.

Note: logic operations are restricted to binary variables, which is not the case in general for set operations.

Page 7: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Logic Operations Involving Binary ImagesLogic Operations Involving Binary Images

Page 8: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.2 Dilation and Erosion9.2 Dilation and Erosion

• These two operations are fundamental to morphological processing.

– Dilation: to enlarge an object along its boundary.

– Erosion: to shrink an object into a smaller size.

Page 9: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.2.1 Dilation9.2.1 Dilation

• With A and B are sets in Z2, the dilation of A by B, denoted A B, is defined asA B = – Other interpretation: A B =

• B is commonly referred to as the structuring element.

• The dilation of A by B is the set of all displacements, z, such that the reflection of B and A overlap by at least one element.

})ˆ(|{ ABz z

})ˆ(|{ AABz z

Page 10: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

The Illustration of DilationThe Illustration of Dilation

Page 11: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

The Implementation of DilationThe Implementation of Dilation

• Given a binary image f and the structuring element s, construct a duplicate of f, denoted by g.

• For each pixel p = f(x, y), do the following:– If p is black:

• If p is at the boundary (any of the 4-adjacent neighbors is white) of the object, center the origin of s at (x, y) in g, and fill the pixels black on which s covers.

• Return g.

Page 12: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Application of DilationApplication of Dilation

• One of the simplest applications of dilation is for bridging gaps.

Page 13: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.2.2 Erosion9.2.2 Erosion

• With A and B are sets in Z2, the dilation of A by B, denoted A B, is defined as

A B = – The erosion of A by

B is the set of all points z such that B, translated by z, is contained in A.

})(|{ ABz z

Page 14: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

The Implementation of DilationThe Implementation of Dilation

• Given a binary image f and the structuring element s, construct a duplicate of f, denoted by g.

• For each pixel p = f(x, y), do the following:– If p is white:

• If p is adjacent to the boundary of the object, center the origin of s at (x, y) in g, and fill the pixels white on which s covers.

• Return g.

Page 15: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Application of DilationApplication of Dilation• One of the simplest uses of erosion is for eliminating

irrelevant detail (in terms of size) from a binary image.

Note that objects are represented by white pixels, rather than by black pixels.

Page 16: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.3 Opening and Closing9.3 Opening and Closing

• Opening: to break narrow isthmuses and to eliminate thin protrusions.

• Closing: to fuse narrow breaks and long thin gulfs, to eliminate small holes, and to fill gaps in the contour.

BBABA ) (

BBABA ) (

Page 17: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,
Page 18: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Illustration of Opening and ClosingIllustration of Opening and Closing

Page 19: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Example 9.4: Application of Opening and Closing

Example 9.4: Application of Opening and Closing

Page 20: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.4 The Hit-or-Miss Transformation9.4 The Hit-or-Miss Transformation

• The morphological hit-or-miss transform is a basic tool for shape detection or pattern matching.

• Let B denote the set composed of X and its background.

– B = (B1, B2), where B1=X, B2=W-X.

The match of B in A, denoted by A B, is*

])( [) ( XWAXABA c *

To find objects that may contain X To find objects that may be contained in X

Page 21: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

The Hit-or-Miss TransformationThe Hit-or-Miss Transformation

• Other interpretation:

• If B is 3x3, the matching can be done directly rather than computing the background image.

] [) ( 21 BABABA c*

)ˆ () ( 21 BABABA *

Page 22: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.5 Some Basic Morphological Algorithms9.5 Some Basic Morphological Algorithms

• Boundary extraction

• Region filling

• Extraction of connected components

• Convex Hull

• Thinning

• Skeletons

• Pruning

Page 23: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.5.1 Boundary Extraction9.5.1 Boundary Extraction

• The boundary of a set A, denoted by β(A), can be obtained by first eroding A by B and then performing the set difference between A and its erosion.

Page 24: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Example 9.5: Boundary ExtractionExample 9.5: Boundary Extraction

• Binary 1’s are shown in white and 0’s in black.• Using 5x5 structuring element would result in a

boundary between 2 and 3 pixels thick.

The structuring element in this example is 3x3; therefore, the boundary is one pixel thick.

Page 25: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.5.2 Region Filling9.5.2 Region Filling• Goal: given a point p inside the boundary (Fig. (a)), fill the

entire region with 1’s.

• Let X0 = p. The filled set Xk can be obtained by

...3,2,1 ) ( 1 kABXX ckk

Page 26: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

The Procedure of Region FillingThe Procedure of Region Filling• The algorithm terminates at iteration step k if Xk=Xk-1.

• The result is obtained from the union of Xk and the boundary in A.

Page 27: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.5.3 Extraction of Connected Components9.5.3 Extraction of Connected Components

• Goal: given a point p, find the component that connects to p.

• Let X0 = p. The set Xk can be obtained by

• The algorithm terminates at iteration step k if Xk=Xk-1.

• The result Y is obtained from Xk.

...3,2,1 ) ( 1 kABXX kk

Page 28: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

The Procedure of Finding Connected Components

The Procedure of Finding Connected Components

Page 29: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Example 9.7Example 9.7

Page 30: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.5.4 Convex Hull9.5.4 Convex Hull

• A set A is said to be convex.– If the straight line joining any two points in A lies entirely

within A.

• The convex hull H of a set S is the smallest convex set containing S.

– The set H-S is called the convex difference, which is useful for object description.

• The procedure is to implement the equation:

– With Xi0=A. Let Di=Xi

conv, where “conv” indicates that Xi

k=Xik-1. The convex hull of A is

1,2,3... and 4,3,2,1 ) ( 1 kiABXX ik

ik *

4

1

)(

i

iDAC

Page 31: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Convex HullConvex Hull

Page 32: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Limiting Growth of Convex HullLimiting Growth of Convex Hull

Page 33: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.5.5 Thinning9.5.5 Thinning

• The thinning of a set A by a structuring element B, denoted A B, is defined by

• Each B is usually a sequence of structuring elements:

– B1, B2,…are different rotated versions of B.

• The result of thinning A by one pass is the union of the results obtained by thinning by Bi by one pass.

x

* ) ( BAABA x

},...,,,{}{ 321 nBBBBB

Page 34: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Thinning ProcedureThinning Procedure

Page 35: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.5.6 Thickening9.5.6 Thickening

• The thickening of a set A by a structuring element B, denoted A B, is defined by

• A more efficient scheme is to obtain the complement of A, say Ac, and then to compute Cc, where C is the thinned result of Ac and Cc is its complement.

·

) ( BAABA · *

Page 36: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.5.7 Skeletons9.5.7 Skeletons• The dot line : the skeleton of A, S(A).

}) (|max{

) ()( with )()(0

kBAkK

BkBAASASAS k

K

kk

Page 37: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

The Procedure of SkeletonizationThe Procedure of Skeletonization

Page 38: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.5.8 Pruning9.5.8 Pruning

spur

Page 39: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

The Procedure of PruningThe Procedure of Pruning

• Thinning an input set A to eliminate the short line segment by

• To restore the character to its original form:– Find the set containing all the end points by

– Dilate the end points and find the intersection with A:

– The union of X3 and X1 yields the desired result:

}{1 BAX

8

112 ) (

k

kBXX *

AHXX ) ( 23

314 XXX

Page 40: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.6 Extensions to Gray-Scale Images9.6 Extensions to Gray-Scale Images

• Dilation– Let Df and Db be the domains of f and b, where b is the

structuring element.

• The dilated image tends to be brighter.

• The dark details either reduce or eliminated, depending on their values and shapes relate to the structuring element.

• Erosion

• The eroded image tends to be darker.

• The bright details either reduce or eliminated.

}),(;)(),(|),(),(max{),)(( bf DyxDytxsyxbytxsftsbf

}),(;)(),(|),(),(min{),)( ( bf DyxDytxsyxbytxsftsbf

Page 41: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Example 9.9Example 9.9

Page 42: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.6.3 Opening and Closing9.6.3 Opening and Closing

Page 43: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

Example 9.10 Example 9.10

• In (a), the decreased sizes of the small, bright details, with no appreciable effect on the darker gray levels.

• In (b), the decreased sizes of the small, dark details, with relatively little effect on the bright features.

Page 44: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.6.4 Applications of Gray-Scale Morphology9.6.4 Applications of Gray-Scale Morphology

• Morphological smoothing– i.e. performing opening followed by a closing.

• Morphological gradient– Let g denote the operation, and then

– Depending less on edge directionality.

) ()( bfbfg

Page 45: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.6.4 Applications of Gray-Scale Morphology9.6.4 Applications of Gray-Scale Morphology

• Top-hat transformation

)( bffh

Page 46: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.6.4 Applications of Gray-Scale Morphology9.6.4 Applications of Gray-Scale Morphology

• Textural segmentation– Use closing operation to eliminate the left half.

– Apply opening to restore and join the right half.

– Threshold the result to draw the boundary.

Page 47: Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,

9.6.4 Applications of Gray-Scale Morphology9.6.4 Applications of Gray-Scale Morphology

• Granulometry (粒度測量 )– Apply opening with different sizes of structuring elements.

– Calculate image difference.

– Draw the histogram to evaluate the difference with respect to various sizes of structuring elements.

– For some x, particles with similar size of x have higher responses in the histogram.