R16 4-1 Dip Unit 5
R16 4-1 Dip Unit 5
UNIT-6
Morphological Image Processing
Introduction
The word morphology commonly denotes a branch of biology that deals with the form
and structure of animals and plants. Morphology in image processing is a tool for extracting
image components that are useful in the representation and description of region shape, such
as boundaries and skeletons. Furthermore, the morphological operations can be used for
filtering, thinning and pruning. The language of the Morphology comes from the set theory,
where image objects can be represented by sets.
Some Basic Concepts form Set Theory :
If every element of a set A is also an element of another set B, then A is said to be a
subset of B, denoted as A ⊆ B
The union of two sets A and B, denoted by C = A∪B
The intersection of two sets A and B, denote by D = A∩B
Dilation
Dilation is used for expanding an element A by using structuring element B. Dilation
of A by B and is defined by the following equation:
This equation is based on obtaining the reflection of B about its origin and shifting
this reflection by z. The dilation of A by B is the set of all displacements z, such that and A
overlap by at least one element. Based On this interpretation the equation of (9.2-1) can be
rewritten as:
Dilation is typically applied to binary image, but there are versions that work on gray
scale image. The basic effect of the operator on a binary image is to gradually enlarge the
boundaries of regions of foreground pixels (i.e. white pixels, typically). Thus areas of
foreground pixels grow in size while holes within those regions become smaller.
Any pixel in the output image touched by the dot in the structuring element is set to
ON when any point of the structuring element touches a ON pixel in the original image. This
tends to close up holes in an image by expanding the ON regions. It also makes objects
larger. Note that the result depends upon both the shape of the structuring element and the
location of its origin.
Summary effects of dilation:
Expand/enlarge objects in the image
Fill gaps or bays of insufficient width
Fill small holes of sufficiently small size
Connects objects separated by a distance less than the size of the window
Erosion
Erosion is used for shrinking of element A by using element B. Erosion for Sets A
and B in Z2, is defined by the following equation:
This equation indicates that the erosion of A by B is the set of all points z such that B,
translated by z, is combined in A.
Any pixel in the output image touched by the · in the structuring element is set to ON
when every point of the structuring element touches a ON pixel in the original image. This
tends to makes objects smaller by removing pixels.
Duality between dilation and erosion:
Dilation and erosion are duals of each other with respect to set
complementation and reflection. That is,
Opening:
An erosion followed by a dilation using the same structuring element for both
operations.
Smooth contour
Break narrow isthmuses
Remove thin protrusion
Closing:
A Dilation followed by a erosion using the same structuring element for both
operations.
Smooth contour
Fuse narrow breaks, and long thin gulfs.
Remove small holes, and fill gaps.
Hit-or-Miss Transform:
The hit-and-miss transform is a basic tool for shape detection. The hit-or-miss
transform is a general binary morphological operation that can be used to look for particular
patterns of foreground and background pixels in an image.
Concept: To detect a shape:
Hit object
Miss background
Let the origin of each shape be located at its center of gravity.
If we want to find the location of a shape– X , at (larger) image, A
Let X be enclosed by a small window, say – W.
The local background of X with respect to W is defined as the set difference (W -
X).
Apply erosion operator of A by X, will get us the set of locations of the origin of X,
such that X is completely contained in A.
It may be also view geometrically as the set of all locations of the origin of X at
which X found a match (hit) in A.
Apply erosion operator on the complement of A by the local background set (W – X).
Notice, that the set of locations for which X exactly fits inside A is the intersection of
these two last operators above.
If B denotes the set composed of X and it’s background B = (B1,B2) ; B1 = X ,
B2 = (W-X).
The match (or set of matches) of B in A, denoted as
The structural elements used for Hit-or-miss transforms are an extension to the ones
used with dilation, erosion etc. The structural elements can contain both foreground and
background pixels, rather than just foreground pixels, i.e. both ones and zeros. The
structuring element is superimposed over each pixel in the input image, and if an exact match
is found between the foreground and background pixels in the structuring element and the
image, the input pixel lying below the origin of the structuring element is set to the
foreground pixel value. If it does not match, the input pixel is replaced by the boundary pixel
value.
Basic Morphological Algorithms
Boundary Extraction:
The boundary of a set A is obtained by first eroding A by structuring element B and
then taking the set difference of A and it’s erosion. The resultant image after subtracting the
eroded image from the original image has the boundary of the objects extracted. The
thickness of the boundary depends on the size of the structuring element. The boundary of a
set A is obtained by first eroding A by structuring element B and then taking the set
difference of A and it’s erosion. The resultant image after subtracting the eroded image from
the original image has the boundary of the objects extracted. The thickness of the boundary
depends on the size of the structuring element. The boundary β (A) of a set A is
Convex Hull:
A is said to be convex if a straight line segment joining any two points in A lies
entirely within A.
The convex hull H of set S is the smallest convex set containing S
The set difference H-S is called the convex deficiency of S
The convex hull and convex deficiency useful for object description. This algorithm
iteratively applying the hit-or-miss transforms to A with the first of B element, unions it with
A, and repeated with second element of B.
Let Bi , i=1,2,3,4 represents the four structuring elements. Then we need to
implement the
Let us consider
If
Thinning:
The thinning of a set A by a structuring element B, can be defined by terms of the hit-
and-miss transform:
The process is to thin by one pass with B1, then thin the result with one pass with B2,
and so on until A is thinned with one pass with Bn. The entire process is repeated until no
further changes occur. Each pass is preformed using the equation:
Thickening:
Thickening is a morphological dual of thinning and is defined as
the structuring elements used for thickening have the same form as in thinning, but with all
1’s and 0’s interchanged.
Skeletons:
The skeleton of A is defined by terms of erosions and openings:
with
k times, and K is the last iterative step before A erodes to an empty set in other words:
The S(A) can be obtained as the union of skeleton subsets Sk(A). A can be also
reconstructed from subsets Sk(A) by using the equation
Dilation:
Equation for gray-scale dilation is
Df and Db are domains of f and b. The condition that (s-x),(t-y) need to be in the
domain of f and x,y in the domain of b, is analogous to the condition in the binary definition
of dilation, where the two sets need to overlap by at least one element.
We will illustrate the previous equation in terms of 1-D. and we will receive an
equation for 1 variable:
The requirements the (s-x) is in the domain of f and x is in the domain of b implies
that f and b overlap by at least one element. Unlike the binary case, f, rather than the
structuring element b is shifted. Conceptually f sliding by b is really not different than b
sliding by f. The general effect of performing dilation on a gray scale image is twofold:
If all the values of the structuring elements are positive than the output image tends to
be brighter than the input. Dark details either are reduced or eliminated, depending on how
their values and shape relate to the structuring element used for dilation
Erosion:
Gray-scale erosion is defined as:
The condition that (s+x),(t+y) have to be in the domain of f, and x,y have to be in the
domain of b, is completely analogous to the condition in the binary definition of erosion,
where the structuring element has to be completely combined by the set being eroded. The
same as in erosion we illustrate with 1-D function
The structuring element is rolled underside the surface of f. All the peaks that are
narrow with respect to the diameter of the structuring element will be reduced in amplitude
and sharpness. The initial erosion removes the details, but it also darkens the image. The
subsequent dilation again increases the overall intensity of the image without reintroducing
the details totally removed by erosion.
Opening a G-S picture is describable as pushing object B under the scan-line graph,
while traversing the graph according the curvature of B
Closing:
In the closing of a gray-scale image, we remove small dark details, while relatively
undisturbed overall gray levels and larger dark features
The structuring element is rolled on top of the surface of f. Peaks essentially are left
in their original form (assume that their separation at the narrowest points exceeds the
diameter of the structuring element). The initial dilation removes the dark details and
brightens the image. The subsequent erosion darkens the image without reintroducing the
details totally removed by dilation
Closing a G-S picture is describable as pushing object B on top of the scan-line graph,
while traversing the graph according the curvature of B. The peaks are usually remains in
their original form.
Morphological smoothing
Perform opening followed by a closing
The net result of these two operations is to remove or attenuate both bright and
dark artifacts and noise.
Morphological gradient
Dilation and erosion are use to compute the morphological gradient of an image,
denoted g:
The top-hat transform is used for light objects on a dark background and the bottom-
hat transform is used for the converse.
Textural segmentation:
The objective is to find the boundary between different image regions based on
their textural content.
Close the input image by using successively larger structuring elements.
Then, single opening is preformed ,and finally a simple threshold that yields the
boundary between the textural regions.
Granulometry:
Granulometry is a field that deals principally with Determining the size distribution
of particles in an image.
Because the particles are lighter than the background, we can use a morphological
approach to determine size distribution. To construct at the end a histogram of it.
Based on the idea that opening operations of particular size have the most effect on
regions of the input image that contain particles of similar size.
This type of processing is useful for describing regions with a predominant
particle-like character.
Image Segmentation
Image segmentation divides an image into regions that are connected and have some
similarity within the region and some difference between adjacent regions. The goal is
usually to find individual objects in an image. For the most part there are fundamentally two
kinds of approaches to segmentation: discontinuity and similarity.
Detection of Discontinuities:
There are three kinds of discontinuities of intensity: points, lines and edges. The most
common way to look for discontinuities is to scan a small mask over the image. The mask
determines which kind of discontinuity to look for.
9
R w1 z1 w2 z 2 ... w9 z9 w z
i 1
i i
Point Detection: Whose gray value is significantly different from its background
R T
where T : a nonnegativ e threshold
Line Detection:
Only slightly more common than point detection is to find a one pixel wide line in an
image.
For digital images the only three point straight lines are only horizontal, vertical, or
diagonal (+ or –45).
Edge Detection:
Edge is a set of connected pixels that lie on the boundary between two regions
• ’Local’ concept in contrast to ’more global’ boundary concept
• To be measured by grey-level transitions
• Ideal and blurred edges
First derivative can be used to detect the presence of an edge (if a point is on a ramp).
The sign of the second derivative can be used to determine whether an edge pixel lie
on the dark or light side of an edge
Second derivative produces two value per edge
Zero crossing near the edge midpoint
Non-horizontal edges – define a profile perpendicular to the edge direction
Gradient
– Vector pointing to the direction of maximum rate of change of f at coordinates (x,y)
Gx fx
f f
G y y
– Magnitude: gives the quantity of the increase (some times referred to as gradient too)
f mag (f ) Gx2 Gy2
1
2
Partial derivatives computed through 2x2 or 3x3 masks. Sobel operators introduce
some smoothing and give more importance to the center point
Laplacian
– Second-order derivative of a 2-D function
2 f 2 f
f 2 2
2
x y
– Digital approximations by proper masks
The Laplacian of h is
The Laplacian of a Gaussian sometimes is called the Mexican hat function. It also can
be computed by smoothing the image with the Gaussian smoothing mask, followed by
application of the Laplacian mask.
The Hough transform consists of finding all pairs of values of and which satisfy
the equations that pass through (x,y). These are accumulated in what is basically a
2-dimensional histogram. When plotted these pairs of and will look like a sine wave. The
process is repeated for all appropriate (x,y) locations.
Thresholding:
The range of intensity levels covered by objects of interest is different from the
background.
1 if f ( x, y ) T
g ( x, y )
0 if f ( x, y ) T
Illumination:
There are two main approaches to region-based segmentation: region growing and
region splitting.
Region Growing:
For example: P(Rk)=TRUE if all pixels in Rk have the same gray level.
Region Splitting:
PREVIOUS QUESTIONS
1. With necessary figures, explain the opening and closing operations.
2. Explain the following morphological algorithms i) Boundary extraction ii) Hole
filling.
3. Explain the following morphological algorithms i) Thinning ii) Thickening
4. What is Hit-or-Miss transformation? Explain.
5. Discuss about Grey-scale morphology.
6. Write a short notes on Geometric Transformation
7. Explain about edge detection using gradient operator.
8. What is meant by edge linking? Explain edge linking using local processing
9. Explain edge linking using Hough transform.
10. Describe Watershed segmentation Algorithm
11. Discuss about region based segmentation.
12. Explain the concept of Thresholding in image segmentation and discuss its
merits and limitations.