Morphological image
processing
By
Dr. Eng./ Tamer Medhat Mohammed Ibrahim
Electrical Engineering Dept., Faculty of Engineering,
Kafrelsheikh University
[email protected]
www.kfs.edu.eg/drtamer.html
Preview
“Morphology “ – a branch in biology that deals with the form
and structure of animals and plants.
“Mathematical Morphology” – as a tool for extracting image
components, that are useful in the representation and
description of region shape
What are the applications of Morphological Image Filtering?
❖ boundaries extraction
❖ skeletons
❖ convex hull
❖ morphological filtering
❖ thinning
❖ Pruning
The language of mathematical morphology is – Set theory.
Unified and powerful approach to numerous image processing
problems
Sets in mathematical morphology represent objects in an
image:
binary image (0 = black, 1 = white) :
the element of the set is the coordinates (x,y) of
pixel belong to the object Z2
Image Morphological Attributes Extracted from Image
Image
Processing
Basic Concepts in Set Theory
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.
What Are Morphological
Operators?
• Local pixel transformations for processing
region shapes
• Most often used on binary images
• Logical transformations based on
comparison of pixel neighbourhoods with a
pattern.
Structuring element (SE)
▪▪ small set to probe the image under study
▪▪ for each SE, define origo
▪▪ shape and size must be adapted to geometric
properties for the objects
Basic morphological operations
◼◼ Erosion
◼◼ Dilation
keep general shape but
◼◼ combine to smooth with respect to
◼◼ Opening object
◼◼ Closening background
Erosion
9
Erosion
10
Dilation
13
Dilation
14
Dilation : Bridging gaps
17
useful
◼◼ Erosion
◼◼ removal of structures of certain shape
and size, given by SE
◼◼ Dilation
◼◼ filling of holes of certain shape and size,
given by SE
18
Combining erosion and
dilation
◼◼ WANTED:
◼◼ remove structures / fill holes
◼◼ without affecting remaining parts
• Solution:
◼◼ combine erosion and dilation
◼◼ (using same SE)
19
Opening
erosion followed by dilation, denoted ∘
A B = ( A − B) B
◼◼ eliminates protrusions
◼◼ breaks necks
◼◼ smoothes contour
Opening
Opening
Closing
dilation followed by erosion, denoted •
A • B = ( A B) − B
◼◼ smooth contour
◼◼ fuse narrow breaks and long thin gulfs
◼◼ eliminate small holes
◼◼ fill gaps in the contour
Closing
Closing
Properties
Opening
(i) AB is a subset (subimage) of A
(ii) If C is a subset of D, then C B is a subset of D B
(iii) (A B) B = A B
Closing
(i) A is a subset (subimage) of A•B
(ii) If C is a subset of D, then C •B is a subset of D •B
(iii) (A •B) •B = A •B
Note: repeated openings/closings has no effect!
Useful: open & close
Application: filtering
Dilation in MATLAB
• Syntax
Y = imdilate(A,B)
• A ➔ input image
• B ➔ Structuring element
• Y ➔Dilated image
Structuring element in MATLAB
• They can be easily created using ‘strel’
function
se = strel ( shape , parameters )
• Shape can be ‘ diamond ’ , ’ square ’ , ’ disk ’
, ’ line ’ etc.
Dilation in MATLAB
• Miss ➔ No changes
• Hit ➔ at least one pixel matches =>The
origin is replaced by 1
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 1 1 0
1 1 1 0 1 1 1 1 1
0 0 1 1 1 0
0 1 1 1 1 1
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Input matrix Structuring
element Dilated matrix
Erosion in MATLAB
• It shrinks or thin objects in a binary image
• Syntax se =imerode(A,B)
• Output is 1 when element completely fits
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 0 1 1 1 0 0 0 1 0 0
0 0 1 1 1 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
Input matrix Structuring
element Erosion matrix
Dilation program
BW = zeros(9,10);
BW(4:6,4:7) = 1
SE = strel('square',3)
BW2 =
imdilate(BW,SE)
Questions
• Perform dilation and erosion