10-1 - morphological image processing

13
4/22/2009 1 Morphological Image Processing: Basic Concepts Spring 2009 1 ELEN 4304/5365 DIP by Gleb V. Tcheslavski: [email protected] http://ee.lamar.edu/gleb/dip/index.htm 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 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-scale Spring 2009 2 ELEN 4304/5365 DIP are elements of 2D space and then extend it to gray scale images.

Upload: neeti-saurav-pahuja

Post on 21-Jan-2016

60 views

Category:

Documents


1 download

DESCRIPTION

morphological image processing

TRANSCRIPT

Page 1: 10-1 - Morphological Image Processing

4/22/2009

1

MorphologicalImage Processing: Basic Concepts

Spring 2009 1ELEN 4304/5365 DIP

by Gleb V. Tcheslavski: [email protected]

http://ee.lamar.edu/gleb/dip/index.htm

Preliminaries We understand mathematical morphology as a tool for extracting image components that are useful in the representation and description of region shape, such asrepresentation 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-scale

Spring 2009 2ELEN 4304/5365 DIP

are elements of 2D space and then extend it to gray scale images.

Page 2: 10-1 - Morphological Image Processing

4/22/2009

2

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.

Spring 2009 3ELEN 4304/5365 DIP

In addition to basic set theory definitions, the reflection of a set B is defined as:

{ }ˆ | ,B w w b for b B= = − ∈

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

( ) { }| ,z

B c c b z for b B= = + ∈

If B is the set of

Spring 2009 4ELEN 4304/5365 DIP

pixels, (B)z is the set of points, whose coordinates (x, y) were replaced by (x+z1, y+z2).

Page 3: 10-1 - Morphological Image Processing

4/22/2009

3

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 SEThe origins of SEs are marked by a black dot

Spring 2009 5ELEN 4304/5365 DIP

marked by a black dot.When working with images, SEs should be rectangular: append the smallest number of background elements.

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

Spring 2009 6ELEN 4304/5365 DIP

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.

Page 4: 10-1 - Morphological Image Processing

4/22/2009

4

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

( ){ }|z

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

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 to “B not sharing any common elements with the

Spring 2009 7ELEN 4304/5365 DIP

q g ybackground”, the erosion can be expressed in the following form:

( ){ }| cz

A B z B A= ∩ = ∅

where Ac is the complement of A and ∅ is the empty set.

ErosionSet A, structuring element B, and erosion of A by B. Boundary ofof A by B. Boundary of set A is shown by the dotted border.

Elongated structuring element B and erosion of A by B. the original set

Spring 2009 8ELEN 4304/5365 DIP

y gwas eroded to a line.

Keep in mind that the erosion is a set of values of z such that satisfy the erosion equations.

Page 5: 10-1 - Morphological Image Processing

4/22/2009

5

ErosionUsing erosion to remove image components:A 486x486 binary image of a wire bond mask andof a wire-bond mask and images eroded using square SEs of sizes 11x11, 15x15, and 45x45 whose components were all ones.T ti l li

Spring 2009 9ELEN 4304/5365 DIP

Two vertical lines were tinned but not removed since their width was greater than 11.Erosion shrinks objects.

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

( ){ }ˆ|A B z B A⊕ = ∩ ≠ ∅( ){ }|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 displacements z, such that and A overlap by at least one element. Therefore, the dilation can also be expressed as

( ){ }ˆ⎡ ⎤

Spring 2009 10ELEN 4304/5365 DIP

( ){ }|z

A B z B A A⎡ ⎤⊕ = ∩ ⊆⎣ ⎦As before, we assume that B is a structuring element and A is the set (image object) to be dilated.

Page 6: 10-1 - Morphological Image Processing

4/22/2009

6

Dilation 

There are other definitions of dilation too. However, the preceding equations are more intuitive when viewing the t t l l t l ti k W d t kstructural element as a convolution mask. We need to keep

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 The manner and extend of this growth is

Spring 2009 11ELEN 4304/5365 DIP

in a binary image. The manner and extend of this growth is controlled by the structuring element.

Dilation Set A, structuring element B, and dilation of A by B.Boundary of set A is shownBoundary of set A is shown by the dotted border. Since the SE is symmetric about its origin, B̂ B=

Structuring element Bdesigned to achieve more

Spring 2009 12ELEN 4304/5365 DIP

des g ed o c eve o edilation vertically than horizontally; and the dilation achieved by it.

Page 7: 10-1 - Morphological Image Processing

4/22/2009

7

Dilation One of the simplest application for dil ti idilation is bridging gaps.Brocken character image with max length of gaps 2 pixels.

Spring 2009 13ELEN 4304/5365 DIP

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.

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

( ) ˆc cA B A B⊕( )( ) ˆ

c

c c

A B A B

A B A B

= ⊕

⊕ =

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 useful when the SE is symmetric with respectˆ

Spring 2009 14ELEN 4304/5365 DIP

Duality is particularly useful when the SE is symmetric with respect 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.

B̂ B=

Page 8: 10-1 - Morphological Image Processing

4/22/2009

8

DualityTo prove the validity of duality principle, we start with the erosion definition:

( ) ( ){ }|cc

zA B z B A= ⊆

If set (B)z is contained in A, then and

( ) ( ){ }|z

( ) cz

B A∩ = ∅

( ) ( ){ }|cc c

zA B z B A= ∩ = ∅

But the complement of the set of z’s satisfying the previous equation is such that

{ } ˆ

Spring 2009 15ELEN 4304/5365 DIP

( ) ( ){ } ˆ|c c cz

A B z B A A B= ∩ ≠ ∅ = ⊕

Opening and closingAs we’ve seen, dilation expands the components of an image while the erosion shrinks them.Opening generally smoothes the contour of an object and eliminateOpening 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

Spring 2009 16ELEN 4304/5365 DIP

( )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.

Page 9: 10-1 - Morphological Image Processing

4/22/2009

9

Opening and closingSimilarly, 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 f h i i

Spring 2009 17ELEN 4304/5365 DIP

of the opening is 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.

Opening and closingThe 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:obtained by taking the union of all translates of B that fit into A:

( ) ( ){ }|z z

A B B B A= ⊆∪where U{.} denotes the union of all sets inside the braces.Closing has a similar geometric interpretation, except that we roll Bon the outside of the boundary.

Spring 2009 18ELEN 4304/5365 DIP

Page 10: 10-1 - Morphological Image Processing

4/22/2009

10

Opening and closingA 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.

Spring 2009 19ELEN 4304/5365 DIP

Dilation of A by B.

Erosion of the set A dilated by B.The result is closing of A by B.

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

( ) ( )ˆc cA B A B( ) ( )( ) ( )ˆ

c c

c c

A B A B

A B A B

• =

= •

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

Spring 2009 20ELEN 4304/5365 DIP

2) If C is a subset of D, then C ◦ B is a subset of D ◦ B.3) (A ◦ B) ◦ B = A ◦ B.

Page 11: 10-1 - Morphological Image Processing

4/22/2009

11

Opening and closingThe closing operation satisfies the following properties:1) A is a subset (subimage) of closing of A by B.2) If C i b f D h C B i b f D B2) If C is a subset of D, then C • B is a subset of 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.

Spring 2009 21ELEN 4304/5365 DIP

Morphological operations can be used to construct filters conceptually similar to the spatial filters.

Opening and closingA binary image corrupted with noise.

A structuring element

Eroded imageEroded image

Opening of A(dilation of eroded image)

Spring 2009 22ELEN 4304/5365 DIP

Dilation of the opening

Closing of the opening

Page 12: 10-1 - Morphological Image Processing

4/22/2009

12

Opening and closingThe background noise was eliminated during erosion since all noisecomponents were smaller than the structuring element. Dark spots –noise elements contained within the fingerprint increased in size. Thisg penlargement was countered by performing dilation that reduced orcompletely deleted this noise.These operations are equivalent to opening, whose effect was toeliminate almost all noise in image. However, new gaps between thefingerprint ridges were created. To counter this effect, a dilation onthe opening was performed.

Spring 2009 23ELEN 4304/5365 DIP

the opening was performed.Most of the breaks were restored but the ridges were thickened, whichcan be remedied by erosion. The result is equivalent to closing of theopening.

The Hit‐or‐Miss transformationThe 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 Dwith respect to W.Complement of A and erosion of A by D.Erosion of Ac by (W – D)

Spring 2009 24ELEN 4304/5365 DIP

Erosion of A 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.

Page 13: 10-1 - Morphological Image Processing

4/22/2009

13

The Hit‐or‐Miss transformationWe 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 suchThe erosion of A by D is the set of locations of the origin of 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

Spring 2009 25ELEN 4304/5365 DIP

(or matches) of B in A is

( ) ( )cA B A D A W D⎡ ⎤⊗ = ∩ −⎣ ⎦

The Hit‐or‐Miss transformationGeneralizing 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 background. In p g gour case B1 = D and B2 = (W-D). Therefore:

( ) ( )1 2cA B A B A B⊗ = ∩

Therefore, the set A⊗B 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:

Spring 2009 26ELEN 4304/5365 DIP

complement of A. The definition can also be rewritten as follows:

( ) ( )1 2A B A B A B⊗ = − ⊕

The set A⊗B represents the morphological hit-or-miss transform.