![Page 1: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/1.jpg)
Morphological Image Processing
Presented By:Diwakar Yagyasen
Sr. LecturerCS&E, BBDNITM, Lucknow
Digital Image Processing
![Page 2: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/2.jpg)
Preview
Morphology
About the form and structure of animals and plants
Mathematical morphology
Using set theory
Extract image component
Representation and description of region shape
2Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 3: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/3.jpg)
Preview (cont.)
Sets in mathematical morphology represent objects in an image
Example
Binary image: the elements of a set is the coordinate (x,y) of the pixels, in Z2
Gray-level image: the element of a set is the triple, (x, y, gray-value), in Z3
3Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 4: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/4.jpg)
Outline
Preliminaries – set theory
Dilation and erosion
Opening and closing
Hit-or-miss transformation
Some basic morphological algorithms
Extensions to gray-scale images
Binaryimages
4Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 5: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/5.jpg)
Preliminaries – set theory
A be a set in Z2.
a = (a1, a2) is an element of A.
a is not an element of A
Null (empty) set:
Aa
Aa
5Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 6: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/6.jpg)
Set theory (cont.)
Explicit expression of a set
Example:
naaaA ,...,, 21
elementsset for condition elementA
DddwwC for ,
1
2
6Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 7: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/7.jpg)
Set operations
A is a subset of B: every element of A is an element of another set B
Union
Intersection
Mutually exclusive
BA
BAC
BAC
BA
7Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 8: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/8.jpg)
Graphical examples
8Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 9: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/9.jpg)
Graphical examples (cont.)
AwwAc BwAwwBA ,
9Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 10: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/10.jpg)
Logic operations on binary images
Functionally complete operations
AND, OR, NOT
10Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 11: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/11.jpg)
BA
BA
AB 11
Diwakar Yagyasen, Deptt of CSE, BBDNITM
![Page 12: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/12.jpg)
Special set operationsfor morphology
translation
AazaccA z for ,)(
reflection
BbbwwB for ,ˆ
12Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 13: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/13.jpg)
Outline
Preliminaries
Dilation and erosion
Opening and closing
Hit-or-miss transformation
Some basic morphological algorithms
Extensions to gray-scale images
13Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 14: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/14.jpg)
Dilation
)ˆ( ABzBA z B:structuringelement
14Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 15: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/15.jpg)
Dilation: another formulation
AABzBA z )ˆ(
15Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 16: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/16.jpg)
Application of dilation: bridging gaps in images
Structuringelement
max. gap=2 pixels
Effects: increase size, fill gap
16Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 17: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/17.jpg)
Erosion
ABzBA z )(
z: displacement
B:structuringelement
17Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 18: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/18.jpg)
Erosion (cont.)
18Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 19: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/19.jpg)
Application of erosion: eliminate irrelevant detail
original image
Squares of size1,3,5,7,9,15 pels
erosion
Erode with13x13 square
dilation
19Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 20: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/20.jpg)
Dilation and erosion are duals
c
z
c ABzBA )( ) (
cc
z ABz )(
)( c
z ABz
)ˆ( ABzBA z
BAc ˆ
20Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 21: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/21.jpg)
Application: Boundary extraction
Extract boundary of a set A:
First erode A (make A smaller)
A – erode(A)
) ( BAA=
21Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 22: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/22.jpg)
Application: boundary extraction
Using 5x5 structuring elementoriginal image
22Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 23: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/23.jpg)
Outline
Preliminaries
Dilation and erosion
Opening and closing
Hit-or-miss transformation
Some basic morphological algorithms
Extensions to gray-scale images
23Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 24: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/24.jpg)
Opening
Dilation: expands image w.r.t structuring elements
Erosion: shrink image
erosion+dilation = original image ?
Opening= erosion + dilation
BBABA ) (
24Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 25: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/25.jpg)
Opening (cont.)
25Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 26: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/26.jpg)
Opening (cont.)
Smooth the contour of an image, breaks narrow isthmuses, eliminates thin protrusions
Find contour Fill in contour
26Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 27: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/27.jpg)
Closing
Dilation+erosion = erosion + dilation ?
Closing = dilation + erosion
BBABA )(
27Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 28: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/28.jpg)
Closing (cont.)
Find contour Fill in contour
Smooth the object contour, fuse narrow breaks and longthin gulfs, eliminate small holes, and fill in gaps
28Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 29: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/29.jpg)
Properties of opening and closing
Opening
Closing
ABA of (subimage)subset a is (i)
BDBCC ofsubset a is then D,ofsubset a is If (ii)
BABBA )( (iii)
BAA of (subimage)subset a is (i)
BDBCC ofsubset a is then D,ofsubset a is If (ii)
BABBA )( (iii)
29Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 30: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/30.jpg)
Noisyimage
opening
Removeouternoise
Removeinnernoise
closing
30Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 31: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/31.jpg)
Outline
Preliminaries
Dilation and erosion
Opening and closing
Hit-or-miss transformation
Some basic morphological algorithms
Extensions to gray-scale images
31Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 32: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/32.jpg)
Hit-or-miss transformation
Find the location of certain shape
erosion
Find the set of pixels thatcontain shape X
X
32Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 33: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/33.jpg)
Hit-or-miss transformation
Erosionwith (W-X)
Detect object via background
33Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 34: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/34.jpg)
Hit-or-miss transformation
Eliminate un-necessary parts
AND
34Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 35: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/35.jpg)
Outline
Preliminaries
Dilation and erosion
Opening and closing
Hit-or-miss transformation
Some basic morphological algorithms
Extensions to gray-scale images
35Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 36: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/36.jpg)
Basic morphological algorithms
Extract image components that are useful in the representation and description of shape
Boundary extraction
Region filling
Extract of connected components
Convex hull
Thinning
Thickening
Skeleton
Pruning
36Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 37: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/37.jpg)
Region filling
How?
Idea: place a point inside the region, then dilate that point iteratively
,...3,2,1,)( 1 kABXX c
kk
pX 0
Until 1 kk XX
Bound the growth
37Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 38: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/38.jpg)
Region filling (cont.)
stop38
Diwakar Yagyasen, Deptt of CSE, BBDNITM
![Page 39: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/39.jpg)
Application: region filling
Original image
The first filledregion
Fill all regions
39Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 40: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/40.jpg)
Extraction of connected components
Idea: start from a point in the connected component, and dilate it iteratively
,...3,2,1 ,)( 1 kABXX kk
pX 0
Until 1 kk XX
40Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 41: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/41.jpg)
Extraction of connected components (cont.)
41Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 42: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/42.jpg)
original
thresholding
erosion
42Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 43: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/43.jpg)
Skeletons
Set A Maximum disk
1. The largest disk Centered at a pixel2. Touch the boundaryof A at two or more places
Recall: Balls of erosion!
How to define a Skeletons?
43Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 44: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/44.jpg)
Skeleton
Idea: erosion
Erosion k 次直到空集合
44Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 45: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/45.jpg)
45Diwakar Yagyasen, Deptt of CSE,
BBDNITM
![Page 46: Chapter 9: Morphological Image Processingdylucknow.weebly.com/.../6731187/morphological...i.pdf · Chapter 9: Morphological Image Processing Author: NCNU Created Date: 11/10/2010](https://reader035.vdocuments.site/reader035/viewer/2022062318/5fbea347670fd6340a49f3aa/html5/thumbnails/46.jpg)
Problem
The scanned image is not adjusted well
How to detection the direction of lines?
How to rotate?
46Diwakar Yagyasen, Deptt of CSE,
BBDNITM