You are on page 1of 62

Digital Image Processing

Chapter 9:
Morphological Image Processing
What are Morphological Operations?

Morphological operations come from the word “morphing”


in Biology which means “changing a shape”.

Morphing

Image morphological operations are used to manipulate


object shapes such as thinning, thickening, and filling.

Binary morphological operations are derived from


set operations.
Basic Set Operations
Concept of a set in binary image morphology:
Each set may represent one object. Each pixel (x,y) has
its status: belong to a set or not belong to a set.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Translation and Reflection Operations
Translation Reflection
Az  c c  a  z, for a  A Bˆ  w w  b, for b  B

B
A

z = (z1,z2)

(A)z B̂
Logical Operations*

*For binary images only


(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Dilation Operations

 
A  B  z Bˆ z  A   
 = Empty set
Dilate means “extend”

A = Object to be dilated
B = Structuring element

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Dilation Operations (cont.)
Reflection B̂

Structuring
Element (B)

Original image (A) Intersect pixel Center pixel


Dilation Operations (cont.)

Result of Dilation Boundary of the “center pixels”



where B̂ z intersects A
Example: Application of Dilation

“Repair” broken characters


(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Erosion Operation
A B  z B z  A

Erosion means “trim”

A = Object to be eroded
B = Structuring element

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Erosion Operations (cont.)

Structuring
Element (B)

Original image (A) Intersect pixel Center pixel


Erosion Operations (cont.)

Result of Erosion Boundary of the “center pixels”


where B is inside A
Example: Application of Dilation and Erosion

Remove small objects such as noise

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Duality Between Dilation and Erosion

( A B )  A  Bˆ
c c

where c = complement
Proof:

( A B )  z B z  A
c c

 z B z  A   
c c

 z B z  Ac   
 A  Bˆ
c
Opening Operation
A  B  ( A B)  B
or
A  B  B z B z  A
= Combination of all parts of A that can completely contain B

Opening eliminates narrow and small details and corners.


(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example of Opening

(Images from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Closing Operation
A  B  (A  B) B

Closing fills narrow gaps and notches

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example of Closing

(Images from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Duality Between Opening and Closing

A  B c

 Ac  Bˆ 
Properties Opening
1. A  B  A
2. If C  D then C  B  D  B
3. A  B   B  A  B
Properties Closing
1. A  A  B
2. If C  D then C  B  D  B
3. A  B   B  A  B
Idem potent property: can’t change any more
Example: Application of Morphological Operations

Finger print
enhancement

(Images from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Hit-or-Miss Transformation
A * X  A 
X   Ac (W  X ) 
where X = shape to be detected
W = window that can contain X

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Hit-or-Miss Transformation (cont.)
A * B  A 
B   Ac (W  X ) 

(Images from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Boundary Extraction
β(A)  A  A B

Original Boundary
image
(Images from Rafael C.
Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Region Filling
X k  X k 1  B   A
c

where X0 = seed pixel p

Original Results of region filling


image

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Extraction of Connected Components

X k  X k 1  B   A where X0 = seed pixel p

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example: Extraction of Connected Components

X-ray image
of bones

Thresholded
image

Connected
components
(Images from Rafael C.
Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Convex Hull
Convex hull has no concave part.
Convex hull

4
Algorithm: C ( A)   D D i  X conv
i
i
where
i 1

X ki  X k 1 * B i  A, i  1,2,3,4

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example: Convex Hull

(Images from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Thinning

A  B  A  ( A * B)
 A  ( A * B)c

A  B ((...(( A  B1 )  B 2 )...)  B n )

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example: Thinning

Make an object
thinner.
(Images from Rafael C.
Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Thickening
A . B  A  ( A * B)
A . B ((...(( A . B ) . B )...) . B )
1 2 n

Make an object thicker


(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Skeletons

Dot lines are


skeletons of this
structure

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Skeletons (cont.)
K
S ( A)   Sk ( A)
k 0

with Sk ( A)  ( A kB)  ( A kB)  B

where ( A kB)  (...( A B ) B ) ...) B


k times

and K  maxk A kB    
Skeletons

(Images from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Pruning

X 1  A  B = thinning
8
X 2   ( X 1 * B k ) = finding end points
k 1

X 3  ( X 2  H )  A = dilation at end points

X 4  X 1  X 3 = Pruned result

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example: Pruning

Original
image

After
Thinning End
3 times points

Dilation
of end Pruned
points result
Summary of Binary Morphological Operations

(Tables from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Summary of Binary Morphological Operations (cont.)

(Tables from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Summary of Binary Morphological Operations (cont.)

(Tables from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Summary of Binary Morphological Operations (cont.)

(Tables from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Basic Types of Structuring Elements

x = don’t care

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Gray-Scale Dilation
1-D Case f  b  maxf ( s  x )  b( x ) | ( s  x )  D f and x  Db 
2-D Case
f  b  maxf ( s  x, t  y )  b( x, y ) | ( s  x ), (t  y )  D f ; ( x, y )  Db 

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Gray-Scale Dilation (cont.)
Original image Reflection
Subimage of B
+

Max
Moving
window

Structuring
element B

Note: B can be any shape and


subimage must have
the same shape as
reflection of B. Output image
Gray-Scale Erosion
1-D Case f  b  minf ( s  x )  b( x ) | ( s  x )  D f and x  Db 
2-D Case
f  b  minf ( s  x, t  y )  b( x, y ) | ( s  x ), (t  y )  D f ; ( x, y )  Db 

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Gray-Scale Erosion (cont.)
Original image
Subimage B
-

Min
Moving
window
Structuring
element B

Note: B can be any shape and


subimage must have
the same shape as B.
Output image
Example: Gray-Scale Dilation and Erosion
Original image After dilation

Darker Brighter

After erosion (Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Gray-Scale Opening
f  b  ( f  b)  b

Opening cuts peaks

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Gray-Scale Closing
f  b  ( f  b)  b

Closing fills valleys


(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example: Gray-Scale Opening and Closing

Original image After opening After closing

Reduce dark
Reduce white
objects
objects
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Gray-scale Morphological Smoothing
Smoothing: Perform opening followed by closing

Original image After smoothing

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Morphological Gradient
g  ( f  b)  ( f  b)

Original image Morphological Gradient

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Top-Hat Transformation

h  f  ( f  b)

Original image Results of top-hat transform

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example: Texture Segmentation Application

Small
blob

Original image Segmented result


Large blob
Algorithm:
1. Perform closing on the image by using successively larger
structuring elements until small blobs are vanished.
2. Perform opening to join large blobs together
3. Perform intensity thresholding
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example: Granulometry
Objective: to count the number of particles of each size
Method:
1. Perform opening using structuring elements of increasing size
2. Compute the difference between the original image and the result
after each opening operation
3. The differenced image obtained in Step 2 are normalized and used
to construct the size-distribution graph.

Size distribution
Original image graph (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Morphological Watershads

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Morphological Watershads

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Morphological Watershads

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Gradient Image

Original P Surface of P
image
P at edges look
like mountain ridges.
Morphological Watershads

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Morphological Watershads

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Morphological Watershads

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Convex Hull

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.

You might also like