0% found this document useful (0 votes)
29 views28 pages

Morphological Processing

Image processing
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)
29 views28 pages

Morphological Processing

Image processing
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/ 28

Lecture No.:7 Digital Image Processing Asst. Prof.Dr.

Tariq Al-Juboori

Morphological processing
1. Introduction :
 The word morphology signifies the study of the form or structure.
 Mathematical morphology is a tool used for extracting image components
based on properties of form or shape within the image.
 The language of Mathematical morphology is set theory.
 A unified and powerful method to solve numerous processing problems.

2.Binarv images: foreground, background, and connectedness :


 A binary image is an image in which each pixel assumes one of only two possible
discrete, logical values: 1 or 0.
 Pixels in a binary image having logical value 1 as the image foreground pixels,
whilst those pixels having logical value 0 are called the image background pixels.
 An object in a binary image consists of any group of connected pixels.
 Two definitions of connection between pixels are commonly used:
A) If we require that a given foreground pixel must have at least one neighboring
foreground pixel to the north, south, east, or west of itself to be considered as part
of the same object, then we are using 4-connection.
B) If, however, a neighboring foreground pixel to the north-east, north-west,
south-east or south-west is sufficient for it to be considered as part of the same
object, then we are using 8- connection. These simple concepts are illustrated in
Figure1.

1
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Figure 1. The binary image depicted above contains two objects (groups of connected pixels)
under 8-connectedness but three objects under 4-connectedness

Example 1-: A (8x8) binary image is given below, which objects of the foreground
pixel values give 4-and 8-connected?

 Properties of interest in binary images are the shape, size and location of the
objects in the image.
 Foreground or background pixel has its value changed depending on three
things; Two of them are the image and the type of morphological operation.
The third factor is called the structuring element and is a key element in any
morphological operation.

2
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

3. Structuring elements and neighborhoods


The structuring element is the entity which determines exactly which
image pixels surrounding the given foreground/background pixel must be
considered to make the decision to change its value or not.

Properties and procedure:

 It is a rectangular array of pixels containing values either I or 0.


 Structuring elements have a designated center pixel. This is located at
the true center pixel when both dimensions are odd (e.g., in 3x3 or
5x5 structuring elements).When either dimension is even, the center
pixel is chosen to be that pixel north, north-west, or west (i.e., above
and/or to the left) of the geometric center (thus, a 4x3, 3 × 4∧¿ 4x4
structuring element would all have centerpixels at location [2,2]) as
figure 2;

Figure 2. Some examples of morphological structuring elements. The center


pixel of each
structuring element is shaded.
 Visualize the center pixel of the structuring element being placed
directly above the pixel under consideration in the image, then the
neighborhood of that pixel is determined by those pixels which lie
underneath those pixels having value 1 in the structuring element as

figure below.

6
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Figure 3. The local neighborhood is defined by a structuring element. This is given by


those shaded pixels in the image which lie bencath the pixels of value 1 in the
structuring element.

·The art in morphological processing is to choose the structuring element to suit the application or
the required aim.

4.Dilation and Erosion


 Erosion: To perform erosion of a binary image, place the center pixel
of the structuring element on each foreground pixel (value 1). If any
of the neighborhood pixels are background pixels (value 0), then the
foreground pixel is switched to background. Formally, the erosion of
image A by structuring element B is denoted (A B)
 Dilation: To perform dilation of a binary image, place the center
pixel of the structuring element o cash background pixel. If any of
the neighborhood pixels are foreground pixels (value 1), then the
background pixel is switched to foreground. Formally, the dilation of
image A by structuring element B is denoted (A B).

Where A is a general image and B an arbitrary structuring element and


speak of the erosion/dilation of A by B.

Example 2:- What is the Erosion morphological operation. Apply


application areas of each of them. Consider the binary image and
structuring element as shown below;

6
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

6
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Example 3:- What is the Dilation morphological operation. Apply application


areas of each of them. Consider the binary image and structuring element as

6
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

shown below;

6
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Example 4:- Repeat example (3) with new structuring elements as shown below;

6
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

A B

Solution:

(a) (b) (c)

Figure 4. Morphological operation (a) Erosion;(b) original image; (c) Dilation.

5. Effects and uses of erosion and dilation


It is apparent that erosion reduces the size of a binary object, whereas dilation
increases it. Erosion has the effect of removing small, isolated features, of
breaking apart thin, joining regions in a feature and of reducing the size of solid

6
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

objects by 'eroding' them at the boundaries. Dilation has an approximately


reverse effect, broadening and thickening. narrow regions and growing the
feature around its edges. Dilation and erosion are the reverse of each other,
although they are not inverses in the strict mathematical sense. This is because
we cannot restore by dilation an object which has previously been completely
removed by erosion. Whether it is dilation or erosion (or both) that is of
interest, we stress that the appropriate choice of structuring element is often
crucial and will depend strongly on the application. It can be seeked to contrive
structuring elements which are sensitive to specific shapes or structures and,
therefore, identify, enhance or delete them.

Figure 5. Using dilation and erosion to identify features based on shape: (a) original; (b)
result after thresholding; (c) After erosion with horizontal line, (d) after erosion with
vertical line,(e) after dilation with same vertical and horizontal lines, (f) boundary of
remaining objects superimposed on original

6. Application of erosion to particle sizing


Another simple but effective use of erosion is in granulometry-the
counting and sizing of granules or small particles. This finds use in several
automated inspections applications. Procedure:

6
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

 Counting the total number of objects present.


 The image is repeatedly eroded using the same structuring element
until no objects remain.
 Record the total number of objects F which have been removed from
the image as a function of the number of erosions n.
 The number of erosions required to make an object vanish is directly
proportional to its size;thus, if the object disappears at the kth
erosion, size is X ≈ αk .
 Form an estimate of F(X) which is a cumulative distribution function
(CDF)of particle size, and the probability density function (PDF).

dF
F (X )=∫ ❑ p(x )dx p(x )= ¿
x
dX x

Figure 6.Using repeated erosion and object counting to estimate the distribution of
particle sizes:

(a) original image; (b) binary image resulting from intensity thresholding; (c) estimated
cumulative

distribution (unnormalized); (d) estimated size density function (unnormalized).

7.Morphological opening and closing

6
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

 Opening is the name given to the morphological operation of erosion


followed by dilation with the same structuring element. We denote
the opening of A by structuring element B as A ∘ B=( A Θ B)⊕ B .
The general effect of opening is to remove small, isolated objects
from the foreground of an image, placing them in the background. It
tends to smooth the contour of a binary object and breaks narrow
joining regions in an object.
 Closing is the name given to the morphological operation of dilation
followed by erosion with the same structuring element. We denote
the closing of A by structuring element B as A ⋅ B=(A ⊕ B)Θ B .
 Closing tends to remove small holes in the foreground, changing
small regions of background into foreground. It tends to join narrow
isthmuses between objects.

Example 5:-What is the opening morphological operation. Apply


application areas of each of them. Consider the binary image and
structuring element as shown below;

(
A B)
B=
B
A

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 1 0 0

0 0 1 0 0 0 1 1 1 0

0 0 0 0 0 0 0 1 0 0
6

0 0 0 0 0 0 0 0 0 0
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Example 6:-What is the closing morphological operation. Apply application areas of each of them. Consider
the binary image and structuring element as shown below;

0 0 0 0 0 0

0 0 1 0 0 0

0 1 1 1 1 0

0 0 1 0 0 0

0 0 0 0 0 0

AB
Solution:

0 0 1 1 0 0 0 0 0 0 0 0
A B= (A B)
0 1 1 1 1 0 0 0 1 1 0 0
B=
0 1 1 1 1 0 0 1 1 1 1 0

0 1 1 1 1 0 14 0 0 1 1 0 0

0 0 1 1 0 0 0 0 0 0 0 0
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

8. The rolling-ball analogy


The best way to illustrate the difference between morphological opening and closing is
to use the 'rolling ball' analogy. Let us suppose for a moment that the structuring element B
is a flat (i.e., 2-D) rolling ball and the object A being opened corresponds to a simple binary
object in the shape of a hexagon, as indicated in Figure 8.Imagine the ball rolling around
freely within A but constrained to always stay inside its boundary.The set of all points within
object A which can be reached by B as it rolls around in this way belongs in the opening of
A with B. the rolling-ball analogy to define the closing of A by B. The analogy is the same,
except that this time we roll structuring element B all the way around the outer boundary of
object A. The resulting contour defines the boundary of the closed object A·B.

Figure 7. The opening of object A by structuring element B, AoB (left). The closing of object A by

structuring element B, A·B (right).

14
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Figure 8. Illustrating the effects of opening and closing upon some example shapes. The original image
shown in the center was opened using disk-shaped structuring elements of radii 3, 5 and 15 pixels,
producing the images to the left. The images to the right were similarly produced by closing the image using
the same structuring elements. The differences become more pronounced the larger the structuring element
employed.

9. Boundary extraction
The boundary can be defined of an object by first eroding the object with a suitable small
structuring element and then subtracting the result from the original image .Thus ,for a
binary image A and a structuring element B, the boundary Ap is defined as:

Ap= A−( A Θ B)

Figure .9 Boundary extraction. Left: original.; center: single-pixel boundary; right:thick boundary

extraction through use of larger structuring element.

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

10. Extracting connected components: The set of all pixels which are connected to a
given pixel is called the connected component of that pixel. The process of extracting
connected components leads to a new image in which the connected groups of pixels (the
objects) are given sequential integer values: the background has value 0, the pixels in the
first object have value 1, the pixels in the second object have value 2 and so on. To identify
and label 8-connected components in a binary image, we proceed as follows:

 Scan the entire image by moving sequentially along the rows from top to bottom.
 Whenever we arrive at a foreground pixel p we examine the four neighbors of p
which have already been encountered thus far in the scan. These are the neighbor’s (i)
to the left of p, (ii) above p, (iii) the upper left diagonal and (iv) the upper right
diagonal.

- The labelling of p occurs as follows:

. if all four neighbors are background (i.e. have value 0), assign a new label to p; else

. if only one neighbour is foreground (i.e. has value 1), assign its label to p; else

. if more than one of the neighbours is foreground, assign one of the labels to p and resolve

the equivalences.

- The iterative procedure is as follows.

Let A denote our image, x o be an arbitrary foreground pixel identified at the beginning of

the procedure, x k the set of connected pixels existing at the kth iteration and B be a

structuring element. Apply the following iterative expression:

The algorithm thus starts by dilating from a single pixel within the connected component

using the structuring element B. At each iteration, the intersection with A ensures that no

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

pixels are included which do not belong to the connected component. When we reach the

point at which a given iteration produces the same connected component as the previous

iteration (i.e. x k =x k 1), all pixels belonging to the connected component have been found.

A simple example is given in Figure 8.12.

Figure 8.12 Connected components labelling. The image displayed on the left is a binary image

containing five connected components or objects. The image displayed on the right is a ‘label matrix’

in which the first group of connected pixels is assigned a value of 1, the second group a value of 2 and

so on. The false-colour bar indicates the numerical values used.

11. Region filling:


Binary images usually arise in image processing applications as the result of thresholding or
some other segmentation procedure on an input grey-scale or colour image. These
procedures may leave ‘holes’, i.e. ‘background’ pixels. Assume that we have a binary object
A within which lies one or more background pixels (a hole).

Let B be a structuring element and let x o be a ‘seed’ background pixel lying within the hole.
Setting x o to be foreground (value 1) to initialize the procedure, the hole may be filled by
applying the following iterative expression:

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

The filled region is then obtained as A U x k . The algorithm thus works by identifying a point
( x o) within the hole and then growing this region by successive dilations. After each dilation,
we take the intersection (logical AND) with the logical complement of the object A. When
the region has grown to the extent that it touches the boundary at all points, the next iteration
will grow the region into the boundary itself. However, the intersection with A will produce
the same pixel set as the previous iteration, at which point the algorithm stops.

In the final step, the union of A with the grown region gives the entire filled object. The
complete set of pixels belonging to all holes is then obtained as The seed
pixels x o for the hole-filling procedure described by Equation (8.3) can
thus be obtained by:

(i) sampling arbitrarily from H;

(ii) applying Equation (8.3) to fill in the hole;

(iii) removing the set of filled pixels resulting from step (ii) from H; (iv) repeating (i)–(iii)
until H is empty.

12. The hit-or-miss transformation : The hit-or-miss transform indicates the


positions where a certain pattern (characterized by a structuring element B) occurs in the
input image. As such, it operates as a basic tool for shape detection. Consider Figure 8.13, in
which ‘target’ pixel configuration B (foreground pixels are shaded). It is important to stress
that we are seeking the correct combination of both foreground (shaded) and background
(white) pixels, not just the foreground, and will refer to this combination of foreground and
background as the target shape, it is readily apparent that the erosion of image A by the
target shape B1 will preserve all those pixels in image A at which the foreground pixels of
the target B1 can be entirely contained within foreground pixels in the image. These points
are indicated in Figure 8.14 as asterisks and are designated as ‘hits’. In terms of our goal of
finding the precise target shape B1, the hits thus identify all locations at which the correct
configuration of foreground pixels are found.

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Figure 8.13 The hit-or-miss transformation. The aim is to identify those locations within an image

(right) at which the specified target configuration of pixels or target shape (left) occurs.

Figure 8.14 The hit-or-miss transformation. The first step is erosion of the image by the target

configuration. This produces the hits denoted by asterisks

Figure 8.15. show the logical complement of image A together with a target pixel
configuration B2 which is the logical complement of B1 (i.e. B2= B1).

Consider now applying erosion of the image complement A by the complement of the target
shape B2. By definition, this erosion will preserve all those pixels at which the foreground
pixels of the target complement B2 can be entirely contained within the foreground pixels of
the image complement A. These points are indicated in Figure 8.16

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Figure 8.15 The hit-or-miss transformation. For the second step where we locate the misses, we

consider the complement of the image A and the complement of the target shape B2 = B1

Figure 8.16 The hit-or-miss transformation. The second step consists of eroding the complement of

the image A by the complement of the target shape (B2 = B1). This produces the misses denoted here

by crosses.

as crosses and are designated as ‘misses’. Note, however, that because we have carried out

the erosion using the complements of the target and image. Second step logically translates
to the identification of all those locations at which the background pixel configuration of the
target is entirely contained within the background of the image. The misses thus identify all
locations at which the correct configuration of background pixels are found but does not test
for the required configuration of foreground pixels.

The first step has identified all those points in the image foreground at which the required

configuration of foreground pixels in the target may be found (but has ignored the required
background configuration). By contrast, the second step has identified all those points in
the image background at which the required configuration of background pixels in the target

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

may be found (but has ignored the required foreground configuration). Third step take a
logical intersection (AND) of the two images. Thus, the hit-or-miss transformation of A by
B1 is formally defined as:

The result obtained for our example is indicated in Figure 8.17. The sole surviving pixel

(shaded) gives the only location of the target shape to be found in the image.

Figure 8.17 The hit-or-miss transformation. The final step takes the intersection (logical AND) of

the two eroded images . Any surviving pixels give the location of the target shape in the original image A.

Figure 8.18 illustrate the use of the hit-and-miss transform to identify the occurrences of a
target letter ‘e’ in a string of text.

Figure 8.18 Application of the hit-or-miss transformation to detect a target shape in a string of

text. Note that the target includes the background and hit-or-miss is strictly sensitive to both the

scale and the orientation of the target shape (See colour plate section for colour version).

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

This means that only exact examples of the target shape (including background and
foreground pixel configurations) are identified. If even one pixel of the configuration probed
in the image differs from the target shape, then the hit-or-miss transform we have used will
not identify it (see Figure 8.19).

Figure 8.19 The fully constrained hit-or-miss transform is sensitive to noise and uncontrolled

variations in the target feature. In the example above, three instances of the target letter .e. on the

second line were missed due to the presence of a small amount of random noise in the image.

13. Relaxing constraints in hit-or-miss: ‘don’t care’ pixels:


The application of the hit-or-miss transformation as carried out in Figure 8.19 is
‘unforgiving’, since a discrepancy of even one pixel between the target shape and the probed
region in the image will result in the target shape being missed. We can achieve this
relaxation of the exact match criterion through the use of ‘don’t care’ pixels (also known as
wild-card pixels). In other words, the target shape now conceptually comprises three types
of pixel: strict foreground 1, strict background 2 and ‘don’t care’ 3. In the simple example
shown in Figure 8.20 we consider the task of automatically locating the ‘upper right corners’
in a sample of shapes, we consider two definitions for upper right corner pixels:.

(1) A strict definition which requires that an ‘upper right corner pixel’ must have no
neighbours to north, north-west, north-east or east (these are the misses) and must have

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

neighbours to the south and west (these are the hits). The south-west neighbour is neither hit
nor miss and, thus, a don’t care pixel.

(2) A looser definition which only requires that an upper right corner pixel must have no

neighbours to north, north-west and north-east (the misses). All other neighbours are

‘don’t care’ pixels.

Figure 8.20 Generalizing the hit-or-miss transform. This illustrates the effect of relaxing constraints

on the hit-or-miss transform. Top left: original image. Top right and bottom left (which uses

an alternative computation): the result of hit-or-miss for strict definition of upper right corner pixels –

only the upper right corner pixels of the solid L shapes are identified. Bottom right: in the second

(relaxed) case, the noisy pixels are also identified.


13.1 Morphological thinning
The thinning of an image A by a structuring element B is defined as
thin (A,B)=A∩AB
where AB is the hit-or-miss transformation of A with B. The thinning of A with B is calculated by
successively translating the origin of the structuring element to each pixel in the image and
comparing it with the underlying image pixels. If both the foreground and background pixels in the
structuring element exactly match those in the underlying image, then the image pixel underneath
the origin of the structuring element is set to background (zero). If no match occurs, then the pixel is
left unchanged.

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

14. Skeletonization
A very useful conceptualization of the morphological skeleton is provided by the prairie-fire
analogy: the boundary of an object is set on fire and spreads with uniform velocity in all
directions inwards; the skeleton of the object will be defined by the points at which the fire
fronts meet and quench (i.e. stop) each other.
Consider an arbitrary, binary object A. A point p within this binary object belongs to the
skeleton of A if and only if the two following conditions hold:
(1) A disk Dz may be constructed, with p at its center, that lies entirely within A and touches
the boundary of A at two or more places.
(2) No other larger disk exists that lies entirely within A and yet contains D z.

An equivalent geometric construction for producing the skeleton is to:

(1) Start at an arbitrary point on the boundary and consider the maximum possible size of
disk which can touch the boundary at this point and at least one other point on the boundary
and yet remain within the object.
(2) Mark the Centre of the disk.
(3) Repeat this process at all points along the entire boundary (moving in infinitesimal steps)
until you return to the original starting point. The trace or locus of all the disk center points is
the skeleton of the object.
Figure 8.21 shows a variety of different shapes and their calculated skeletons. should
convince that the circle is actually slightly elliptical and that the pentagon and star are not
regular. The skeleton is a useful representation of the object morphology, as it provides both
topological information and numerical metrics which can be used for comparison and

categorization.

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Figure 8.21 Some shapes and their corresponding morphological skeletons


15. Opening by reconstruction
Morphological opening, opening by reconstruction is a morphological transformation which
enables the objects which survive an initial erosion to be exactly restored to their original
shape. The method is conceptually simple and requires two images which are called the
marker and the mask. The mask is the original binary image. The marker image is used as
the starting point of the procedure and is, in many cases, the image obtained

Figure 8.22 Effects of morphological opening. (a) Original binary image. (b) Result of opening
using a circular structuring element of radius 10. Note the rounding on the points of the star and the
corners of the rectangle. (c) Result of opening using a square structuring element of side length 25.
Only the rectangle is properly restored, the other shapes are significantly distorted.

The procedure can describe by the following simple algorithm:


 denote the marker image by A and the mask image by M;
 define a 33 structuring element of 1s=B;
 iteratively apply An+1 =(AB) ∩M;
 when An+1= An, stop.
Figure 8.23 illustrate the use of morphological
reconstruction. We preserve all alphabetic characters
which have a long vertical stroke in a printed text
sequence whilst completely removing all others.

Figure 8.23 Opening by reconstruction. Top: the original text –


the mask image. Middle: the text
after erosion by a long, vertical structuring element. This acts
as the marker image. Bottom: the image
after opening by reconstruction. Only characters with long vertical strokes have been
restored

16. Grey-scale erosion and dilation

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Grey-scale erosion of image A by structuring element B is denoted A B and the operation


may be described as follows:
. successively place the structuring element B over each location in the image A;
. for each location, select the minimum value of A-B occurring within the local
neighborhood defined by the structuring element B.
Grey-scale dilation of image A by structuring element B is denoted AB and the operation
may be described as follows:
. successively place the structuring element B over each location in the image;
. for each location, select the maximum value of AB occurring within the local
neighborhood defined by the structuring element B.
17. Grey-scale structuring elements: general case
Where grey-scale morphology is being considered, structuring elements have, in the most
general case, two parts:
(1) An array of 0s and 1s, where the 1s indicate the domain or local neighborhood defined by
the structuring element. We denote this by b.
(2) An array of identical size containing the actual numerical values of the structuring
element. We denote this by vb.
18. Grey-scale erosion and dilation with flat structuring elements
Flat structuring elements have height values which are all zero and are thus specified entirely
by their neighborhood. When a flat structuring element is assumed, grey-scale erosion and
dilation are equivalent to local minimum and maximum filters respectively. In other words,
erosion with a flat element results in each grey-scale value being replaced by the
minimum value in the vicinity defined by the structuring element neighborhood. Conversely,
dilation
with a flat element results in each grey-scale value being replaced by the maximum.
Figure 8.24 shows how grey-scale erosion and dilation may be used to calculate a so-called
morphological image gradient. It is easy to see why the morphological gradient works:
replacing a given pixel by the minimum or maximum value in the local neighborhood
defined by the structuring element will effect little or no change in smooth regions of the
image. However, when the structuring element spans an edge, the response will be the
difference between the maximum and minimum-valued pixels in the defined region and,
hence, large. The thickness of the edges can be tailored by adjusting the size of the
structuring elements if desired.

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

Figure 8.24 Calculating the morphological gradient: (a) grey-scale dilation with flat 3_3
structuring element; (b) grey-scale erosion with flat 3_3 structuring element; (c) difference of
(a) and (b)= morphological gradient.
19. Grey-scale opening and closing
Grey-scale opening and closing are defined in exactly the same way as for binary images and
their effect on images is also complementary. Grey-scale opening (erosion followed by
dilation) tends to suppress small bright regions in the image whilst leaving the rest of the
image relatively unchanged, whereas closing (dilation followed by erosion) tends to suppress
small dark regions. We can exploit this property in the following example, in Figure 8.25 in
which the objects/regions of interest are of similar size and separated from one another,
opening can be used quite effectively to estimate the illumination function.

Figure 8.25 Correction of nonuniform illumination through morphological opening. Left to right:
(a) original image; (b) estimate of illumination function by morphological opening of original;
(c) original with illumination subtracted; (d) contrast-enhanced version of image (c)

17
Lecture No.:7 Digital Image Processing Asst. Prof.Dr. Tariq Al-Juboori

20. The top-hat transformation


The top-hat transformation is defined as the difference between the image and the image
after opening with structuring element b, namely I-I b. Opening has the general effect of
removing small light details in the image whilst leaving darker regions undisturbed. The
difference of the original and the opened image thus tends to lift out the local details of the
image independently of the intensity variation of the image as a whole. For this reason, the
top-hat transformation is useful for uncovering detail which is rendered invisible by
illumination or shading variation over the image as a whole. Figure 8.26 shows an example
in which the individual elements are enhanced.

Figure 8.26 Morphological top-hat filtering to increase local image detail. Left to right: (a) original
image; (b) after application of top-hat filter (circular structuring element of diameter approximately
equal to dimension of grains); (c) after contrast enhancement

17

You might also like