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

IPT Module 5

Uploaded by

b20cs36
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

IPT Module 5

Uploaded by

b20cs36
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Module – 5 Morphological Operations & Representation and Description

Morphological operations are a set of image processing techniques that focus on analyzing and manipulating
the shape, structure, and spatial relationships of objects within a digital image. These operations are based on
mathematical morphology, a theory developed by Georges Matheron and Jean Serra in the 1960s.
The purpose of morphological operations in digital image processing is to extract meaningful information,
enhance or suppress specific image features, and perform tasks such as segmentation, noise removal, object
recognition, and shape analysis. Morphological operations are particularly effective in dealing with binary or
grayscale images, although they can be extended to color images as well.
STRUCTURING ELEMENT
A structuring element is a small shape or template that defines the neighborhood around each pixel in the
image. It defines the size, shape, and configuration of the local area used for the operation.
The structuring element is typically a binary matrix or a binary image, where the foreground pixels (usually
represented as 1s) define the shape of the element. The background pixels (usually represented as 0s)
indicate the area outside the shape. The size of the structuring element is usually odd, ensuring a central
pixel exists.
The shape and size of the structuring element influence the behaviour of morphological operations and the
resulting effects on the image. Commonly used structuring elements include:
1. Square: A square structuring element has equal dimensions in both the horizontal and vertical directions.
It defines a square neighborhood around each pixel.
2. Rectangle: A rectangle structuring element has different dimensions in the horizontal and vertical
directions, allowing for elongated or rectangular neighbourhoods.

TRACE KTU
3. Disk: A disk structuring element defines a circular neighborhood around each pixel. It is useful for
capturing circular or rounded structures in the image.
4. Line: A line structuring element consists of a single row or column of foreground pixels. It is used for
morphological operations along specific directions, such as detecting lines or thin structures.
5. Custom Shape: Structuring elements can be designed to match specific shapes or structures of interest.
They can be created manually or generated automatically based on specific criteria.
EROSION
 Erosion is a fundamental morphological operation used in digital image processing to remove small or
thin features and to shrink or simplify the boundaries of objects.
 The erosion operation uses a structuring element to scan the image and replaces each pixel with the
minimum pixel value within the structuring element.
 The resulting image is a reduced version of the original image, where objects have been shrunk or
eliminated.
 With A and B as sets in Z2, the erosion of A by B, denoted by A ⊖ B is given by
 The equation indicates that erosion of A by B is the set of all points on z such that B is translated by z
contained in A.
 The erosion operation has several important applications in digital image processing, including noise
removal, segmentation, object detection, and pattern recognition.
 It is often used in conjunction with other morphological operations, such as dilation, opening, and
closing, to achieve specific tasks.
 The choice of structuring element determines the specific characteristics of the erosion operation and its
impact on the image.
 A larger structuring element results in more significant erosion, while a smaller structuring element
produces more refined details.

DILATION

TRACE KTU
Dilation is a fundamental morphological operation used in digital image processing to expand or grow
the boundaries of objects, fill in gaps, and connect nearby regions.
 The dilation operation uses a structuring element to scan the image and replaces each pixel with the
maximum pixel value within the structuring element.
 The resulting image is an expanded version of the original image, where objects have been enlarged or
connected.
 With A and B as sets in Z2, dilation of A by denoted by A ⊕ B, is defined as
 This equation is based on reflecting about its origin, and shifting this reflection by z
 The dilation operation has several important applications in digital image processing, including filling
gaps, connecting broken lines or contours, smoothing object boundaries, and generating mask or kernel
effects.
 It is often used in conjunction with other morphological operations, such as erosion, opening, and
closing, to achieve specific tasks.
 The choice of structuring element determines the specific characteristics of the dilation operation and its
impact on the image.
 A larger structuring element results in more significant dilation, while a smaller structuring element
produces more refined details.

OPENING AND CLOSING

Opening:

 Opening is a sequence of two operations: erosion followed by dilation. It is primarily used for noise
removal, smoothing object boundaries, and separating touching or overlapping objects. The opening
operation removes small or thin structures and preserves the overall structure of larger objects.
 The opening operation can be defined as A ° B followed by (A ⊖ B) ⊕ B, where A is the input image, B
is the structuring element, ⊖ represents erosion, and ⊕ represents dilation.
 The opening operation works by eroding away small details and noise, creating a simplified version of

TRACE KTU
the original image. This is followed by a dilation operation that expands the boundaries of the remaining
objects, effectively restoring their original size but with smoother contours. Opening is useful for tasks
such as noise removal, object separation, and background suppression.
 The opening operation has a geometric interpretation. Suppose that we view the structuring element B as
a (flat) “rolling ball.” The boundary of A ° B is then established by the points in B that reach the farthest
into the boundary of A as B is rolled around the inside of this boundary. This geometric fitting property
of the opening operation leads to a set theoretic formulation, which states that the opening of A by B is
obtained by taking the union of all translates of B that fit into A. That is, opening can be expressed as a
fitting process such that where ∪ {. } Denotes the union of all sets inside the
braces.
Closing:

 Closing is a sequence of two operations: dilation followed by erosion. It is primarily used for filling
gaps, connecting broken lines or contours, and closing holes or openings in objects. The closing
operation completes object boundaries and eliminates small holes or gaps.
 The closing operation can be defined as followed by (A ⊕ B) ⊖ B, where A is the input image, B
is the structuring element, ⊕ represents dilation, and ⊖ represents erosion.
 The closing operation works by dilating the image, which fills in gaps and connects nearby regions. This
is followed by an erosion operation that shrinks the expanded regions, effectively closing small holes or
gaps in objects. Closing is useful for tasks such as object reconstruction, boundary completion, and
filling in missing parts of objects.
 Closing has a similar geometric interpretation, except that now we roll B on the outside of the boundary
(Fig. 9.9). As discussed below, opening and closing are duals of each other, so having to roll the ball on
the outside is not unexpected. Geometrically a point w is an element of if and only if (𝐵)𝑧 ∩ 𝐴 ≠
∅ for any translate (B)z that contains w.

TRACE KTU
HIT OR MISS TRANSFORMATION

The Hit-or-Miss transformation is useful to find patterns in binary images. In particular, it finds those pixels
whose neighbourhood matches the shape of a first structuring element B1 while not matching the shape of a
second structuring element B2 at the same time. Mathematically, the operation applied to an image A can be
expressed as follows:

The process of the hit-or-miss transformation involves the following steps:


1. Define the foreground and background structuring elements:
 The foreground structuring element (B1) represents the pattern or shape to be detected. It
contains 1s where the pattern is present and 0s elsewhere.
 The background structuring element (B2) represents the complement of the pattern. It
contains 1s where the pattern is absent (background) and 0s elsewhere.
2. Perform erosion with the foreground structuring element:
 Apply the erosion operation to the input image using the foreground structuring element (B1)
to obtain the eroded image.
 This step will remove the parts of the image that do not match the pattern, leaving only the
pixels that potentially belong to the pattern.
3. Perform erosion with the complement of the background structuring element:
 Apply the erosion operation to the complement of the input image using the background
structuring element (B2) to obtain the eroded complement image.
 This step will remove the parts of the image that do not match the background of the pattern,
leaving only the pixels that potentially belong to the background.
4. Combine the eroded images:
 Perform a logical AND operation between the eroded image obtained in step 2 and the eroded
complement image obtained in step 3.
 The resulting image will contain foreground pixels (1s) only at the locations where both the
pattern and its background are present in the input image.
The hit-or-miss transformation is particularly useful for applications such as object recognition, shape
detection, and pattern matching. By defining appropriate structuring elements, specific patterns or
combinations of foreground and background pixels can be detected within an image.

BOUNDARY FOLLOWING
Given a binary region R, or its boundary, an algorithm for following the border of R, or the given boundary
consists of following steps:

TRACE KTU
1. Let the starting point b0 be the uppermost left point image that is labeled 1. Denote by c0 the west most
neighbour of b0. Clearly c0 is a background point. Examine the 8 neighbours of b0 starting from c0 and
proceeding in clockwise direction. Let b1 denotes the first neighbour encountered whose value is 1. Let
c1 be the point immediately preceding b1. Store the locations b0 and b1 for use in step 5.

2. Let b = b1 and c = c1.

3. Let the 8 neighbours of b, starting at c and proceeding in clockwise direction be denoted by n1, n2, ….
N8. Find the first nk labelled 1.

4. Let b = nk and c = nk-1

5. Repeat the steps 3 and 4 until b = b0 and the next boundary point b1 is found. The sequence of points
found when the algorithm stops constitutes the set of ordered boundary points.
This algorithm sometimes is referred to as the Moore boundary tracking algorithm.
CHAIN CODES
Chain codes are used to represent a boundary by a connected sequence of straight-line segments of specified
length and direction.
Typically, this representation is based on 4- or 8-connectivity of the segments.
The direction of each segment is coded by using a numbering scheme.
A boundary code formed as a sequence of such directional numbers is referred to as a Freeman chain code.
In chain codes, each point on the boundary is connected to its neighbour points in a specific direction,
forming a chain.
The chain code of a boundary depends on the starting point. However, the code can be normalized with
respect to the starting point by a straightforward procedure:
We simply treat the chain code as a circular sequence of direction numbers and redefine the starting point so
that the resulting sequence of numbers forms an integer of minimum magnitude. We can normalize also for
rotation by using the first difference of the chain code instead of the code itself.
Using these codes, we can represent the boundary of an object as a sequence of numbers, which can be
stored more efficiently than the actual pixel coordinates.
For example, consider the following image of a triangle:
00000000
00000000
00111000
00101000
TRACE KTU
00111000
00000000
00000000
00000000
We can represent the boundary of the triangle using chain codes as follows: 3 5 5 5 1 7 7 7 3
This sequence of codes describes the direction of each segment of the triangle's boundary, starting from the
top left corner and moving clockwise around the boundary.
Chain codes can be useful for various applications, such as shape recognition, object tracking, and
compression. They provide a compact representation of the boundary of an object in an image that can be
easily manipulated and analyzed.
POLYGONAL APPROXIMATIONS USING MINIMUM PERIMETER POLYGON
 A digital boundary can be approximated with arbitrary accuracy by a polygon.

 For a closed boundary, the approximation becomes exact when the number of segments of the polygon is
equal to the number of points in the boundary so that each pair of adjacent points defines a segment of
the polygon.
 The goal of a polygonal approximation is to capture the essence of the shape in a given boundary using
the fewest possible number of segments.

 This problem is not trivial in general and can turn into a time-consuming iterative search. However,
approximation techniques of modest complexity are well suited for image processing tasks.

 Among these, one of the most powerful is representing a boundary by a minimum-perimeter polygon
(MPP).
Foundation:

 The idea is to enclose a boundary (think of it as a rubber band) by a set of concatenating cells.

 The boundary is allowed to shrink but it is constrained by the inner and outer walls of the bounding
region defined by the cells.

 Ultimately, the shape shrinking provides the MPP.

 The vertices of the MPP coincide with corners of the inner or the outer wall.

 The size of the cells determines the accuracy of the representation.

 The objective is to use the largest possible cell size acceptable in a given application.

 The shape of the object enclosed by the inner wall of the light gray cells is shown in dark gray.


TRACE KTU
Traversing the boundary (counter clockwise) encounters convex (white dots) or concave (black dots)
vertices.

 The vertices of the MPP coincide either with convex vertices in the inner wall or with the “mirrors” of
the concave vertices in the outer wall.
MPP algorithm
The set of cells enclosing a digital boundary, described in the previous paragraphs, is called a cellular
complex. We assume that the boundaries under consideration are not self-intersecting, which leads to simply
connected cellular complexes. Based on these assumptions, and letting white(W) and black (B) denote
convex and mirrored concave vertices, respectively, we state the following observations:
1. The MPP bounded by a simply connected cellular complex is not self-intersecting.
2. Every convex vertex of the MPP is a W vertex, but not every W vertex of a boundary is a vertex of the
MPP.
3. Every mirrored concave vertex of the MPP is a B vertex, but not every B vertex of a boundary is a vertex
of the MPP.
4. All B vertices are on or outside the MPP, and all W vertices are on or inside the MPP.
5. The uppermost, leftmost vertex in a sequence of vertices contained in a cellular complex is always a W
vertex of the MPP.
Data preparation
– List of coordinates of each vertex.
– Label each vertex as W (convex) or B (concave).
– List of the mirrors of B vertices.
– Vertices must be in sequential order.
– The first vertex V0 is the uppermost leftmost vertex. It is always a W vertex
– The algorithm uses a white crawler WC and a black crawler BC crawling along the convex (W) and
mirrored concave (B) vertices respectively.

TRACE KTU
The algorithm terminates when it reaches the first vertex again, and thus has processed all the vertices in the
polygon. The VL vertices found by the algorithm are the vertices of the MPP. It has been proved that this
algorithm finds all the MPP vertices of a polygon enclosed by a simply connected cellular complex
BOUNDARY DESCRIPTORS
Simple Descriptors:
 The length of a boundary is one of its simplest descriptors.
 The number of pixels along a boundary gives a rough approximation of its length.
 For a chain coded curve with unit spacing in both directions, the number of vertical and horizontal
components √2 plus times the number of diagonal components gives its exact length.

 The diameter of a boundary is defined as where D is the distance measure


and pi and pj are boundaries.

 The value of the diameter and the orientation of a line segment connecting the two extreme points that
comprise the diameter (this line is called the major axis of the boundary) are useful descriptors of a
boundary.

 The minor axis of a boundary is defined as the line perpendicular to the major axis, and of such length that
a box passing through the outer four points of intersection of the boundary with the two axes completely
encloses the boundary.

 The box just described is called the basic rectangle, and the ratio of the major to the minor axis is called
the eccentricity of the boundary. This also is a useful descriptor.
 Curvature is defined as the rate of change of slope.

 As the boundary is traversed in the clockwise direction, a vertex point p is said to be part of a convex
segment if the change in slope at p is nonnegative; otherwise, p is said to belong to a segment that is
concave.
Shape Numbers:
 Shape number: first difference of smallest magnitude (in the chain code).

 The order of a shape number is defined as the number of digits in its representation.

Although first differences are invariant to rotation the coded boundary depends on the orientation of the grid.

TRACE KTU
Solution: align the chain-code grid with the sides of the basic rectangle.
–Compute the basic rectangle and the order n of the shape.
–Approximate the basic rectangle with a rectangle of order n (a rectangle with perimeter equal to n),
e.g. if n=12, all the rectangles with a perimeter 12are in {2x4, 3x3,1x5}.
–Select the one that best matches the eccentricity of the basic rectangle of the shape.
–Establish the grid on the new rectangle.
Fourier Descriptor:
for k = 0, 1, 2, …, K – 1.
Statistical Moments: TRACE KTU
The shape of boundary segments (and of signature waveforms) can be described quantitatively by using
statistical moments, such as the mean, variance, and higher order moments.
Let us treat the amplitude g as a discrete random variable v and form an amplitude histogram p(vi) i = 0, 1, 2
…, A – 1 where A is the number of discrete amplitude increments in which we divide amplitude scale.
Then nth moment of v about its mean is given by where m is given by
The quantity m is recognized as the mean value of 𝑣 and 𝜇2 as its variance.
The advantage of moments over other techniques is that implementation of moments is straightforward and
they also carry a “physical” interpretation of boundary shape. Size normalization, if desired, can be achieved
by scaling the range of values
REGIONAL DESCRIPTORS
Some Simple Descriptors:
The area of a region is defined as the number of pixels in the region. The perimeter of a region is the length
of its boundary.
A more frequent use of these two descriptors is in measuring compactness of a region, defined as
(perimeter)2/area.
A slightly different (within a scalar multiplier) descriptor of compactness is the circularity ratio, defined as
the ratio of the area of a region to the area of a circle (the most compact shape) having the same perimeter.
The circularity ratio is given by the equation: R c = 4πA/P2 where A is the area of the region and P is the length
of its perimeter.
Topological Descriptors:
Topological properties are useful for global descriptions of regions in the image plane. Simply defined,
topology is the study of properties of a figure that are unaffected by any deformation, as long as there is no
tearing or joining of the figure (sometimes these are called rubber-sheet distortions).
Another topological property useful for region description is the number of connected components. The
number of holes H and the connected components C can be used to define the Euler number E: E = C – H.
The Euler number is also a topological property.
Denoting number of vertices V, number of edges Q and number of faces F, gives the following relationship
called the Euler formula: V – Q + F = C – H. which implies V – Q + F = E. (as C – H = E).
Topological descriptors provide an additional feature that is often useful in characterizing regions in a scene.
Texture:
An important approach to region description is to quantify its texture content. Although no formal definition
of texture exists, intuitively this descriptor provides measures of properties such as smoothness, coarseness,
and regularity.
The three principal approaches used in image processing to describe the texture of a region are statistical,
structural, and spectral.

 Statistical approaches yield characterizations of textures as smooth, coarse, grainy, and so on.
 Structural techniques deal with the arrangement of image primitives, such as the description of texture
based on regularly spaced parallel lines.

TRACE KTU
Spectral techniques are based on properties of the Fourier spectrum and are used primarily to detect global
periodicity in an image by identifying high-energy, narrow peaks in the spectrum.
Statistical Approach:
One of the simplest approaches for describing texture is to use statistical moments of the intensity histogram
of an image or region.
Let z be a random variable denoting the intensity and let p(z i), I = 0, 1, 2 … , L – 1. Be the corresponding
histogram where L is the number of distinct intensity levels, the nth moment of z about the mean is

where m is the mean value of z given by


The second moment [the variance], is of a particular importance for the texture description. It is a measure of
intensity contrast that can be used to establish descriptors of relative smoothness.
The standard deviation is also frequently used as a measure of texture.
The third moment is a measure of skewness of histogram.
The fourth moment is a measure of flatness.
The fifth and higher moments are not related to histogram shape but they provide further quantitative
discrimination of texture content.
Measure of uniformity:
Average Entropy:
Moment Invariants:
A 2 D moment of order (p + q) of a digital image f(x, y) of size M * N is given by
Where p = 0, 1, 2, … and q = 0, 1, 2, …. are integers.
The corresponding central moment of order (p + q) is given by

RELATIONAL DESCRIPTORS:

TRACE KTU

You might also like