Chapter 4 - Clean

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 80

Class of Image Processing

CHAPTER 4
Morphological
Image Processing
6 Periods

Department of Mechatronics

EIU - 2017
N.Huan Le
Chapter outcomes
• Understand basic concept and Logic Operations
Involving Binary Pixels and Images
• Understand methods to apply morphological
operations for image enhancement
• Basic morphological algorithms
• Extensions of basic morphological algorithms to
gray-scale images

N.Huan Le
Contents
• This lecture will cover:
– Preliminaries
– Dilation and Erosion
– Opening and Closing
– The Hit-or-Miss Transformation
– Some Basic Morphological Algorithms
– Extensions to Gray-Scale Images

N.Huan Le
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.
N.Huan Le
Basic Concepts in Set Theory
• Subset

• Union

• Intersection

disjoint / mutually exclusive


• Complement
• Difference
• Reflection
• Translation

N.Huan Le
Logic Operations Involving
Binary Pixels and Images
• The principal logic operations used in image
processing are: AND, OR, NOT (COMPLEMENT).
• These operations are functionally complete.
• Logic operations are preformed on a pixel by pixel
basis between corresponding pixels (bitwise).
• Other important logic operations:
XOR (exclusive OR), NAND (NOT-AND)
• Logic operations are just a private case for a binary
set operations, such: AND – Intersection , OR –
Union, NOT-Complement.

N.Huan Le
Basic Set Operations

Concept of a set in binary image morphology:


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Each set may represent one object. Each pixel (x,y) has
its status: belong to a set or not belong to a set.

N.Huan Le
Translation and Reflection
Operations
Translation Reflection

Az c c a  z, for a  A Bˆ w w  b, for b  B

z = (z1,z2)

(A)z

N.Huan Le
Dilation Operations

• Dilation is used for expanding an element A by using


structuring element B.
• Dilation of A by B and is defined by the following equation:

• This equation is based on obtaining the reflection 0f B


about its origin and shifting this reflection by z.
• The dilation of A by B is the set of all displacements z,
such that and A overlap by at least one element. Based
on this interpretation the equation of (9.2-1) can be
rewritten as:

N.Huan Le
Dilation Operations

A  B  z Bˆ z  A  

Images taken from Gonzalez & Woods, Digital Image Processing (2002)

= Empty set
Dilate means “extend”

A = Object to be dilated
B = Structuring element

N.Huan Le
Dilation Operations (cont.)
Reflection

Structuring
Element (B)

Original image (A) Intersect pixel Center pixel


N.Huan Le
Dilation Operations (cont.)

Result of Dilation Boundary of the “center pixels”



where B̂ z intersects A
N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

“Repair” broken characters


Dilation
Example: Application of

N.Huan Le
Erosion Operation

• Erosion is used for shrinking of element


A by using element B.
• Erosion for Sets A and B in Z2, is defined
by the following equation:

• This equation indicates that the erosion


of A by B is the set of all points z such
that B, translated by z, is combined in
A.

N.Huan Le
Erosion Operation

A B z B z  A
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Erosion means “trim”

A = Object to be eroded
B = Structuring element

N.Huan Le
Erosion Operations (cont.)

Structuring
Element (B)

Original image (A)


Intersect pixel Center pixel

N.Huan Le
Erosion Operations (cont.)

Result of Erosion
Boundary of the “center pixels”
where B is inside A

N.Huan Le
Example: Application of
Dilation and Erosion
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Remove small objects such as noise


N.Huan Le
Opening And Closing

• Opening – smoothes contours , eliminates


protrusions
• Closing – smoothes sections of contours,
fuses narrow breaks and long thin gulfs,
eliminates small holes and fills gaps in
contours
• These operations are dual to each other
• These operations can be applied few times,
but has effect only once

N.Huan Le
Opening And Closing
• Opening –
– First – erode A by B, and then dilate the result
by B
– In other words, opening is the unification of all
B objects entirely contained in A

N.Huan Le
Opening Operation
A  B ( A B )  B
or
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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.


N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Example of Opening

N.Huan Le
Example of Opening
http://homepages.inf.ed.ac.uk/rbf/HIPR2/hipr_top.htm

Effect of opening using a 3×3 square structuring element

N.Huan Le
Opening And Closing
• Closing –
– First – dilate A by B, and then erode the result by B
– In other words, closing is the group of points,
which the intersection of object B around them
with object A – is not empty

N.Huan Le
Closing Operation
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

A  B ( A  B ) B

Closing fills narrow gaps and notches

N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Example of Closing

N.Huan Le
Example of Closing
http://homepages.inf.ed.ac.uk/rbf/HIPR2/hipr_top.htm

Effect of closing using a 3×3 square structuring element

N.Huan Le
Example: Application of
Morphological Operations

N.Huan Le
Example: Application of
Morphological Operations
Finger print
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

enhancement

N.Huan Le
The Hit-or-Miss
Transformation
http://homepages.inf.ed.ac.uk/rbf/HIPR2/hipr_top.htm

– The hit-and-miss transform is a general binary


morphological operation that can be used to look for
particular patterns of foreground and background pixels
in an image.
N.Huan Le
The Hit-or-Miss
Transformation
– Example of the extended type of structuring
element used in hit-and-miss operations.
– This particular element can be used to find
corner points.

– Four structuring elements used for corner finding in


binary images using the hit-and-miss transform.
– Note that they are really all the same element, but
rotated by different amounts. N.Huan Le
The Hit-or-Miss
Transformation
http://homepages.inf.ed.ac.uk/rbf/HIPR2/hipr_top.htm

– Effect of the hit-and-miss based right angle convex


corner detector on a simple binary image.

N.Huan Le
Hit-or-Miss Transformation

Some applications of the hit-and-miss transforms:


http://homepages.inf.ed.ac.uk/rbf/HIPR2/hipr_top.htm

– 1 is used to locate isolated points in a binary image.


– 2 is used to locate the end points on a binary. Note that this
structuring element must be used in all its rotations so four
hit-and-miss passes are required.
– 3a and 3b are used to locate the triple points (junctions).
Both structuring elements must be run in all orientations so
eight hit-and-miss passes are required.
N.Huan Le
Example: Application of
Hit-or-Miss Transformation
http://lamda.nju.edu.cn/

N.Huan Le
Example: Application of
Hit-or-Miss Transformation

N.Huan Le
Basic Morphological
Algorithms
1 – Boundary Extraction
2 – Region Filling
3 – Extraction of Connected Components
4 – Convex Hull
5 – Thinning
6 – Thickening
7 – Skeletons

N.Huan Le
Boundary Extraction

• First, erode A by B, then make set difference


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

between A and the erosion


• The thickness of the contour depends on the size
of constructing object – B

N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

image
Original
β(A)  A  A
B
Boundary Extraction

Boundary

N.Huan Le
Example: Boundary
Extraction

N.Huan Le
Region Filling
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

• This algorithm is based on a set of dilations,


complementation and intersections
• p is the point inside the boundary, with the value of 1
• X(k) = (X(k-1) xor B) conjunction with complemented
A
• The process stops when X(k) = X(k-1)
• The result that given by union of A and X(k), is a set
contains the filled set and the boundary

N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Region Filling

N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

image
Original
Region Filling

Results of region filling

N.Huan Le
Extraction of Connected
Components
• This algorithm extracts a component by selecting
a point on a binary object A
• Works similar to region filling, but this time we
use in the conjunction the object A, instead of it’s
complement

N.Huan Le
Extraction of Connected
Components
X k X k  1  B  A where X0 = seed pixel p
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

N.Huan Le
Example: Extraction of Connected
Components

X-ray image
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of bones

Thresholded
image

Connected
components

N.Huan Le
Example: Extraction of Connected
Components

N.Huan Le
Convex Hull

• A is said to be convex if a straight line segment


joining any two points in A lies entirely within A
• The convex hull H of set S is the smallest convex
set containing S
• Convex deficiency is the set difference H-S
• Useful for object description
• This algorithm iteratively applying the hit-or-miss
transform to A with the first of B element, unions
it with A, and repeated with second element of B

N.Huan Le
Convex Hull
Convex hull has no concave part.
Convex hull

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

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

N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Example: Convex Hull

N.Huan Le
Example: Convex Hull

N.Huan Le
Thinning
• The thinning of a set A by a structuring element B,
can be defined by terms of the hit-and-miss
transform:

• A more useful expression for thinning A


symmetrically is based on a sequence of
structuring elements:
{B}={B1, B2, B3, …, Bn}
• Where Bi is a rotated version of Bi-1.
• We define thinning by a sequence of structuring
elements:

N.Huan Le
Thinning (cont..)

• The process is to thin by one pass


with B1 , then thin the result with one
pass with B2, and so on until A is
thinned with one pass with Bn.
• The entire process is repeated until
no further changes occur.
• Each pass is preformed using the
equation:

N.Huan Le
Thinning (cont..)

A  B A  ( A B)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

*
c
A  ( A * B)

A  B ((...(( A  B )  B )...)  B )


1 2 n

N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Example: Thinning

thinner.
Make an object

N.Huan Le
Example: Thinning

N.Huan Le
Thickening

• Thickening is a morphological dual of thinning.


• Definition of thickening .
• Thickening can be defined as a sequential
operation:

• The structuring elements used for thickening


have the same form as in thinning, but with all
1’s and 0’s interchanged.

N.Huan Le
Thickening - cont

• A separate algorithm for thickening is often


used in practice.

• To thicken a set A, we form C=Ac , thin C and


then form Cc.

• Depending on the nature of A, this procedure


may result in some disconnected points.

• Thickening by this procedure usually require a


simple post-processing step to remove
disconnected points.

N.Huan Le
Thickening example preview

• The thinned background forms a boundary for the


thickening process.

• This feature does not occur in the direct


implementation of thickening.

• This is one of the reasons for using background


thinning to accomplish thickening.

N.Huan Le
A . B  A  ( A B)
*
*

A . B ((...(( A . B ) . B )...) . B )


1 2 n
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Make an object thicker

N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

(cont.)
Summary of Binary Morphological Operations

N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

(cont.)
Summary of Binary Morphological Operations

N.Huan Le
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Elements

x = don’t care
Basic Types of Structuring

N.Huan Le
Gray-Scale Dilation
1-D Case
ff  b max f ( s  x )  b( x ) | ( s  x )  D and x  D 
b
2-D Case
f  b max f ( s  x, t  y )  b( x, y ) | ( s  x ), (t  y )  D f ; ( x, y )  Db 
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

N.Huan Le
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
N.Huan Le
Example: Gray-Scale Dilation

N.Huan Le
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 taken from Gonzalez & Woods, Digital Image Processing (2002)

N.Huan Le
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 N.Huan Le
Example: Gray-Scale Erosion

N.Huan Le
Example: Gray-Scale Dilation and Erosion

Original image After dilation


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Darker Brighter

After erosion N.Huan Le


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

f  b ( f  b)  b
Gray-Scale Opening

Opening cuts peaks

N.Huan Le
Example: Gray-Scale
Opening

N.Huan Le
Gray-Scale Closing

f  b ( f  b)  b
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Closing fills valleys


N.Huan Le
Example: Gray-Scale Closing

N.Huan Le
Example: Gray-Scale
Opening and Closing
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original image After opening After closing

Reduce dark
Reduce white objects
objects
N.Huan Le
Gray-scale Morphological
Smoothing
Smoothing: Perform opening followed by closing
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original image After smoothing

N.Huan Le
Morphological Gradient

g ( f  b)  ( f  b)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original image Morphological Gradient

N.Huan Le
Top-Hat Transformation

h  f  ( f  b)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original image Results of top-hat transform

N.Huan Le
Example: Texture
Segmentation Application
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Small
blob

Original image Segmented result


Algorithm: Large blob
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 N.Huan Le
Example: Granulometry
Objective: to count the number of particles of each size
Method:
1. Perform opening using structuring elements of increasing size
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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 N.Huan Le
N.Huan Le

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy