Title: Mathematical Morphology in Image Processing
1Mathematical MorphologyinImage Processing
- Dr.K.V.Pramod
- Dept. of Computer Applications
- Cochin University of Sc. Technology
2- What is Mathematical Morphology ?
3An (imprecise) Mathematical answer
- A mathematical tool for investigating geometric
structure in binary and grayscale images.
4A (precise) Mathematical Answer
Algebra Complete Lattices
Topology Hit-or-Miss
Mathematical Morphology
Operators Erosions-Dilations
Geometry Convexity - Connectivity Distance
- A mathematical tool that studies operators on
complete lattices
5- With in Biology, the term morphology is used for
the study of the shape and structure of animals
and plants. - In image processing Mathematical morphology is
theoretical framework for representation,
description and pre-processing
6- Built on Minkowski set theory.
- Part of the theory of finite lattices.
- A mathematical theory or methodology for
nonlinear image processing. - A technique for image analysis based on shape.
- Extremely useful, yet not often used
7Morphology - advantages
- Preserves edge information
- Works by using shape-based processing
- Can be designed to be idempotent
- Computationally efficient
8Morphology - applications
- Image enhancement
- Image restoration (eg. Removing scratches from
digital film) - Edge detection
- Texture analysis
- Noise reduction
- There are many more applications that
morphology can be applied to. Morphology has
been widely researched for use in image and video
processing.
9Some History
- Mathematical morphology was developed in the
1970s by George Matheron and Jean Serra -
- - George Matheron (1975) Random Sets and Integral
Geometry, John Wiley. - Jean Serra (1982) Image Analysis and
Mathematical Morphology, Academic Press. - Petros Maragos (1985) A Unified Theory of
Translations-Invariant Systems with Applications
to Morphological Analysis and Coding of Images,
Doctoral Thesis, Georgia Tech.
10Why we use these techniques ?Shape Processing
and Analysis
- Visual perception requires transformation of
images so as to make explicit particular shape
information. - Goal Distinguish meaningful shape information
from irrelevant one. - The vast majority of shape processing and
analysis techniques are based on designing a
shape operator which satisfies desirable
properties.
11Example
- Image analysis consists of obtaining measurements
characteristic to images under consideration. - Geometric measurements (e.g., object location,
orientation, area, length of perimeter)
12Mathematical Morphology
- Principles
- Such further processing is performed using one or
a combination of several morphological
transformations. - The transformations work in a certain local
neighborhood of each pixel (similarly to
convolution) defined by so called Structuring
Element . The structuring element can be
square, cross-like or any other shape.
13Mathematical Morphology Binary
ImagesMorphology uses Set Theory as foundation
for many functions. The simplest functions to
implement are Dilation and Erosion
- Dilation
- Dilation replaces zeros neighboring to ones by
ones. - Erosion
- Erosion replaces ones neighboring to zeros by
zeros.
14- Two other basic operations are -
- Closing Opening
- Closing
- Closing is dilation followed by erosion.
- Closing merges dense of ones together, fills
small - holes and smoothes boundaries.
- Closing smoothes objects by adding pixels
- Opening
- Opening is erosion followed by dilation.
- Opening removes single ones, thin lines and
divides objects connected with a narrow path
(neck). - Opening smoothes objects by removing pixels
15Dilation (I)
- Brief Description
- One of the two basic operators
- Basic effect
- Gradually enlarge the boundaries of regions of
foreground pixels on a binary image.
16Dilation (II)
- How It Works
- A set of Euclidean coordinates corresponding to
the input binary image - B set of coordinates for the structuring element
- Bx translation of B so that its origin is at x.
- The dilation of A by B is simply the set of all
points x such that the intersection of Bx with A
is non-empty.
17- Dilation in 1D is defined as
- A B x (?)x (intersection) A ? ? Ãœx?B
Ax
(1) - Where A and B are sets in Z. this definition is
also known as Minkowski Addition. This
equation simply means that B is moved over A and
the intersection of B reflected and translated
with A is found. Usually A will be the signal or
image being operated on and B will be the
Structuring Element. -
18. The following figure shows how dilation works
on a 1D binary signal.
- The output is given by (1) and will be set to one
unless the input is the inverse of the
structuring element. For example, in the input
it is 000 would cause the output to be zero, if
in the SE it 111.
19How dilation works
20- . Dilation has several interesting properties,
which make it useful for image processing. These
properties are - Translation invariant.
- This means that the result of A dilated with B
translated is the same as A translated dilated
with B as given by - (A B)x Ax B (2)
- Order invariant
- This simply means that if several dilations
are to be done, then the order in which they are
done is irrelevant. The result will be same
irrespective. - (A B) C A (B C) (3)
21- Increasing operator
- This means that if a set A, is a subject of
another set B, then the dilation of A by C is
still a subset of B dilated by C - (A contained in B) A C contained in B
C (4) - Scale invariant
- This means that the input and structuring
element can be scaled, then dilated and will give
the same as scaling the dilated output - rA rB r(A B) (5)
- Where r is a scale factor.
- These properties can be very useful in image
processing and can result in some operations
being simplified.
22Dilation (III)
23Dilation (IV)
- Example Binary dilation
- Note that the corners have been rounded off.
- When dilating by a disk shaped structuring
element, convex boundaries will become rounded,
and concave boundaries will be preserved as they
are.
Result of two Dilation passes using a disk shaped
structuring element of 11 pixels radius
Original image
Thresholded image
24Dilation (V)
- Example Binary dilation (edge detection)
- Dilation can also be used for edge detection by
taking the dilation of an image and then
subtracting away the original image.
25Dilation (VI)
- Example Binary dilation (Region Filling)
- Dilation is also used as the basis for many other
mathematical morphology operators, often in
combination with some logical operators.
26Dilation (VII)
- Conditional dilation
- Combination of the dilation operator and a
logical operator - Region filling applies logical NOT, logical AND
and dilation iteratively.
27Dilation (VIII)
X0 One pixel which lies inside the region
Dilate the left image
AND
Step 1 Result
Negative of the boundary
Original image
28Dilation (IX)
Dilate the left image
X1
AND
Step 2 Result
Negative of the boundary
29Dilation (X)
- Repeating dilation and with the inverted
boundary until convergence, yields
Step 4 Result
Step 5 Result
Step 6 Result
Step 3 Result
OR
Final Result
Original image
Result of Region Filling
30Dilation (XI)
- Grayscale Dilation
- Generally brighten the image
- Bright regions surrounded by dark regions grow in
size, and dark regions surrounded by bright
regions shrink in size. - The effect of dilation using a disk shaped
structuring element
31Dilation (XII)
- Example Grayscale dilation (brighten the image)
- The highlights on the bulb surface have increased
in size. - The dark body of the cube has shrunk in size
since it is darker than its surroundings.
Original image
Two passes Dilation by 33 flat square
structuring element
Five passes Dilation by 33 flat square
structuring element
32Dilation (XIII)
Pepper noise image
Dilation by 33 flat square structuring element
33Morphological Erosion
Structuring Element
Pablo Picasso, Pass with the Cape, 1960
34Erosion (I)
- Brief Description
- Erosion is one of the basic operators in the area
of mathematical morphology. - Basic effect
- Erode away the boundaries of regions of
foreground pixels (i.e. white pixels, typically).
Common names Erode, Shrink, Reduce
35Erosion (II)
- How It Works
- A set of Euclidean coordinates corresponding to
input binary image - B set of coordinates for the structuring
element - Bx translation of B so that its origin is at x
- The erosion of A by B is simply the set of all
points x such that Bx is a subset of A
36The Opposite of Dilation is known as Erosion
- This is defined as
- A ? B x (B)x contained in A
?x?B Ax -
(6) - This definition is also known as Minkowski
Substration. The equation simply says, erosion
of A by B is the set of points x such that B
translated by x is contained in A. The following
Figure shows how erosion works on a 1D binary
signal. This works in exactly the same way as
dilation. However (6) essentially says that for
the output to be a one, all of the inputs must be
the same as the structuring element.
37How Erosion Works
38Erosion, like dilation also contains properties
that are useful for image processing
- Translation invariant.
- This means that the result of A eroded with B
translated is the same as A translated eroded
with B as given by - (A ? B)x Ax ? B (7)
- Order invariant
- This simply means that if several erosions are
to be done, then the order in which they are done
is irrelevant. The result will be same
irrespective. - (A ? B) ? C A ? (B ? C) (8)
39- Increasing operator
- This means that if a set, A, is a subject of
another set, B, then the erosion of A by C is
still a subset of B eroded by C - (A ? B) ? C A ? C contained in B ? C (9)
- Scale invariant
- This means that the input and structuring
element can eb scaled, then eroded and will give
the same as scaling the eroded output - rA ? rB r(A ? B) (10)
- Where r is a scale factor.
40Erosion (III)
Effect of erosion using a 33 square structuring
element
41Erosion (IV)
- Example Binary erosion
- It shows that the hole in the middle of the image
increases in size as the border shrinks. - Erosion using a disk shaped structuring element
will tend to round concave boundaries, but will
preserve the shape of convex boundaries.
Original thresholded image
Result of erosion four times with a disk shaped
structuring element of 11 pixels in diameter
42Erosion (V)
- Example Binary erosion (separate touching
objects)
Original image (a number of dark disks)
Inverted image after thresholding
The result of eroding twice using a disk shaped
structuring element 11 pixels in diameter
Using 99 square structuring element leads to
distortion of the shapes
43Erosion (VI)
- Grayscale erosion
- Generally darken the image
- Bright regions surrounded by dark regions shrink
in size, and dark regions surrounded by bright
regions grow in size. - The effect of erosion using a disk shaped
structuring element
44Erosion (VII)
- Example Grayscale erosion (darken the image)
- The highlights have disappeared.
- The body of the cube has grown in size since it
is darker than its surroundings.
Two passes Erosion by 33 flat square structuring
element
Five passes Erosion by 33 flat square
structuring element
Original image
45Erosion (VIII)
- Example Grayscale erosion (Remove salt noise)
- The noise has been removed.
- The rest of the image has been degraded
significantly.
Erosion by 33 flat square structuring element
Salt noise image
46Opening (I)
- Brief Description
- The Basic Effect
- Somewhat like erosion in that it tends to remove
some of the foreground(bright) pixels from the
edges of regions of foreground pixels. - To preserve foreground regions that have a
similar shape to structuring element.
47Opening (II)
- How It works
- Opening is defined as an erosion followed by a
dilation. - Gray-level opening consists simply of a
gray-level erosion followed by a gray-level
dilation. - Opening is the dual of closing.
- Opening the foreground pixels with a particular
structuring element is equivalent to closing the
background pixels with the same element.
48- Both dilation and erosion have interesting and
useful properties. However, it would be useful
to have the properties of both in one function.
This can be done in two ways. The first method,
Opening is defined as - A ? B (A ? B) B (11)
- This simply erodes the signal and then dilates
the result as shown in Figure 3. As can be seen,
the zeros are opened up. Any ones that are
shorter than the structuring element are removed,
but the rest of the signal is left unchanged. - This is a very useful property as it means that
if the filter is applied once, no more changes to
the signal will result from repeated applications
is known as Idempotent - (A ? B) ? B A ? B (12)
49Opening (III)
- Guidelines for Use
- Idempotence
- After the opening has been carried out, the new
boundaries of foreground regions will all be such
that the structuring element fits inside them. - So further openings with the same element have no
effect - Effect of opening using a 33 square structuring
element
50Opening (IV)
- Binary Opening Example
- Separate out the circles from the lines
- The lines have been almost completely removed
while the circles remain almost completely
unaffected.
Opening with a disk shaped structuring
element with 11 pixels in diameter
A mixture of circle and lines
51Opening (V)
- Binary Opening Example
- Extract the horizontal and vertical lines
separately - There are a few glitches in rightmost image where
the diagonal lines cross vertical lines. - These could easily be eliminated, however, using
a slightly longer structuring element.
Original image
The result of an Opening with 39 vertically
oriented structuring element
The result of an Opening with 93 horizontally
oriented structuring element
52Opening (VI)
Original image
Inverted image after thresholding
The result of an Opening with 11 pixel circular
structuring element
The result of an Opening with 7 pixel circular
structuring element
53Opening (VII)
- Example Grayscale opening
- The important thing to notice here is the way in
which bright features smaller than the
structuring element have been greatly reduced in
intensity. - The fine grained hair and whiskers have been much
reduced in intensity.
54Opening (VIII)
- Compare Opening with Erosion
- Opening
- The noise has been entirely removed with
relatively little degradation of the underlying
image. - Erosion
- The noise has been removed.
- The rest of the image has been degraded
significantly.
Erosion by 33 flat square structuring element
Salt noise Image
Opening with 33 square structuring element
55Opening (IX)
- Example Grayscale opening (pepper noise)
- No noise has been removed.
- At some places where two nearby noise pixels have
merged into one larger point, the noise level has
even been increased.
56Closing (I)
- Brief Description
- Closing is one of the two important operators
from mathematical morphology. - Closing is similar in some ways to dilation in
that it tends to enlarge the boundaries of
foreground (bright) regions in an image.
Common names Closing
57Closing (II)
- How It works
- Closing is defined as a dilation followed by an
erosion. - Closing is the dual of opening.
- Closing the foreground pixels with a particular
structuring element is equivalent to opening the
background pixels with the same element.
58Closing
- the opposite of opening is Closing defined by
- A ? B (A B) ? B (13)
- It can be seen that this closes gaps in the
signal in the same way as opening opened up gaps.
Closing also has the property of being
idempotent.
59Closing (III)
- Guidelines for Use
- Idempotence
- After the closing has been carried out, the
background region will be such that the
structuring element can be made to cover any
point in the background without any part of it
also covering a foreground point. - So further closings will have no effect.
Effect of closing using a 33 square
structuring element
60Closing (IV)
- Example Binary closing
- If it is desired to remove the small holes while
retaining the large holes, then we can simply
perform a closing with a disk-shaped structuring
element with a diameter larger than the smaller
holes, but smaller than the larger holes.
Original image
Result of a closing with a 22 pixel diameter disk
61Closing (V)
- Example Binary closing
- Enhance binary images of objects obtained from
thresholding. - We can see that skeleton (B) is less complex, and
it better represents the shape of the object.
Result of closing with a circular structuring
element of size 20
Original image
Thresholded image
(B) The skeleton of the image produced by
the closing operator
(A) The skeleton of the image which was only
thresholded
62Closing (VI)
- Example Grayscale closing
- Gray-level closing can similarly be used to
select and preserve particular intensity patterns
while attenuating others. - Notice how the dark specks in between the bright
spots in the hair have been largely filled in to
the same color as the bright spots. - But, the more uniformly colored nose area is
largely the same intensity as before.
63Closing (VII)
- Compare Closing with Dilation
- Closing
- The noise has been completely removed with only a
little degradation to the image. - Dilation
- Note that although the noise has been effectively
removed, the image has been degraded
significantly.
Closing with 33 square structuring element
Dilation by 33 flat square structuring element
Pepper noise image
64Closing (VIII)
- Example Grayscale closing (salt noise)
- No noise has been removed.
- The noise has even been increased at locations
where two nearby noise pixels have merged
together into one larger spot.
Salt noise image
Result of Closing
65Open-close Close-open filters
- Both Open and Close filters again have
interesting properties that would be nice to have
in one filter. The opening and closing can be
combined to merge these properties. There are
two ways of combining these, the first of which
is known as an Open-Close filter and is defined
by - A O? B (A ? B) ? B (14)
- The signal is first opened and the result is then
closed. The opposite can also be done by closing
and then opening. This is called a Close-Open
filter and is defined by - A ?O B (A ? B) ? B (15)
66Extending to Grey scale and Extending to 2D 3D
- For morphology to be of use in image
processing, it needs to be extended to non-binary
signals. There are various ways in which this
can be done . The chosen method uses very simple
functions, which allow them to be implemented in
an efficient way. One method of implementing is
Gray scale morphology and further extending to 2D
3D.
67