0% found this document useful (0 votes)
133 views

Explain Following Morphological Methods With Examples

The document discusses and provides examples of several morphological image processing methods: 1) Boundary extraction subtracts the eroded image from the original to extract pixel differences. 2) Region/hole filling iteratively dilates the image using a structuring element to fill hollow regions. 3) Connected component labeling groups pixels into components based on connectivity and labels them. 4) Thinning iteratively removes foreground pixels to reduce lines to single pixel thickness while preserving length. 5) Thickening grows selected foreground regions using dilation to determine shapes like convex hulls.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views

Explain Following Morphological Methods With Examples

The document discusses and provides examples of several morphological image processing methods: 1) Boundary extraction subtracts the eroded image from the original to extract pixel differences. 2) Region/hole filling iteratively dilates the image using a structuring element to fill hollow regions. 3) Connected component labeling groups pixels into components based on connectivity and labels them. 4) Thinning iteratively removes foreground pixels to reduce lines to single pixel thickness while preserving length. 5) Thickening grows selected foreground regions using dilation to determine shapes like convex hulls.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

1. Explain following morphological methods with examples.

a. Boundary Extraction
If A is an image and structuring element is B Then Boundary Extraction can be
given as, Boundary (A) = A - (A Ɵ B)
It means subtracting the erode image of A form the original Image.
Let A =

If B=

Then AƟB would be same as A except one pixel, A Ɵ B =

Now Boundary (A) =


Hence, it would give a pixel difference.

b. region/Hole Filling
It fills the hollow portion of the image.
Xk=(Xk−1⊗B) ∩ ACk=1,2,3,…..
To start the procedure of region filling, we start with a pixel p and assign a value 1
to it.
Then apply the above formula to it, X0=p and B is the structuring element.

Consider the example A=

We start with pixel p inside the boundary. Let p=1


Therefore, X0=p
Now according to formula, Xk=(Xk−1⊗B) ∩ ACk=1,2,3,…..
Therefore, X_1= (X_0 \0 times B)∩A^C i.e. X1 is X0 dilated by B which is then
intersected by the complement of A Similarly,
X2=(X1⊗B) ∩AC
We continue to use the formula till Xk = Xk−1.
X1=(X0⊗B)∩AC
Similarly=1,2,3…..,we get the final output

X5=(X4⊗B) ∩AC
Since, X5=X4(Xk=Xk−1.) we stop the algorithm here.
Therefore, Xk=X4
The final step is finding the union of image A and X4X4
AUXk=A∩X4AUXk=A∩X4
c. Extraction of Connected Components
Connected components labeling scans an image and groups its pixels into
components based on pixel connectivity, i.e. all pixels in a connected
component share similar pixel intensity values and are in some way connected
with each other. Once all groups have been determined, each pixel is labeled
with a graylevel or a color (color labeling) according to the component it was
assigned to.

Extracting and labeling of various disjoint and connected components in an


image is central to many automated image analysis applications.

Connected component labeling works by scanning an image, pixel-by-pixel (from


top to bottom and left to right) in order to identify connected pixel
regions, i.e. regions of adjacent pixels which share the same set of intensity
values V. (For a binary image V= {1}; however, in a gray level image V will take on
a range of values, for example: V={51, 52, 53, ..., 77, 78, 79, 80}.)

Connected component labeling works on binary or gray level images and different


measures of connectivity are possible. However, for the following we assume
binary input images and 8-connectivity. The connected components labeling
operator scans the image by moving along a row until it comes to a
point p (where p denotes the pixel to be labeled at any stage in the scanning
process) for which V= {1}. When this is true, it examines the four neighbors
of p which have already been encountered in the scan (i.e. the neighbors (I) to the
left of p, (ii) above it, and (iii and iv) the two upper diagonal terms). Based on this
information, the labeling of p occurs as follows:

 If all four neighbors are 0, assign a new label to p, else


 if only one neighbor has V= {1}, assign its label to p, else
 if more than one of the neighbors have V= {1}, assign one of the labels
to p and make a note of the equivalences.

After completing the scan, the equivalent label pairs are sorted into equivalence
classes and a unique label is assigned to each class. As a final step, a second scan
is made through the image, during which each label is replaced by the label
assigned to its equivalence classes. For display, the labels might be different gray
levels or colors.

d. Thinning
Thinning is a morphological operation that is used to remove selected foreground
pixels from binary images, somewhat like erosion or opening. It can be used for
several applications, but is particularly useful for skeletonization. In this mode it is
commonly used to tidy up the output of edge detectors by reducing all lines to
single pixel thickness. Thinning is normally only applied to binary images, and
produces another binary image as output.

The thinning operation is related to the hit-and-miss transform, and so it is helpful


to have an understanding of that operator before reading on.

Implementation.

Like other morphological operators, the behavior of the thinning operation is


determined by a structuring element. The binary structuring elements used for
thinning are of the extended type described under the hit-and-miss
transform (i.e. they can contain both ones and zeros).
The thinning operation is related to the hit-and-miss transform and can be
expressed quite simply in terms of it. The thinning of an image I by a structuring
element J is:

where the subtraction is a logical subtraction defined by ,

In everyday terms, the thinning operation is calculated by translating the origin of


the structuring element to each possible pixel position in the image, and at each
such position comparing it with the underlying image pixels. If the foreground and
background pixels in the structuring element exactly match foreground and
background pixels in the image, then the image pixel underneath the origin of the
structuring element is set to background (zero). Otherwise it is left unchanged.
Note that the structuring element must always have a one or a blank at its origin
if it is to have any effect.

The choice of structuring element determines under what situations a foreground


pixel will be set to background, and hence it determines the application for the
thinning operation.

We have described the effects of a single pass of a thinning operation over the
image. In fact, the operator is normally applied repeatedly until it causes no
further changes to the image (i.e. until convergence). Alternatively, in some
applications, e.g. pruning, the operations may only be applied for a limited
number of iterations.

Thinning is the dual of thickening, i.e. thickening the foreground is equivalent to


thinning the background.

One of the most common uses of thinning is to reduce the thresholded output of


an edge detector such as the Sobel operator, to lines of a single pixel thickness,
while preserving the full length of those lines (i.e. pixels at the extreme ends of
lines should not be affected). A simple algorithm for doing this is the following:
Consider all pixels on the boundaries of foreground regions (i.e. foreground
points that have at least one background neighbor). Delete any such point
that has more than one foreground neighbor, as long as doing so does
not locally disconnect (i.e. split into two) the region containing that pixel.
Iterate until convergence.

This procedure erodes away the boundaries of foreground objects as much as


possible, but does not affect pixels at the ends of lines.

This effect can be achieved using morphological thinning by iterating until


convergence with the structuring elements shown in Figure 1, and all
their 90° rotations (4×2 = 8 structuring elements in total).

In fact what we are doing here is determining the octagonal skeleton of a binary


shape --- the set of points that lie at the centers of octagons that fit entirely inside
the shape, and which touch the boundary of the shape at at least two points. See
the section on skeletonization for more details on skeletons and on other ways of
computing it. Note that this skeletonization method is guaranteed to produce a
connected skeleton.

Figure 1.
Structuring elements for skeletonization by morphological thinning. At each
iteration, the image is first thinned by the left hand structuring element,
and then by the right hand one, and then with the remaining
six 90° rotations of the two elements. The process is repeated in cyclic
fashion until none of the thinnings produces any further change. As usual,
the origin of the structuring element is at the center.
Figure 2

shows the result of this thinning operation on a simple binary image.

Figure 2 
Example skeletonization by morphological thinning of a simple binary
shape, using the above structuring elements. Note that the resulting
skeleton is connected.

Note that skeletons produced by this method often contain undesirable short
spurs produced by small irregularities in the boundary of the original object.
These spurs can be removed by a process called pruning, which is in fact just
another sort of thinning. The structuring element for this operation is shown in
Figure 3, along with some other common structuring elements.
Figure 3 Some applications of thinning. 1 simply finds the boundary of a
binary object, i.e. it deletes any foreground points that don't have at least
one neighboring background point. Note that the detected boundary is 4-
connected. 2 does the same thing but produces an 8-
connected boundary. 3a and 3b are used for pruning. At each thinning
iteration, each element must be used in each of its four 90° rotations.
Pruning is normally carried out for only a limited number of iterations to
remove short spurs, since pruning until convergence will actually remove all
pixels except those that form closed loops.

e. Thickening
Thickening is a morphological operation that is used to grow selected regions of
foreground pixels in binary images, somewhat like dilation or closing. It has
several applications, including determining the approximate convex hull of a
shape, and determining the skeleton by zone of influence. Thickening is normally
only applied to binary images, and it produces another binary image as output.

The thickening operation is related to the hit-and-miss transform, and so it is


helpful to have an understanding of that operator before reading on.

Implementation.

Like other morphological operators, the behavior of the thickening operation is


determined by a structuring element. The binary structuring elements used for
thickening are of the extended type described under the hit-and-miss
transform (i.e. they can contain both ones and zeros).

The thickening operation is related to the hit-and-miss transform and can be


expressed quite simply in terms of it. The thickening of an image I by a structuring
element J is:
Thus the thickened image consists of the original image plus any additional
foreground pixels switched on by the hit-and-miss transform.

In everyday terms, the thickening operation is calculated by translating the origin


of the structuring element to each possible pixel position in the image, and at
each such position comparing it with the underlying image pixels. If the
foreground and background pixels in the structuring element exactly
match foreground and background pixels in the image, then the image pixel
underneath the origin of the structuring element is set to foreground (one).
Otherwise it is left unchanged. Note that the structuring element must always
have a zero or a blank at its origin if it is to have any effect.

The choice of structuring element determines under what situations a


background pixel will be set to foreground, and hence it determines the
application for the thickening operation.

We have described the effects of a single pass of a thickening operation over the
image. In fact, the operator is normally applied repeatedly until it causes no
further changes to the image (i.e. until convergence). Alternatively, in some
applications, the operations may only be applied for a limited number of
iterations.

Thickening is the dual of thinning, i.e. thinning the foreground is equivalent to


thickening the background. In fact, in most cases thickening is performed by
thinning the background.

We will illustrate thickening with two applications, determining the convex hull,


and finding the skeleton by zone of influence or SKIZ.

The convex hull of a binary shape can be visualized quite easily by imagining


stretching an elastic band around the shape. The elastic band will follow the
convex contours of the shape, but will `bridge' the concave contours. The
resulting shape will have no concavities and contains the original shape. Where an
image contains multiple disconnected shapes, the convex hull algorithm will
determine the convex hull of each shape, but will not connect disconnected
shapes, unless their convex hulls happen to overlap (e.g. two interlocked `U'-
shapes).

An approximate convex hull can be computed using thickening with the


structuring elements shown in Figure 1. The convex hull computed using this
method is actually a `45° convex hull' approximation, in which the boundaries of
the convex hull must have orientations that are multiples of 45°. Note that this
computation can be very slow.

Figure 1
Structuring elements for determining the convex hull using thickening.
During each iteration of the thickening, each element should be used in
turn, and then in each of their 90° rotations, giving 8 effective structuring
elements in total. The thickening is continued until no further changes
occur, at which point the convex hull is complete.

The image

is containing a number of cross-shaped binary objects

Applying the 45° convex hull algorithm described above results in


This process took a considerable amount of time --- over 100 thickening passes
with each of the eight structuring elements!

Another application of thickening is to determine the skeleton by zone of


influence, or SKIZ. The SKIZ is a skeletal structure that divides an image into
regions, each of which contains just one of the distinct objects in the image. The
boundaries are drawn such that all points within a particular boundary are closer
to the binary object contained within that boundary than to any other. As with
normal skeletons, various possible distance metrics can be used. The SKIZ is also
sometimes called the Voronoi diagram.

One method of calculating the SKIZ is to first determine the skeleton of the
background, and then prune this until convergence to remove all branches except
those forming closed loops, or those intersecting the image boundary. Both of
these concepts are described (applied to foreground objects) under thinning.
Since thickening is the dual of thinning, we can accomplish the same thing using
thickening. The structuring elements used in the two processes are shown in
Figure 2.

Figure 2
 Structuring elements used in determining the SKIZ. 1a and 1b are used to
perform the skeletonization of the background. Note that these elements
are just the duals of the corresponding skeletonization by thinning
elements. On each thickening iteration, each element is used in turn, and in
each of its 90° rotations. Thickening is continued until convergence. When
this is finished, structuring elements 2a and 2b are used in similar fashion
to prune the skeleton until convergence and leave behind the SKIZ.
f. Skeletons
Skeletonization is a process for reducing foreground regions in a binary image to a
skeletal remnant that largely preserves the extent and connectivity of the original
region while throwing away most of the original foreground pixels. To see how this
works, imagine that the foreground regions in the input binary image are made of
some uniform slow-burning material. Light fires simultaneously at all points along
the boundary of this region and watch the fire move into the interior. At points
where the fire traveling from two different boundaries meets itself, the fire will
extinguish itself and the points at which this happens form the so called `quench
line'. This line is the skeleton. Under this definition it is clear that thinning produces a
sort of skeleton.

Another way to think about the skeleton is as the loci of centers of bi-tangent circles
that fit entirely within the foreground region being considered. Figure 1 illustrates
this for a rectangular shape.

Figure 1  Skeleton of a rectangle defined in terms of bi-tangent circles.


The terms medial axis transform (MAT) and skeletonization are often used
interchangeably but we will distinguish between them slightly. The skeleton is simply
a binary image showing the simple skeleton. The MAT on the other hand is a gray
level image where each point on the skeleton has an intensity which represents its
distance to a boundary in the original object.

Implementation
The skeleton/MAT can be produced in two main ways. The first is to use some kind
of morphological thinning that successively erodes away pixels from the boundary
(while preserving the end points of line segments) until no more thinning is possible,
at which point what is left approximates the skeleton. The alternative method is to
first calculate the distance transform of the image. The skeleton then lies along
the singularities (i.e. creases or curvature discontinuities) in the distance transform.
This latter approach is more suited to calculating the MAT since the MAT is the same
as the distance transform but with all points off the skeleton suppressed to zero.

Note: The MAT is often described as being the `locus of local maxima' on the
distance transform. This is not really true in any normal sense of the phrase `local
maximum'. If the distance transform is displayed as a 3-D surface plot with the third
dimension representing the gray value, the MAT can be imagined as the ridges on
the 3-D surface.

Just as there are many different types of distance transform there are many types of
skeletonization algorithm, all of which produce slightly different results. However,
the general effects are all similar, as are the uses to which the skeletons are put.

The skeleton is useful because it provides a simple and compact representation of a


shape that preserves many of the topological and size characteristics of the original
shape. Thus, for instance, we can get a rough idea of the length of a shape by
considering just the end points of the skeleton and finding the maximally separated
pair of end points on the skeleton. Similarly, we can distinguish many qualitatively
different shapes from one another on the basis of how many `triple points' there
are, i.e. points where at least three branches of the skeleton meet.

In addition, to this, the MAT (not the pure skeleton) has the property that it can be
used to exactly reconstruct the original shape if necessary.

As with thinning, slight irregularities in a boundary will lead to spurious spurs in the
final image which may interfere with recognition processes based on the topological
properties of the skeleton. Despurring or pruning can be carried out to remove spurs
of less than a certain length but this is not always effective since small perturbations
in the boundary of an image can lead to large spurs in the skeleton.

Note that some implementations of skeletonization algorithms produce skeletons


that are not guaranteed to be continuous, even if the shape they are derived from is.
This is due to the fact that the algorithms must of necessity run on a discrete grid.
The MAT is actually the locus of slope discontinuities in the distance transform.

Here are some example skeletons and MATs produced from simple shapes. Note that
the MATs have been contrast-stretched in order to make them more visible.

Starting with

Skeleton is

MAT is

Starting with

Skeleton is
MAT is

Starting with

Skeleton is

MAT is

Starting with

Skeleton is

MAT is
The skeleton and the MAT are often very sensitive to small changes in the object. If,
for example, the above rectangle changes to

the corresponding skeleton becomes

Using a different algorithm which does not guarantee a connected skeleton yields

Sometimes this sensitivity might be useful. Often, however, we need to extract


the binary image from a grayscale image. In these cases, it is often difficult to obtain
the ideal shape of the object so that the skeleton becomes rather complex. We
illustrate this using

To obtain a binary image we threshold the image at a value of 100, thus obtaining


The skeleton of the binary image, shown in

is much more complex than the one we would obtain from the ideal shape of the
telephone receiver. This example shows that simple thresholding is often not
sufficient to produce a useful binary image. Some further processing might be
necessary before skeletonizing the image.

The skeleton is also very sensitive to noise. To illustrate this we add some `pepper
noise' to the above rectangle, thus obtaining

As can be seen in

the corresponding skeleton connects each noise point to the skeleton obtained from
the noise free image.

g. Pruning
The pruning algorithm is a technique used in digital image processing based
on mathematical morphology. It is used as a complement to the skeleton and
thinning algorithms to remove unwanted parasitic components (spurs). In this
case 'parasitic' components refer to branches of a line which are not key to the
overall shape of the line and should be removed. These components can often be
created by edge detection algorithms or digitization. Common uses for pruning
include automatic recognition of hand-printed characters. Often inconsistency in
letter writing creates unwanted spurs that need to be eliminated for better
characterization.

The standard pruning algorithm will remove all branches shorter than a given
number of points. If a parasitic branch is shorter than four points and we run the
algorithm with n = 4 the branch will be removed. The second step ensures that
the main trunks of each line are not shortened by the procedure.
Structuring Elements
The x in the arrays indicates a “don’t care” condition i.e. the image could have
either a 1 or a 0 in the spot.
Step 1: Thinning
Apply this step a given (n) times to eliminate any branch with (n) or less pixels.
Step 2: Find End Point
Wherever the structuring elements are satisfied, the center of the 3x3 matrix is
considered an endpoint.

You might also like