You are on page 1of 29

Digital Image Processing

Morphology

Basic Morphology Concepts


Mathematical Morphology is based on the algebra of non-linear operators
operating on object shape and in many respects supersedes the linear
algebraic system of convolution.
It performs in many tasks pre-processing, segmentation using object
shape, and object quantification better and more quickly than the
standard approach.
Mathematical morphology tool is different from the usual standard algebra
and calculus.
Morphology tools are implemented in most advanced image analysis.
Mathematical morphology is very often used in applications where shape of
objects and speed is an issueexample: analysis of microscopic images,
industrial inspection, optical character recognition, and document analysis.
The non-morphological approach to image processing is close to calculus,
being based on the point spread function concept and linear
transformations such as convolution.
Mathematical morphology uses tools of non-linear algebra and operates
with point sets, their connectivity and shape.
Morphology operations simplify images, and quantify and preserve the
main shape characteristics of objects.
Morphological operations are used for the following purpose:
Image pre-processing (noise filtering, shape simplification).
Enhancing object structure (skeleton zing, thinning, thickening, convex
hull, object marking).
Segmenting objects from the background.
Quantitative description of objects (area, perimeter, projections, EulerPoincare characteristics).

Mathematical morphology exploits point set properties, results of integral


geometry, and topology.
The real image can be modeled using point sets of any dimension; the
Euclidean 2D space   and its system of subsets is a natural domain for
planar shape description.
Set difference is defined by
\ =   
Computer vision uses the digital counterpart of Euclidean space sets of
integer pairs (  ) for binary image morphology or sets of integer
triples(  ) for gray-scale morphology or binary 3D morphology.
Discrete grid can be defined if the neighborhood relation between points is
well defined. This representation is suitable for both rectangular and
hexagonal grids.
A morphological transformation  is given by the relation of the image
with another small point set B called structuring element. B is expressed
with respect to a local origin .
Structuring element is a small image-used as a moving window-- whose
support delineates pixel neighborhoods in the image plane.
It can be of any shape, size, or connectivity (more than 1 piece, have holes).
To apply the morphological transformation () to the image  means
that the structuring element B is moved systematically across the entire
image.
Assume that B is positioned at some point in the image; the pixel in the
image corresponding to the representative point O of the structuring
element is called the current pixel.
The result of the relation between the image X and the structuring element
B in the current position is stored in the output image in the current image
pixel position.

Fig 1: Typical structuring elements.

The duality of morphological operations is deduced from the existence of


the set complement; for each morphological transformation () there
exists a dual transformation  ()


() =  (  )

The translation of the point set  by the vector is denoted by  ; it is


defined by
 =     ,  =  + !" #!$%   &.

Fig 2: Translation by a vector

Morphological Principles:
1. Compatibility with translation: Let the transformation  depend on the
position of the origin  of the co-ordinate system, and denote such a
transformation by  . If all points are translated by the vector , it is
expressed as ) . The compatibility with translation principle is given by
 ( ) = ) () .

If  does not depend on the position of the origin, then the compatibility
with translation: principle reduces to invariance under translation
( ) = () .
2. Compatibility with change of scale: Let * represent the homothetic
scaling of a point set  (i.e., the co-ordinates of each point of the set are
multiplied by some positive constant *). This is equivalent to change of
scale with respect to some origin. Let + denote a transformation that
depends on the positive parameter * (change of scale). Compatibility with
change of scale is given by
1
+ () = * , .
*
If  does not depend on the scale *, then compatibility with change of
scale reduces to invariance to change of scale
(*) = *()
3. Local knowledge: The local knowledge principle considers the situation in
which only a part of a larger structure can be examinedthis is always the
case in reality, due to the restricted size of the digital grid. The
morphological transformation  satisfies the local knowledge principle if
for any bounded point set / in the transformation () there exists a
bounded set , knowledge of which is sufficient to provide . The local
knowledge principle may be written symbolically as
 ) / = ) / .
4. Upper semi-continuity: The upper semi-continuity principle says that the
morphological transformation does not exhibit any abrupt changes.

Binary Dilation and Erosion


The sets of black and white pixels constitute a description of a binary
image. Assume only black pixels is considered, and the others are treated
as a background.
The primary morphological operations are dilation and erosion, and from
these two, more complex morphological operations such as opening,
closing, and shape decomposition can be constituted.
Dilation
The morphological transformation dilation combines two sets using
vector addition (e.g., (a, b) +(c, d) = (a+c, b+d)).
The dilation  1 is the point set of all possible vector additions of pairs
of elements, one from each of the sets  and 1
 1 =    :  =  + 3,   456 3 1}

Example:
={(1,0),(1,1),(1,2),(2,2),(0,3),(0,4)},
1= {(0, 0), (1, 0)},
 1={(1,0),(1,1),(1,2),(2,2),(0,3),(0,4),(2,0),(2,1),(2,2),(3,2),(1,3),(1,4)}

Fig 3: Dilation

Fig 4 shows 256x256 original image on the left. A structuring element size
3x3 is used.
The result of dilation is shown on the right side of Fig 4. In this case the
dilation is an isotropic expansion (Fill or Grow).

Fig 4: Dilation as isotropic expansion

Dilation with an isotropic 3x3 structuring element might be described as a


transformation which changes all background pixels neighboring the object
to object pixels.
Dilation properties:
Dilation operation is commutative
1 =1
Dilation operation is associative
 (1 7) = ( 1) 7
Dilation may also be expressed as a union of shifted point sets

 1 = 8 9
9:

Invariant to translation
 1 = ( 1)
Dilation is an increasing transformation
;   =%5  1  1
Dilation is used to fill small holes and narrow gulfs in objects. It increases
the object size if the original size needs to be preserved, and then dilation is
combined with erosion.

Fig 5: Dilation where the representative point is not a member of the structuring element.

Fig 5 illustrates the result of dilation if the representative point is not a


member of the structuring element B, if this structuring element is used;
the dilation result is substantially different from the input set.
Erosion
Erosion combines two sets using vector subtraction of set elements and
is dual operator of dilation.
 1 =    :  =  + 3  !" %?%"@ 3  1}.

This formula says that every point  from the image is tested; the result of
the erosion is given by those points  for which all possible  + 3 are in X.
Example:

={(1,0),(1,1),(1,2),(0,3),(1,3),(2,3),(3,3),(1,4)},
1= {(0, 0), (1, 0)},
 1= {(0, 3), (1, 3), (2, 3)}.

Fig 6: Erosion

The result of the erosion is shown in the right side of the Fig 7. Erosion with
an isotropic structuring element is called as shrink or reduce.

Fig 7: Erosion as isotropic shrink

Basic morphological transformations can be used to find the contours of


objects in an image very quickly. This can be achieved, for instance, by
subtraction from the original picture of its eroded version as in Fig 8.

Fig 8: Contours obtained by subtraction of an eroded image from the original (left).

Erosion is used to simplify the structure of an object. It decomposes


complicated object into several simple ones.
The equivalent definition for erosion
 1 =    : 1A }.
The erosion might be interpreted by structuring element 1 sliding across
the image ; then, if 1 translated by the vector  is contained in the
image , the point corresponding to the representative point 1 belongs to
the erosion  1.
An implementation of erosion might be simplified by noting that an
image  eroded by the structuring element 1 can be expressed as an
intersection of all translations of the image  by the vector 3 1

 1 = B )9 .
9:

If the representative point is a member of the structuring element, then


erosion is an anti-extensive transformation; that is, if(0,0) 1, then 
1 .
Erosion properties:
Erosion is translation invariant
 1 = ( 1) ,
 1 = ( 1)) ,
Erosion as increasing transformation:
E   =%5  1  1
Erosion and dilation are dual transformations
( ) =   F .
Erosion is not commutative
 1 1 .
Erosion and intersection combined together
( ) 1 = ( 1) ( 1),
1 ( ) (1 ) (1 ).
Image intersection and dilation cannot be interchanged; the dilation of the
intersection of two images is contained in the intersection of their dilations
( ) 1 = 1 ( ) ( 1) ( 1).
The order of erosion may be interchanged with set union. This fact enables
the structuring element to be decomposed into a union of simpler
structuring elements
1 ( ) = ( ) 1 = ( 1) ( 1),
( ) 1 ( 1) ( 1),
1 ( ) = ( 1) ( 1).

Successive dilation of the image  first by the structuring element 1 and


then by the structuring element 7 is equivalent to the dilation of the image
X by 1 7
( 1) 7 =  (1 7),
( 1) 7 =  (1 7).

Hit-or-miss transformation
Hit-or-miss transformation is the morphological operator for finding local
patterns of pixels, where local means the size of the structuring element.
It is a variant of template matching that finds collections of pixels with
certain shape properties.
Structuring element 1, Tested points X, operation denoted by a pair of
disjoint sets 1 = (1J , 1 ), called a composite structuring element.
The Hit-or-miss transformation is defined as
 1 = : 1J  456 1   }.
Finding local patterns in image 1J tests objects, 1 background
(complement), Useful for finding corners, for instance.
The hit-or-miss transformation operates as a binary matching between an
image  and the structuring element(1J , 1 ). It may be expressed using
erosions and dilations as well
M ).
 1 = ( 1J ) (  1 ) = ( 1J )( 1
Opening and closing
Erosion and dilation are not inverse transformationif an image is eroded
and then dilated, the original image is not re-obtained.
Erosion followed by dilation is called opening. The opening of an image 
by the structuring element 1 is denoted by  1 and is defined as
 1 = (X B) B.

Dilation followed by erosion is called Closing. The closing of an image  by


the structuring element 1 is denoted by  1 and is defined as
 1 = ( 1) 1.
If an image  is unchanged by opening with the structuring element 1 , it is
called open with respect to 1 . Similarly , if an image  is unchanged by
closing with 1 , it is called as closed with respect to 1.
Opening and closing with an isotropic structuring element is used to
eliminate specific image details smaller than the structuring elementthe
global shape of the objects is not distorted.
Closing connects objects that are close to each other, fills up small holes,
and smoothes the object outline by filling up narrow gulfs.

Fig 9: Opening (original on left)

Fig 10: Closing (original on left)

Opening and closing are invariant to translation of the structuring element.


Opening is anti-extensive ( 1 ) and closing is extensive (  1).
Opening and closing are dual transformations
( 1) =   1F.
Iteratively used opening and closings are idempotent, meaning that
reapplication of these transformations does not change the previous result.
 1 = ( 1) 1,
 1 = ( 1) 1.

Gray scale dilation and erosion


Binary morphological operations are extendible to gray-scale images using
the min and max operations.
Erosion assigns to each pixel minimum value in a neighborhood of
corresponding pixel in input image
structuring element is richer than in binary case
structuring element is a function of two variables, specifies
desired local gray-level property
Value of structuring element is subtracted when minimum is
calculated in the neighborhood.
Dilation assigns maximum value in neighborhood of corresponding pixel
in input image
value of structuring element is added when maximum is
calculated in the neighborhood
Such extension permits topographic view of gray scale images
Gray-level is interpreted as height of a particular location of a
hypothetical landscape
Light and dark spots in the image correspond to hills and
valleys
Such morphological approach permits the location of global
properties of the images as valleys, mountain ridges (crests),
watersheds.

Top surface, Umbra, and gray-scale dilation and erosion


Consider a point set P in 5 -dimensional Euclidean space, P R
Assume first (5 1) co-ordinates of the set constitute a spatial domain
and the 5S co-ordinate corresponds to the value of a function or functions
at a point.
The top surface of a set P is a function defined on the (5 1) dimensional
support.
For each (5 1) tuple, the top surface is the highest value of the last coordinate of P (Fig 11).

Fig 11: Top surface of the set P corresponds to maximal values of the function (J ,  )

Let P R and the support T =  R)J !" #!$% @  , (, @)P}. The
Top surface of P , denoted by U[P], is a mapping T defined as
U[P]() = max@, (, @) P}.

Umbra of a function
1) dimensional space.

defined on some subset T (support) of (5

Umbra is a region of complete shadow resulting from obstructing the light


by a non-transparent object.
In mathematical morphology, the umbra of is a set that consists of the
top surface of and everything below it (Fig 12).

Fig 12: Umbra of the top surface of a set is the whole subspace below it.

Let T R)J and : T .The umbra of , denoted by \[ ], \[ ] T


, is defined by
\[ ] = (, @) T , @ ()}.
Umbra of an umbra of is an umbra.
Top surface and umbra in the case of a simple 1D gray scale image (Fig 13)

Fig 13: Example of a 1D function (left) and its umbra (right).

The gray-scale dilation of two functions as the top surface of the dilation of
their umbras can be defined.
Let T, _ R)J 456 : T 456 `: _ . The dilation of
3@ `, `: T _ is defined by
` = U\[ ] \[`]}.
on the left-hand side is dilation in the gray-scale image,
on the left-hand side is dilation of binary image.
No new symbol is introduced here, same applies to erosion also.
For binary dilation, one function, say
represents an image and the
second, ` small structuring element. Fig 14 shows the function ` that will
play the role of structuring element.
Fig 15 shows the dilation of the umbra of by the umbra of ` .

Fig 14: A structuring element: 1D function (left) and its umbra (right).

Fig 15: 1D example of gray-scale dilation. The umbras of the 1D function and structuring
element ` are dilated first, \[ ] \[`] . The top surface of this dilated set gives the result,
`=U\[ ] \[`]}.

A computationally plausible way to calculate dilation can be obtained by


taking the maximum of set of sums:
( `)() = max ( a) + `(a), a _,  a T}.
The computational complexity is the same as for convolution in linear
filtering, where a summation of products is performed.
The definition of gray-scale erosion is analogous to gray-scale dilation. The
gray-scale erosion of two functions(point sets)
Takes their umbras.
Erodes them using binary erosion.
Gives the result as the top surface.
Let T, _ R)J 456 : T 456 `: _ . The erosion of 3@ `,
`: T _ is defined by
` = U\[ ] \[`]}.
To decrease computational complexity, the actual computations are
performed in another way as the minimum of a set of differences:
( `)() = min ( + a) `(a)}.
de

Fig 16:1D example of gray-scale erosion: The umbras of 1D function and the structuring
element ` are eroded first, [ ] \[`] . The top surface of this eroded set gives the result,
` = U\[ ] \[`]}.

Example (Fig 17)


This figure illustrates morphological pre-processing on a microscopic image
of cells corrupted by noise.
The aim is to reduce noise and locate individual cells.
A 3x3 structuring element was used in erosion and dilation.
The individual cells can be located by the reconstruction operation .The
original image is used as a mask and the dilated image is an input for
reconstruction.

Fig 17: Morphological pre-processing: (a)cells in a microscopic image corrupted by


notes;(b)Eroded image;(c)Dilation of original image;(d)Reconstructed cells.

Umbra homeomorphism theorem, properties of erosion and dilation, opening


and closing.
The Umbra homeomorphism theorem states that the umbra operation is a
homeomorphism from gray-scale morphology to binary morphology.
Let T, _ R)J 456 : T 456 `: _ . Then
(a) \[ `] = \[ ] \[`],
(b) \[ `] = \[ ] \[`].
The umbra homeomorphism is used for deriving properties of gray-scale
operations.
Gray-scale opening is defined as ` = ( `) `.
Gray-scale closing is defined as ` = ( `) `.
The duality between opening and closing is expressed as
( `)() = f( ) `F g ().
The opening of f by structuring element k can be interpreted as sliding k on
the landscape f. The position of all highest points reached by some part of k
during the slide gives the opening, similar interpretation exists for erosion
Gray-scale opening and closing often used to extract parts of a gray-scale
image with given shape and gray-scale structure.
Top hat transformation
The top hat transformation is used as a simple tool for segmenting objects
in gray-scale images that differ in brightness from background, even when
the background is of uneven gray-scale.
The top hat transform is superseded by the watershed segmentation for
more complicated backgrounds.
Assume a gray-level image  and a structuring element _. The residue of
opening as compared to original image  ( _) constitutes a new
useful operation called a Top hat transformation.

The top hat transformation is a good tool for extracting light objects on a
dark but slowly changing background. Those parts of the image that cannot
fit into structuring element _ are removed by opening.
Subtracting the opened image from the original provides an image where
removed objects stand out.
The actual segmentation can be performed by simple thresholding (Fig 18).
If an image were a hat, the transformation would extract only the top of it,
provided that the structuring element is larger than the hole in the hat.

Fig 18:The top hat transform permits the extraction of light objects from an uneven
background.

Example from visual industrial inspection


A factory producing glass capillaries for mercury maximal thermometers
had the following problem:
The thin glass tube should be narrowed in one particular place to prevent
mercuryfalling back when the temperature decreases from the maximal
value. This is done by using a narrow gas flame and low pressure in the
capillary.

The capillary is illuminated by a collimated light beamwhen the capillary


wall collapses due to heat and low pressure, an instant specular reflection
is observed and serves as a trigger to cover the gas flame.
Originally the machine was controlled by a human operator who looked at
the tube image projected optically on the screen; the gas flame was
covered when the specular reflection was observed.
This task had to be automated and the trigger signal learned from a
digitized image. The specular reflection is detected by a morphological
procedure (Fig 19).

Fig 19: An industrial example of gray-scale opening and top hat segmentation, i.e., image based control
of glass tube narrowing by gas flame. (a)Original image of the glass tube, 512x256 pixels. (b)Erosion by a
one-pixel-wide vertical structuring element 20 pixels long. (c)Opening with the same element. (d)Final
specular reflection segementation by the top hat transformation.

Morphology segmentation and watersheds


Particles segmentation, marking, watersheds:
Finding objects of interest in the image is called as segmentation.
Mathematical morphology helps mainly to segment images of texture or
images of particles in which the input image can be either binary or grayscale.
In the binary case, the task is to segment overlapping particles; in the grayscale case, the segmentation is the same as object contour extraction.
Morphological particle segmentation is performed in two basic steps:
Location of particle markers
Watersheds used for particle reconstruction
The marker of an object or set X is a set M that is included in X. Markers
have the same homotopy as the set X, and are typically located in the
central part of the object.
Application specific knowledge should be used for marker-finding
technique.
Object marking in many cases left to user, who marks objects manually on
the screen.
When the objects are marked, they can be grown from the markers, e.g.,
using watershed transformation, which is motivated by the topographic
view of images.
Consider the analogy of a landscape and rain; water will find the swiftest
descent path until it reaches some lake or sea.
The landscape can be entirely partitioned into regions which attract water
to a particular sea or lakethese will be called catchment basins.
These regions are influence zones of the regional minima in the image.
Watersheds, also called watershed lines, separate catchment basins.
Watersheds and catchment basins are illustrated in the below figure:

Fig 20: Illustration of catchment basins and watersheds in a 3D landscape view.

Binary morphological segmentation


The top hat transformation method is used to find the objects that differ in
brightness from an uneven background.
The top hat approach just finds peaks in the image function that differ from
the local background.
The gray-level shape of the peaks does not play any role, but the shape of
the structuring element does. Watershed segmentation takes into account
both sources of information and supersedes the top hat method.
Morphological segmentation in binary images aims to find regions
corresponding to individual overlapping objects.
Each particle is marked firstultimate erosion may be used for this
purpose, or markers may be placed manually.
The next task is to grow objects from the markers provided they are kept
within the limits of the original set and parts of objects are not joined when
they come close to each other.
The oldest technique for this purpose is called conditional dilation. Ordinary
dilation is used for growing, and the result is constrained by the two
conditions.
Geodesic reconstruction is more sophisticated and performs much faster
than conditional dilation. The structuring element adapts according to the
neighborhood of the processed pixel.

Geodesic influence zones are sometimes used for segmenting particles.

Fig 21: Segmentation by geodesic influence zones(SKIZ) need not lead to correct result.

The original binary image is converted into gray scale using the negative
distance transform. If a drop of waterfalls onto a topographic surface of the
dist image, it follows the steepest slope towards a regional minimum (Fig
22).

Fig 22: Segmentation of binary particles. (a)Input binary images. (b)Gray scale image created from (a)
using the dist function. (c) Topographic notion of the catchment basin. (d) Correctly segmented
particles using watersheds of image (b).

Application of watershed particle segmentation is shown in Fig 23. We


selected an image of a few touching particles as an input Fig 23(a).
The distance function calculated from the background is visualized using
contours in Fig 23(b).
The regional maxima of the distance function serve as markers of the
individual particles (Fig 23(c)).
In preparation for watershed segmentation, the distance function is
negated, and is shown together with the dilated markers (Fig 23(d)).

Fig 23: (a) Original binary image (b) level lines distance function (c) maxima of distance function
(d) Watersheds of inverted distance function

Gray-scale segmentation, watersheds


The markers and watersheds method can also be applied to gray-scale
segmentation. Watersheds are also used as crest-line extractors in grayscale images.
The contour of a region in a gray-level image corresponds to points in the
image where gray-levels change most quicklythis is analogous to edge
based segmentation.

The watershed transformation is applied to the gradient magnitude (Fig


24).
Algebraic difference of unit-size dilation and unit-size erosion of the input
image X
j"46() = ( 1) ( 1).

Fig 24:Segmentation in gray-scale images using gradient magnitude.

The main problem with segmentation via gradient images without markers
is over-segmentation, meaning that the image is partitioned into too many
regions.
The watershed segmentation methods do not suffer from oversegmentation.
The below Fig will illustrate the application of watershed segmentation.

Fig 25: Watershed segmentation (a) Original image. (b) Dots are superimposed markers found
by non morphological methods. (c) Modified gradient. (d) Watersheds from markers (b).

Example Image:

Fig 26: Illustration of segmentation method

You might also like