You are on page 1of 13

4/22/2009

Morphological ImageProcessing: BasicConcepts


byGlebV.Tcheslavski:gleb@ee.lamar.edu http://ee.lamar.edu/gleb/dip/index.htm
Spring2009 ELEN4304/5365DIP 1

Preliminaries
We understand mathematical morphology as a tool for extracting image components that are useful in the representation and description of region shape, such as boundaries, skeletons, etc. We are also interested in morphological techniques for pre- and post-processing, such as morphological filtering, thinning, and pruning. We start discussion on binary images, whose components are elements of 2D space and then extend it to gray gray-scale scale images.

Spring2009

ELEN4304/5365DIP

4/22/2009

Preliminaries
Morphology is formulated in terms of set theory. Sets represent objects in an image; for instance, the set of all white pixels in a binary image is a complete morphological description of an image. In binary images, the sets are members of the 2D integer space Z2, where each element of a set is a tuple (2D vector) whose coordinates are the (x, y) coordinates of a white (or black) pixel in the image. Gray-scale images can be represented as sets, whose components are in Z3: two components are coordinates of a pixel, and the third its discrete intensity value. In addition to basic set theory definitions, the reflection of a set B is defined as:

= {w | w = b, for b B} B
ELEN4304/5365DIP

Spring2009

Preliminaries
If B is a set of pixels (2D points) representing an object in an image, then its reflection is the set of points in B, whose (x, y) coordinates have been replaced by (-x, -y) as shown: The translation of a set B by point z = (z1, z2), denoted (B)z is defined as

( B ) z = {c | c = b + z,

for b B}

If B is the set of pixels, (B)z is the set of points, whose coordinates (x, y) were replaced by (x+z1, y+z2).
Spring2009 ELEN4304/5365DIP 4

4/22/2009

Preliminaries
Reflection and transmission are used extensively to formulate operations based on so-called structuring elements (SEs): small sets of subimages used to probe an analyzed image for properties of interest. Examples of structuring elements: shaded square denotes a member of the SE The origins of SEs are marked by a black dot dot. When working with images, SEs should be rectangular: append the smallest number of background elements.
Spring2009 ELEN4304/5365DIP 5

Preliminaries
A set Structuring element

A set padded by background el-ts to form a rectangular array SE as an array Set processed by SE The operation: create a new set by running B over A such that the origin of B visits every element of A; at each location of the origin of B, if B is completely contained in A, mark that location as a member of a new set. As a result, the boundary of A is eroded.
Spring2009 ELEN4304/5365DIP 6

4/22/2009

Erosion
With A and B as sets in Z2, the erosion of A by B is defined as

A B = { z | ( B ) z A}

The erosion of A by B is the set of all points z such that B, translated by z, is contained in A. We will assume that the set B is a structuring element. In the previous example (slide 6), since B had to be contained in A is equivalent q to B not sharing g any y common elements with the background, the erosion can be expressed in the following form:

A B = { z | ( B ) z Ac = }
where Ac is the complement of A and is the empty set.
Spring2009 ELEN4304/5365DIP 7

Erosion
Set A, structuring element B, and erosion of A by B. Boundary of set A is shown by the dotted border. Elongated structuring element B and erosion of A by y B. the original g set was eroded to a line. Keep in mind that the erosion is a set of values of z such that satisfy the erosion equations.
Spring2009 ELEN4304/5365DIP 8

4/22/2009

Erosion
Using erosion to remove image components: A 486x486 binary image of a wire-bond wire bond mask and images eroded using square SEs of sizes 11x11, 15x15, and 45x45 whose components were all ones. Two vertical T ti l lines li were tinned but not removed since their width was greater than 11. Erosion shrinks objects.
Spring2009 ELEN4304/5365DIP 9

Dilation
With A and B as sets in Z2, the dilation of A by B is defined as

A A B = z | B
z

{ ()

This equation is based on reflecting B about its origin, and shifting this reflection by z. The dilation of A by B then is the set of all and A overlap by at least one element. displacements z, such that B Therefore, the dilation can also be expressed as

A A A B = z | B z

( )

As before, we assume that B is a structuring element and A is the set (image object) to be dilated.
Spring2009 ELEN4304/5365DIP 10

4/22/2009

Dilation
There are other definitions of dilation too. However, the preceding equations are more intuitive when viewing the structural t t l element l t as a convolution l ti mask. k We W need d to t keep k in mind that dilation is based on set operations and therefore is a nonlinear operation, while the convolution is linear. Unlike the erosion, dilation grows or thickens objects in a binary image. image The manner and extend of this growth is controlled by the structuring element.

Spring2009

ELEN4304/5365DIP

11

Dilation
Set A, structuring element B, and dilation of A by B. Boundary of set A is shown by the dotted border. Since the SE is symmetric about =B its origin, B Structuring element B designed des g ed to o achieve c eve more oe dilation vertically than horizontally; and the dilation achieved by it.

Spring2009

ELEN4304/5365DIP

12

4/22/2009

Dilation
One of the simplest application for dil ti is dilation i bridging gaps. Brocken character image with max length of gaps 2 pixels. The structuring element B used Gaps were bridged with the advantage that the morphological methods result in binary image as opposite to gray-scale image that would be produced by LPF.
Spring2009 ELEN4304/5365DIP 13

Duality
Erosion and dilation are duals of each other with respect to set complementation and reflection:

( A B ) = Ac B c ( A B ) = Ac B
c

Indicating that erosion of A by B is the complement of the dilation of the complement of A by the reflection of B and vice versa. Duality is particularly when the SE is symmetric with respect useful B = B to its origin, so that . Then we can obtain the erosion of an image by B simply by dilating its background (complement of A) with the same structuring element and complementing the result.

Spring2009

ELEN4304/5365DIP

14

4/22/2009

Duality
To prove the validity of duality principle, we start with the erosion definition: c c ( A B ) = { z | ( B ) z A}
c If set (B)z is contained in A, then ( B ) z A = and

( A B)

= { z | ( B ) z Ac = }

But the complement of the set of zs satisfying the previous equation is such that

( A B)

= { z | ( B ) z Ac } = Ac B

Spring2009

ELEN4304/5365DIP

15

Openingandclosing
As weve seen, dilation expands the components of an image while the erosion shrinks them. Opening generally smoothes the contour of an object and eliminate thin protrusions. Closing also tends to smooth sections of contours but fusing narrow breaks and long, thin gulfs and eliminating small holes and filling gaps in the contour. The opening of a set A by structuring element B is defined as

A B = ( A B) B
Therefore, the opening A by B is the erosion of A by B, followed by a dilation of the result by B.
Spring2009 ELEN4304/5365DIP 16

4/22/2009

Openingandclosing
Similarly, the closing of a set A by structuring element B is defined as

A B = ( A B) B
Therefore, the closing of A by B is the dilation of A by B, followed by the erosion of the result by B. Supposing that B is a flat rolling ball. Then, the boundary of f the h opening i is i determined by the points in B that reach the farthest into the boundary of A as B is rolled around the inside of this boundary.
Spring2009 ELEN4304/5365DIP 17

Openingandclosing
The geometric fitting property of the opening operation leads to a set-theoretic formulation stating that the opening of A by B can be obtained by taking the union of all translates of B that fit into A:

A B = {( B ) z | ( B ) z A}
where U{.} denotes the union of all sets inside the braces. Closing has a similar geometric interpretation, except that we roll B on the outside of the boundary.

Spring2009

ELEN4304/5365DIP

18

4/22/2009

Openingandclosing
A set A; the structuring element is a disc. Erosion of A by B. Dilation of the set A eroded by B. The result is opening of A by B. Dilation of A by B. Erosion of the set A dilated by B. The result is closing of A by B.
Spring2009 ELEN4304/5365DIP 19

Openingandclosing
Opening and closing are also duals of each other with respect to set complementation and reflection. Therefore:

( A B) (A
B)

( ) ) =(A B
= Ac B
c

The opening operation satisfies the following properties: 1) Opening of A by B is a subset (subimage) of A. 2) If C is i a subset b of f D, then h C B is i a subset b of f D B. 3) (A B) B = A B.

Spring2009

ELEN4304/5365DIP

20

10

4/22/2009

Openingandclosing
The closing operation satisfies the following properties: 1) A is a subset (subimage) of closing of A by B. 2) If C is i a subset b of f D, then h C B is i a subset b of f D B. 3) (A B) B = A B. The last condition in both cases states that multiple openings or closings of a set have no effect after the operator has been applied once. Morphological operations can be used to construct filters conceptually similar to the spatial filters.

Spring2009

ELEN4304/5365DIP

21

Openingandclosing
A binary image corrupted with noise. A structuring element Eroded image Opening of A (dilation of eroded image)

Dilation of the opening Closing of the opening


Spring2009 ELEN4304/5365DIP 22

11

4/22/2009

Openingandclosing
The background noise was eliminated during erosion since all noise components were smaller than the structuring element. Dark spots noise elements contained within the fingerprint g p increased in size. This enlargement was countered by performing dilation that reduced or completely deleted this noise. These operations are equivalent to opening, whose effect was to eliminate almost all noise in image. However, new gaps between the fingerprint ridges were created. To counter this effect, a dilation on the opening was performed. Most of the breaks were restored but the ridges were thickened, which can be remedied by erosion. The result is equivalent to closing of the opening.
Spring2009 ELEN4304/5365DIP 23

TheHitorMisstransformation
The morphological hit-or-miss transformation is a basic tool for shape detection. A set A consisting of 3 sets C, D, E. A window W; local background of D with respect to W. Complement of A and erosion of A by D. Erosion of Ac by (W D). ) Intersection of two erosions showing the location of the origin of D. The objective of the processing was to find the location of one of the shapes D.
Spring2009 ELEN4304/5365DIP 24

12

4/22/2009

TheHitorMisstransformation
We enclose D by a small window W; the local background of D with respect to W is defined as the set difference W D. The erosion of A by D is the set of locations of the origin of D, D such that D is completely contained in A. The intersection of the erosion of the complement of A by the local background set W-D and the erosion of A by D is the set of locations for which D exactly fits inside A. Denoting by B the set consisting of D and its background, the match (or matches) of B in A is
c A B = ( A D) A (W D )

Spring2009

ELEN4304/5365DIP

25

TheHitorMisstransformation
Generalizing the notation by letting B = (B1, B2), where B1 is the set formed from the elements of B associated with an object and B2 is the set of elements of B associated with the corresponding p g background. g In our case B1 = D and B2 = (W-D). Therefore:

A B = ( A B1 ) ( Ac B2 )

Therefore, the set AB contains all the points (origin) at which simultaneously B1 found a match (hit) in A; and B2 found a match in complement of A. The definition can also be rewritten as follows:

A B = ( A B1 ) ( A B2 )
The set AB represents the morphological hit-or-miss transform.
Spring2009 ELEN4304/5365DIP 26

13

You might also like