Morphological Image Processingresearch.iaun.ac.ir/pd/pourghassem/pdfs/UploadFile_4849.pdf · 9...
Transcript of Morphological Image Processingresearch.iaun.ac.ir/pd/pourghassem/pdfs/UploadFile_4849.pdf · 9...
1
Morphological Image Processing
Chapter 9
1
Instructor: Hossein Pourghassem
Morphological Image Processing
Morphology deals with form and structure
Mathematical morphology is a tool for extracting image components useful in:
representation and description of region shape (e.g. boundaries)pre or post processing (filtering thinning etc )
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 2
pre- or post-processing (filtering, thinning, etc.)
Based on set theory
2
Morphology
Sets represent objects in imagesSets in binary images (x y)Sets in binary images (x,y)Sets in gray scale images (x,y,g)Some morphological operations:
Dilation & Erosion
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 3
Opening & ClosingHit-or-Miss Transform
Basic Algorithms
Basic Concepts of Set Theory
Assume A is a set in If a=(a1,a2) an element of A, then we write a∈A
2ZIf a (a1,a2) an element of A, then we write a∈AIf not, then a∉A∅: null (empty) setTypical set specification: C={w|w=-d, for d ∉ D}If A is the subset of B then we write A⊆B
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 4
⊆Union of A and B: C=A∪BIntersection of A and B: D=A∩B
3
Disjoint sets: A∩B= ∅Complement of A:
}|{ AwwAc ∉
Basic Concepts of Set Theory
Difference of A and B:A-B={w|w ∈ A, w ∉ B}=Reflection of B:
}|{ AwwA ∉=
A∩ Bc
ˆ B = {w | w = −b,b∈ B}
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 5
Translation of A by z=(z1,z2): B {w | w b,b∈ B}
(A)z = {c | c = a+ z,a ∈ A}
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 6
4
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 7
Logical Operation
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 8
5
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 9
Dilation & Erosion
Dilation:
∅: empty set; A,B: sets in Z2
Dilation of A by B:
})ˆ(|{ ∅≠∩=⊕ ABzBA
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 10
})(|{ ∅≠∩=⊕ ABzBA z
6
Dilation & Erosion
Dilation:
Obtaining the reflection of B about its origin and thenshifting this reflection by z
The dilation of A by B then is the set of all zdisplacements such that and A overlap by at leastone nonzero element
B̂
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 11
one nonzero element…
Dilation & Erosion
Dilation:
}])ˆ[(|{ AABxBA x ⊆∩=⊕
B is the structuring element in dilation.
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 12
7
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 13
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 14
8
Dilation & Erosion
Erosion:
i.e. the erosion of A by B is the set of all points xsuch that B, translated by x, is contained in A.
})(|{ ABxBA x ⊆=
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 15
In general:
BABA cc ˆ)( ⊕=
Dilation & Erosion
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 16
9
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 17
Opening & Closing
In essence, dilation expands an image and erosion shrinks it.
Opening:generally smoothes the contour of an image, breaks isthmuses, eliminates protrusions.
Cl i
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 18
Closing:smoothes sections of contours, but it generally fuses breaks, holes, gaps, etc.
10
Opening & Closing
Opening of A by structuring element B:
BBABA ⊕= ) (o
• Closing:
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 19
BBABA )( ⊕=•
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 20
11
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 21
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 22
12
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 23
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 24
13
Opening & Closing
BDBCDCifABA
⊆→⊆⊆
oo
o
BAABDBCDCif
BABBACCif
•⊆•⊆•→⊆
=⊆→⊆
)( ooo
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 25
BABBABAA
•=•••⊆)(
Hit-or-Miss Transform
Morphological hit or miss transform is aMorphological hit-or-miss transform is a basic tool for shape detection.
Definitions:B (B1,B2)
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 26
B1 is the set of elements of B associated with an objectB2 is the set of elements of B associated with thecorresponding background.
14
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 27
Hit-or-Miss Transform
A * B contains all the origin points at which, simultaneously:
B1 found a match (“hit”) in A and, B2 found a match in Ac.
)()(* BABABA c
)(21 XWBandXB −==
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 28
or
) () (* 21 BABABA c∩=*
)ˆ() (* 21 BABABA ⊕−=*
15
Example Basic Morphological Algorithms
Purpose: to extract image components that are useful in the representation and description of shape.
Boundary Extraction:
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 29
) ()( BAAA −=β
Morphological Image Processing•Boundary Extraction Example
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 30
16
Morphological Image Processing
•Boundary Extraction Example
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 31
Region Filling
Region filling based on set dilation, complementation andintersections.
Beginning with a point p inside the boundary the objective is
Xk = (Xk−1 ⊕ B)∩ Ac
Where X =p
Beginning with a point p inside the boundary, the objective isto fill the entire region with 1’s.
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 32
Where X0=p when Xk=Xk-1 the algorithm has converged.
17
Xk = (Xk−1 ⊕ B)∩ AcRegion Filling
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 33
Morphological Image Processing• Example of Region filling
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 34
18
Basic Morphological Algorithms
Extraction of Connected Components:
ABXX kk ∩⊕= − )( 1 k=1,2,3,…
Where X0=p
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 35
when Xk=Xk-1 the algorithm has converged.
Morphological Image Processing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 36
19
Example of Extraction of Connected Components
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 37
Convex Hull H of an arbitrary set S is the smallest convexcontaining S.
Convex Hull
Convex deficiency: H-S. these are useful for object description.The procedure consists of iteratively applying the hit-misstransform to A with B.
U
0
1 ,...3,124,3,2,1)*( −
=
===i
iik
ik
AX
kandiABXX
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 38
U4
1
1
0
)(=
−
=
==⇒=
i
i
ik
iconv
iik
ik
DAC
XXDXXif
AX
20
Convex Hull
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 39
× indicate Don’t care
Thinning
CBAABAABA
)*(*
I=
−=⊗ },...,,,{}{ 321 nBBBBB =
Algorithm:
))...))((...((}{ 21 nBBBABA ⊗⊗⊗=⊗1−ii BofversionrotatedaisBwhere
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 40
1- thin with B1 to Bn
2- go to step 1 until no further change is obtained
21
Thinning
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 41
Thickening
))...))((...((}{)*(
21 nBBBABABAABA
•••=•
=• U
• Structuring elements B in the above equation is theNot of B in thinning operator.
• Thickening can be performed by thinning Ac
• Connectivity check may be performed after
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 42
• Connectivity check may be performed afterthickening.
22
Thickening
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 43
Skeletons
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 44
23
Skeletons
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 45
Skeleton
)()(0
==
ASASK
kkU
})(|max{...)))(...()(
)()()(0
∅≠==
−==
BAkKBBBAkBABkBAkBAASk
k
o
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 46
BBBAkBA
kBASAK
kk
⊕⊕⊕=⊕
⊕==
...)))(...()(
))((0U
24
Skeletons
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 47
PruningPost processing after thinning or and skeletonizing to cleanup parasitic components.M th dMethod
- Thin with proper structuring element n times
- Find end points}{1 BAX ⊗=
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 48
- Dilate end points with proper structuring element n times
314
23 )(XXX
AHXXU
I
=⊕=
25
Pruning
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 49
Gray Scale Dilation
})()()(|)()({),)((
DDtbtftsbf
+++++=⊕
}),(;)(),(|),(),(max{ bf DyxDytxsyxbytxsf ∈∈+++++
};)(|)()(max{))((
bf DxDxsxbxsfsbf
∈∈+++=⊕
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 50
26
Gray Scale Dilation
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 51
Gray Scale Erosion
}),(;)(),(|),(),(min{),)((
bf DyxDytxsyxbytxsftsbf
∈∈++−++=
};)(|)()(min{))((
bf DxDxsxbxsfsbf
∈∈+−+=
)()(ˆ),)(ˆ(),)((
yxbyxb
tsbftsbf c
−−=
⊕=
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 52
),(),(
),(),(
yxfyxf
yxbyxbc −=
−−=
27
Gray Scale Erosion
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 53
Gray scale Erosion and Dilation
Dilation produces the image with
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 54
Dilation produces the image with
brighter than and dark details have been reduced
28
Gray Scale Opening and Closing
)( bbfbf o ⊕=
),(
ˆ)(
)()(
yxff
bfbf
bbfbfbbfbf
c
cc o
o
−=
=•
⊕=•⊕=
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 55
)ˆ()(
),(
bfbf
yxff
o−=•−
Gray Scale Opening and Closing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 56
29
Gray Scale Opening and Closing
Islamic Azad University, Najafabad Branch, Department of Electrical Engineering, Dr. H. Pourghassem, 57