0% found this document useful (0 votes)
51 views35 pages

Lecture 9 - Morphological Image Processing

The document discusses morphological image processing techniques. It describes erosion and dilation as fundamental morphological operations that deal with shape and features in images. Erosion shrinks objects while dilation enlarges them. A structuring element is used to determine how these operations transform images. Compound operations like opening and closing combine erosion and dilation to remove imperfections or noise.

Uploaded by

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

Lecture 9 - Morphological Image Processing

The document discusses morphological image processing techniques. It describes erosion and dilation as fundamental morphological operations that deal with shape and features in images. Erosion shrinks objects while dilation enlarges them. A structuring element is used to determine how these operations transform images. Compound operations like opening and closing combine erosion and dilation to remove imperfections or noise.

Uploaded by

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

Morphological Image Processing

• Erosion
• Dilation
• Opening
• Closing
Morphology
Morphological image processing (or morphology) describes a
range of image processing techniques that deal with the shape
(or morphology) of features in an image
Morphological operations are typically applied to remove
imperfections introduced during segmentation, boundary
extraction, pruning, thinning, Skeletonization, etc.
What is mathematical morphology?
3

• Basic principle: the extraction of geometrical and topological


information from an unknown set (an image) through
transformations using another, well-defined, set, known as
structuring element (SE).
• In morphological image processing, the design of SEs, their shape
and size, is crucial to the success of the morphological operations
that use them.
• Set Theory
Fundamental concepts and operations
4
Basic set operations:
Complement

Difference

Translation

Reflection
Fundamental concepts and operations
5
Fundamental concepts and operations
6
Logical equivalents of(e) set theory operations
(f)

Intersection
Figur e 13.1 ~Basic
logical AND
set operations: (a) set A ; (b) translation of A by x =
c
(x 1 , x 2 ); (c) set B ; (d)
reflection of B ; (e) set A and its complement A ; (f) set difference (A − B ).

The equivalent expression using conventional image processing notation would be:

1 if A (x , y) and B (x , y) are both 1
C (x , y) = (13.6)
0 otherwise
This expression leads quite easily to a single MATLAB statement that perform the
intersection operation using the logical operator AND (&). Similarly, complement can be
obtianed using the unary NOT (~) operator, set union can be implemented using the logical
Similarly:
operator OR (| ) and set difference (A − B ) can be expressed as ( A & ~B) . Figure 13.2
shows representative results for two binary input images. Please note that we have followed
Complement ~ logical NOT
the IPT convention, representing foreground (1-valued) pixels as white pixels against a black
Union ~ logical OR
background.

Difference ~ A AND (NOT B)


13.2.1 The s truc turing e le me nt

The structuring element (SE) is the basic neighborhood structure associated with morpho-
logical image operations. It is usually represented as a small matrix, whose shape and size
Fundamental concepts and operations
7

Logical equivalents of set theory operations


The structuring element
8

 The structuring element (SE) is the basic neighborhood structure


associated with morphological image operations.
 It is usually represented as a small matrix, whose shape and size
impact the results of applying a certain morphological operator to
an image.
 Although a structuring element can have any shape, its
implementation requires that it be converted to a rectangular
array.
 For each array, the shaded squares correspond to the members of
the SE whereas the empty squares are used for padding, only.
The structuring element
9

Examples:

square cross

MATLAB functions
strel
getsequence
The structuring element
10
Examples:
Structuring Elements
Structuring elements can be any size and make any shape
However, for simplicity we will use rectangular structuring elements
with their origin at the middle pixel

0 0 1 0 0
1 1 1 0 1 0 0 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 1 0 0 1 1 1 0
0 0 1 0 0
Structuring Elements, Hits & Fits

Structuring Element
B
Fit: All on pixels in the structuring element cover
on pixels in the image

A Hit: Any on pixel in the structuring element


covers an on pixel in the image
C
Miss: No on pixel in the structuring element
covers an on pixel in the image

All morphological processing operations are based on these simple ideas


Fitting & Hitting
0 0 0 0 0 0 0 0 0 0 0 0
1 1 1
0 0 0 1 1 0 0 0 0 0 0 0
1 1 1
0 0 1 B1 1 1 1 0 C0 0 0 0
1 1 1
0 1 1 1 1 1 1 1 0 0 0 0 Structuring
0 1 1 1 1 1 1 1 0 0 0 0 Element 1

0 0 1 1 1 1 1 1 0 0 0 0 0 1 0
0 0 1 1 1 1 1 1 1 0 0 0 1 1 1
0 0 1 1 1 1 1 A1 1 1 1 0 0 1 0
0 0 0 0 0 1 1 1 1 1 1 0 Structuring
Element 2
0 0 0 0 0 0 0 0 0 0 0 0
Erosion
• Erosion of image f by structuring element s is given by f  s
• The structuring element s is positioned with its origin at (x, y) and
the new pixel value is determined using the rule:

 1 if s fits f
g ( x, y )  
0 otherwise
Erosion shrinks objects
Erosion Example
Original Image Processed Image With Eroded Pixels

Structuring Element
Erosion
16

• The value of the output pixel is the minimum value of all the pixels
in the input pixel's neighborhood.
• In a binary image, if any of the pixels is set to 0, the output pixel is
set to 0.
Erosion
17
Erosion – geometrical interpretation
Erosion 18

Erosion– MATLAB example

a = [ 0 0 0 0 0 ; 0 1 1 1 0; 1 1 1 0 0; 0 1 1 1 1; 0 0 0 0 0]
se1 = strel('square',3)
b = imerode (a,se1)

se2 = strel('rectangle', [1 3])


c = imerode (a,se2)
Dilation
• Dilation of image f by structuring element s is given by f  s
• The structuring element s is positioned with its origin at (x, y) and the new
pixel value is determined using the rule:

1 if s hits f
g ( x, y )  
0 otherwise
Dilation enlarges objects
Dilation Example
Original Image Processed Image

Structuring Element
Dilation
21

The effect of dilation is to “grow” or “thicken” objects in a binary


image.
Simplest Application is “bridging the gaps”.
The extent and direction of this thickening is controlled by the size
and shape of the structuring element.
Mathematically:
Dilation
• The value of the output pixel is the maximum value of all the 22
pixels in the input pixel's neighborhood.
• In a binary image, if any of the pixels is set to the value 1, the
output pixel is set to 1.
Dilation
23

Dilation – geometrical interpretation


Dilation 24

Dilation – Example
Dilation 25

Dilation – MATLAB example


a = [0 0 0 0 0;
0 1 1 0 0;
0 1 1 0 0;
0 0 1 0 0;
0 0 0 0 0]

se1 = strel('square',3)
b = imdilate (a,se1)

se2 = strel('rectangle', [1 3])


c = imdilate (a,se2)
Dilation and Erosion – geometrical interpretation
26
Compound Morphological Operations
More interesting morphological operations can be performed by
performing combinations of erosions and dilations
The most widely used of these compound operations are:

Opening: f ○ s = (f  s)  s

Closing: f  s = (f  s)  s
Compound Operations (Opening & Closing)
28

Opening: erosion followed by dilation


Mathematically:

or:

In MATLAB: imopen


Compound operations (Opening & Closing)
29

Closing: dilation followed by erosion


Mathematically:

In MATLAB: imclose
Compound Operations (Example)
30
Compound Operations (Example)
31
Compound Operations (Example)
32

Operations
supported by
bwmorph
Basic Morphological Algorithms
33

Boundary Extraction
Hole Filling
Extraction of Connected Components
Thinning
Thickening
Skeletons
Pruning
Reconstruction
Segmentation of Water in Bottles
b = imread('bottles.jpg');
t=double(multithresh(b,2))/256
bL = im2bw(b,t(1));
bH = im2bw(b,t(2));
L = bL - bH;
se5 = strel('disk',5);
se10 = strel('disk',10);
L1 = imopen(L,se5);
L2 = imclose(L1,se10);
Bottles Liquid White Liquid Black

subplot(2,3,1),imshow(b),title('Bottles'),
subplot(2,3,2), imshow(bL), title('Liquid White'),
subplot(2,3,3), imshow(bH), title('Liquid Black'),
subplot(2,3,4), imshow(L), title('Liquid with noise'),
subplot(2,3,5), imshow(L1), title('Liquid with less noise'), Liquid with noise Liquid with less noise Pure Liquid

subplot(2,3,6), imshow(L2), title('Pure Liquid');


Exercise
Collect some bottles at your home, partially and completely
filled with some liquid. Take pictures of these bottles. Write
a program which can label only incompletely filled bottles
and test on these pictures.

You might also like