You are on page 1of 54

CS589-04 Digital Image Processing

Lecture 5. Morphological Image
Processing
Fall 2015
Bahria University

Introduction

Morphology: a branch of biology that deals with
the form and structure of animals and plants

Morphological image processing is used to extract
image components for representation and
description of region shape, such as boundaries,
skeletons, and the convex hull

03/31/16

2

Preliminaries (1)

Reflection

µ , is defined as
The reflection of a set B, denoted B
µ  {w | w  b, for b  B}
B

Translation

The translation of a set B by point z  ( z1 , z2 ), denoted ( B) Z ,
is defined as
( B) Z  {c | c  b  z, for b  B}
03/31/16

3

Example: Reflection and Translation

03/31/16

4

Preliminaries (2)

Structure elements (SE)
Small sets or sub-images used to probe an image under
study for properties of interest

03/31/16

5

Examples: Structuring Elements (1) origin 03/31/16 6 .

then the location is a member of the new set.Examples: Structuring Elements (2) Accommodate the entire structuring elements when its origin is on the border of the original set A Origin of B visits every element of A At each location of the origin of B. otherwise it is not a member of the new set. if B is completely contained in A. 03/31/16 7 .

the erosion of A by B. denoted A defined A B. translated by z .Erosion With A and B as sets in Z 2 . A 03/31/16 B   z | ( B ) Z  A   c 8 . is contained by A. B   z | ( B) Z  A The set of all points z such that B.

Exampl e of Erosion (1) 03/31/16 9 .

Exampl e of Erosion (2) 03/31/16 10 .

the translated B overlap by at least one element. denoted A  B. the dilation of A by B.     µ  A  A A  B  z |  B   z 03/31/16 11 . is defined as     µ A A  B= z | B z µ and A The set of all displacements z.Dilation 2 With A and B as sets in Z .

Examples of Dilation (1) 03/31/16 12 .

Examples of Dilation (2) 03/31/16 13 .

Duality ► Erosion and dilation are duals of each other with respect to set complementation and reflection  A  B c µ  A B c and  A  B 03/31/16 c µ  Ac  B 14 .

Duality ► Erosion and dilation are duals of each other with respect to set complementation and reflection  A  B c   z |  B  Z  A c   z |  B  Z  A   c c   z |  B  Z  Ac   µ  Ac  B 03/31/16 15 .

Duality ► Erosion and dilation are duals of each other with respect to set complementation and reflection  A  B c     A   µ A   z | B   µ  z| B c Z c Z µ  Ac  B 03/31/16 16 .

and fills gaps in the contour 03/31/16 17 .Opening and Closing ► Opening generally smoothes the contour of an object. eliminates small holes. and eliminates thin protrusions ► Closing tends to smooth sections of contours but it generates fuses narrow breaks and long thin gulfs. breaks narrow isthmuses.

denoted AgB. denoted A oB.Opening and Closing The opening of set A by structuring element B. is defined as A oB   A  B   B The closing of set A by structuring element B. is defined as AgB   A  B   B 03/31/16 18 .

is defined as A oB  U  B  Z |  B  Z  A 03/31/16 19 .Opening The opening of set A by structuring element B. denoted A oB.

Example: Opening 03/31/16 20 .

Example: Closing 03/31/16 21 .

03/31/16 22 .

Duality of Opening and Closing ► Opening and closing are duals of each other with respect to set complementation and reflection  AgB  c  A oB  03/31/16 µ)  ( A oB c c µ)  ( A gB c 23 .

then C oB is a subset of D oB (c) ( A oB) oB  A oB ► Properties of Closing (a) A is subset (subimage) of AgB (b) If C is a subset of D.The Properties of Opening and Closing ► Properties of Opening (a) A oB is a subset (subimage) of A (b) if C is a subset of D. then C gB is a subset of D gB (c) ( AgB )gB  AgB 03/31/16 24 .

03/31/16 25 .

the match (or set of matches) of B in A. A * B   A  D    Ac   W  D  B   B1 .The Hit-or-Miss Transformation if B denotes the set composed of D and its background. denoted A  B. B2  B1 : object B2 : background A  B   A  B1   ( Ac  B2 ) 03/31/16 26 .

can be obtained by first eroding A by B and then performing the set difference between A and its erosion.Some Basic Morphological Algorithms (1) ► Boundary Extraction The boundary of a set A.  ( A)  A   A  B  03/31/16 27 .

Example 1 03/31/16 28 .

Example 2 03/31/16 29 .

Given a point in each hole. the objective is to fill all the holes with 1s.e. Let A denote a set whose elements are 8-connected boundaries. each boundary enclosing a background region (i.Some Basic Morphological Algorithms (2) ► Hole Filling A hole may be defined as a background region surrounded by a connected border of foreground pixels. a hole).. 03/31/16 30 .

… Stop the iteration if Xk = Xk-1 03/31/16 31 .3.Some Basic Morphological Algorithms (2) ► Hole Filling 1.2. Xk = (Xk-1 + B) Ac k=1.  2. Forming an array X0 of 0s (the same size as the array containing A). except the locations in X0 corresponding to the given point in each hole. which we set to 1.

Example 03/31/16 32 .

03/31/16 33 .

Some Basic Morphological Algorithms (3) ► Extraction of Connected Components Central to many automated image analysis applications. Let A be a set containing one or more connected components. and form an array X0 (of the same size as the array containing A) whose elements are 0s. except at each location known to correspond to a point in each connected component in A. which is set to 1. 03/31/16 34 .

Some Basic Morphological Algorithms (3) ► Extraction of Connected Components Central to many automated image analysis applications. X k  ( X k 1  B)  A B : structuring element until X k  X k -1 03/31/16 35 .

03/31/16 36 .

03/31/16 37 .

Gray-Scale Morphology f ( x. y ) : gray-scale image b( x. y ): structuring element 03/31/16 38 .

y )  (min s .Gray-Scale Morphology: Erosion and Dilation by Flat Structuring f ( x  s.t )b 03/31/16 39 .t )b f ( x  s. y)  max ( s . y  t )   f  b ( x. y  t )   f  b ( x.

03/31/16 40 .

t )   f  bN  ( x. y  t )  bN ( s.t )b 03/31/16 41 . y )  (min s . y )  max ( s . t )   f  bN  ( x.Gray-Scale Morphology: Erosion and Dilation by Nonflat Structuring f ( x  s. y  t )  bN ( s.t )b f ( x  s.

03/31/16 42 .

03/31/16 43 .

► Opening and closing are used often in combination as morphological filters for image smoothing and noise removal. and closing suppresses dark details. 03/31/16 44 .Morphological Smoothing ► Opening suppresses bright details smaller than the specified SE.

Morphological Smoothing 03/31/16 45 .

thus producing a “derivative-like” (gradient) effect.Morphological Gradient ► Dilation and erosion can be used in combination with image subtraction to obtain the morphological gradient of an image. g  ( f  b)  ( f  b) ► The edges are enhanced and the contribution of the homogeneous areas are suppressed. denoted by g. 03/31/16 46 .

Morphological Gradient 03/31/16 47 .

Top-hat and Bottom-hat Transformations ► The top-hat transformation of a grayscale image f is defined as f minus its opening: That ( f )  f  ( f ob) ► The bottom-hat transformation of a grayscale image f is defined as its closing minus f: Bhat ( f )  ( f  b)  f 03/31/16 48 .

Top-hat and Bottom-hat Transformations ► One of the principal applications of these transformations is in removing objects from an image by using structuring element in the opening or closing operation 03/31/16 49 .

Example of Using Top-hat Transformation in Segmentation 03/31/16 50 .

Granulometry ► Granulometry deals with determining the size of distribution of particles in an image ► Opening operations of a particular size should have the most effect on regions of the input image that contain particles of similar size ► For each opening. the sum (surface area) of the pixel values in the opening is computed 03/31/16 51 .

Example 03/31/16 52 .

Textual Segmentation ► Segmentation: the process of subdividing an image into regions. 03/31/16 53 .

Textual Segmentation 03/31/16 54 .