Morphological Image Processing Shahram Ebadollahi Lecture 8 (3.31.08)

advertisement
Lecture 8 (3.31.08)
Morphological Image Processing
Shahram Ebadollahi
A number of figures used in this presentation are courtesy of
“Morphological Image Analysis” by P. Soille
3/31/2008
DIP ELEN E4830
1
Outline
1
1
1
1
What is Mathematical Morphology?
Background Notions
Introduction to Set Operations on Images
Basic operation
1
1
1
Erosion, Dilation, Opening, Closing, Hit-or-Miss
Algorithms
Morphological operations on gray-level
images
3/31/2008
2
Morphological Image Processing
1
1
Started in 1960s by G.
Matheron and J. Serra
Analysis of form and
structure of objects
•Point
•neighborhood
Ψ
f
Morphological
Image
Transform
g
g = Ψ[ f ]
Image-to-image transform
1
Tools/Operations for
describing/characterizing
image regions and image
filtering
1
Images are treated as sets
3/31/2008
3
Applications - filtering
3/31/2008
4
Applications - segmentation
3/31/2008
5
Applications - quantification
3/31/2008
6
Background Notions:
Image as a Set
Binary image
f : D f ⊂ Ζ n → {0,1}
Image as a set: Set of all white pixels
definition domain of f –or- image plane
Grey-level image
f : D f ⊂ Ζ n → {0,1, 1 , t max }
Image as Digital Elevation Map (DEM)
• How could the grey-level image be treated as a set?
Image Graph
Image Sub-Graph
3/31/2008
{
SG ( f ) = {( x, t ) ∈ Ζ
}
G ( f ) = ( x, t ) ∈ Ζ n × Ν 0 | t = f ( x )
n
}
× Ν 0 | 0 ≤ t ≤ f ( x)
7
Background Notions:
Gray-level Image as a Set
3/31/2008
8
Set Operations on Images Union & Intersection
Union
( f ∨ g )( x) = max[ f ( x), g ( x)]
SG ( f ∨ g ) = SG ( f ) 2 SG ( g )
Intersection
( f ∧ g )( x) = min[ f ( x), g ( x)]
SG ( f ∧ g ) = SG ( f ) 3 SG ( g )
(Ψ1 ∨ Ψ2 )( f ) = Ψ1 ( f ) ∨ Ψ2 ( f )
(Ψ1 ∧ Ψ2 )( f ) = Ψ1 ( f ) ∧ Ψ2 ( f )
3/31/2008
9
Set Operations on Images
Complementation
fc
max
f
f c ( x) = t max − f ( x)
Set Difference
X \Y = X 3Y c
Note: Only on binary images
∨
Translation
g = g (− x)
∀x ∈
f b ( x ) = f ( x − b)
Reflection
∨
B = {− b | b ∈ B}
3/31/2008
10
Morphological Image Operations
•All morphological image operations are the result
of interaction between a set representing an image
and a set representing a structuring element
•All interactions are based on combination of
intersection, union, complementation and
translation
3/31/2008
11
Graphs
Graph is a pair of vertices
and edges (V,E), where:
V =
E =
(v 1 , v 2 , 4
(e 1 , e 2 , 4
)
, em )
,vn
• Planar graph
• Simple graph
Neighborhood of vertex v:
N G (v) = {v'∈ V | (v, v' ) ∈ E}
Path P in graph G:
PG = (v0 , v1 ,4, vl ) , (vi , vi +1 ) neighbors
PGh
3/31/2008
12
Grids & Connectivity
Connectivity:
a set is connected if each pair of
its points can be joined by a path
completely in the set
Gh-Connectivty:
2 pixel p and q of image f are Ghconnected iff there exists a PGh
path with end points p and q
3/31/2008
13
Structuring Element (SE):
A Small Set for Probing Images
3/31/2008
14
Erosion: “Does the SE fit the set?”
ε B ( X ) = {x | Bx ⊆ X }
: Eroding set X with SE B
ε B ( X ) = 3 X −b
b∈B
∨
εB(X ) = X − B
3/31/2008
15
Erosion: Implementation
B
ε B ( f ) = ∧ f −b
f
b∈B
⇒ [ε B ( f )]( x) = min f ( x + b)
b∈B
f +1
εB( f )
f −1
3/31/2008
16
Erosion: “Does the SE fit the set?”
Grey-level image
ε B [ SG ( f )] = {( x, t ) | B( x ,t ) ⊆ SG ( f )}
3/31/2008
17
Dilation: “Does the SE hit the set?”
δ B ( X ) = {x | Bx ∩ X ≠ φ }
: Dilating set X with SE B
δ B ( X ) = 2 X −b
b∈B
∨
δB(X ) = X ⊕ B
3/31/2008
18
Dilation: Implementation
δ B ( f ) = ∨ f −b
B
f
b∈B
⇒ [δ B ( f )]( x) = max f ( x + b)
b∈B
f +1
δB( f )
f −1
3/31/2008
19
Dilation: “Does the SE hit the set?”
Grey-level image
δ B [ SG ( f )] = {( x, t ) | B( x ,t ) 3 SG ( f ) ≠ φ}
3/31/2008
20
Erosion and Dilation: Examples
Dilation
Erosion
then
Dilation
3/31/2008
21
Erosion and Dilation:
Example
3/31/2008
Basic morphological operations in Matlab
22
Properties of Erosion and Dilation
Duality
ε B = Cδ B C
δ B ( f c ) = ∨ b∈B [t max − f −b ]
= t max − ∧ b∈B [ f −b ]
= t max − ε B ( f )
= [ε B ( f )]c
• Erosion and Dilation are irreversible operations
• Homotopy is not preserved under either one
3/31/2008
23
Properties of Erosion and Dilation
Increasingness
ε ( f ) ≤ ε ( g )
f ≤g ⇒ 
δ ( f ) ≤ δ ( g )
Distributivity
δ (∨ f i ) = ∨ δ ( f i )
i
i
ε (∧ f i ) = ∧ ε ( f i )
i
3/31/2008
i
24
Properties of Erosion and Dilation
Composition
δ B δ B ( f ) = δ (δ
2
1
ε B ε B ( f ) = ε (δ
2
1
Break down operations using large SE
with multiple operations with small SE.
∨
B2
∨
B2
( B1 ))
( B1 ))
(f)
(f)
B1
B2
δ B ( B1 )
2
δ nB = δ B (n )
Making a circular disk
3/31/2008
25
Opening –
“If SE fits image then keep all SE!”
γ B ( f ) = δ [ε B ( f )]
∨
B
γ B ( X ) = 2{Bx | Bx ⊆ X }
x
3/31/2008
26
Opening –
“If SE fits the image then keep all SE!”
εB( f )
3/31/2008
γB( f )
27
Closing –
“If SE fits the background then all points in
SE belong to the complement of closing!”
φB ( f ) = ε [δ B ( f )]
∨
B
φB ( X ) = 3{Bxc | X ⊆ Bxc }
x
3/31/2008
28
Closing
δB( f )
3/31/2008
φB ( f )
29
Properties of Opening and Closing
Duality
Increasingness
Idempotence
γ B = CφB C
γ ( f ) ≤ γ ( g )
f ≤g ⇒ 
φ ( f ) ≤ φ ( g )
γ (n ) = γ
φ (n ) = φ
3/31/2008
Sieving process:
same sieve is not
helpful using it
more than once
30
Opening and Closing: Example
3/31/2008
31
Opening and Closing: Example
3/31/2008
32
Top Hat transform
WTH ( f ) = f − γ ( f )
γB( f )
WTH ( f )
BTH ( f ) = φ ( f ) − f
φB ( f )
3/31/2008
BTH ( f )
33
Top Hat transform
3/31/2008
34
Hit-or-Miss
HMTB ( X ) = {x | ( BFG ) x ⊆ X , ( BBG ) x ⊆ X c }
HMTB ( X ) = ε BFG ( X ) 3 ε BBG ( X c )
HMTB ( X ) = HMTB c ( X c )
• Property:
where,
B = ( B1 , B2 )
B c = ( B2 , B1 )
3/31/2008
35
Thinning and Thickening
THIN B ( f ) = f − HMTB ( f )
THICK B ( f ) = f + HMTB ( f )
3/31/2008
36
Example Applications:
Boundary Extraction
β( f ) = f −εB( f )
3/31/2008
37
Example Applications:
Region Filling
X k = δ B ( X k −1 ) 3 Ac
k = 1,2,3,4
• start with X0=p
• stop when Xk=Xk-1
3/31/2008
38
Example Applications:
Connected component extraction
X k = δ B ( X k −1 ) 3 A
3/31/2008
k = 1,2,3, 4
39
Example Applications:
Convex Hull
X ki = HMTB i ( X k −1 ) 2 A i = 1,2,3,4 k = 1,2,3,4
X 0i = A
D i = X ki
4
C ( A) = 2 D i
i =1
3/31/2008
40
Skeletonization
K
S ( A) = 2 S k ( A)
k =0
S k ( A) = ε kB ( A) − φB (ε kB ( A) )
K = max{k | ε kB ( A) ≠ null }
K
A = 2 (δ kB ( S k ( A)))
k =0
3/31/2008
41
Skeletonization (Medial Axis Transform)
B is a “Maximal Disc” in set X if there are no
other discs included in X and containing B
Notion of “Maximal Disc”
Skeleton is the loci of the centers of all
“maximal discs”
S ( X ) = 2 {ε kB ( X ) \ γ B [ε kB ( X )]}
k ≥0
3/31/2008
42
Skeletonization
K
S ( X ) = 2 Sk ( X )
Notion of “Maximal Disc”
k =0
S k ( X ) = ε kB ( X ) − γ B (ε kB ( X ))
ε kB ( X ) = ε B (ε B (4 (ε B ( X )))
K = max{k | ε kB ( X ) ≠ φ }
Reconstruction
K
X = 2 δ kB ( S k ( X ))
k =0
δ kB ( X ) = δ B (δ B (4 (δ B ( S k ( X ))))
3/31/2008
Skeleton is the loci of the
centers of all “maximal discs”
43
Matlab examples - dilation
originalBW = imread('text.png');
se = strel('line',11,90);
dilatedBW = imdilate(originalBW,se);
figure, imshow(originalBW), figure, imshow(dilatedBW)
originalI = imread('cameraman.tif');
se = strel('ball',5,5);
dilatedI = imdilate(originalI,se);
figure, imshow(originalI), figure, imshow(dilatedI)
se1 = strel('line',3,0);
se2 = strel('line',3,90);
composition = imdilate(1,[se1 se2],'full')
3/31/2008
44
Matlab examples - erosion
originalBW = imread('text.png');
se = strel('line',11,90);
erodedBW = imerode(originalBW,se);
figure, imshow(originalBW)
figure, imshow(erodedBW)
originalI = imread('cameraman.tif');
se = strel('ball',5,5);
erodedI = imerode(originalI,se);
figure, imshow(originalI), figure, imshow(erodedI)
3/31/2008
45
Matlab examples - closing
originalBW = imread('circles.png');
figure, imshow(originalBW);
se = strel('disk',10);
closeBW = imclose(originalBW,se);
figure, imshow(closeBW);
3/31/2008
46
Matlab examples - opening
original = imread('snowflakes.png');
se = strel('disk',5);
afterOpening = imopen(original,se);
figure, imshow(original), figure, imshow(afterOpening)
3/31/2008
47
Matlab examples - HMT
bw=[0 0 0 0 0 0
001100
011110
011110
001100
0 0 1 0 0 0]
interval = [0 -1 -1
1 1 -1
0 1 0];
bw2 = bwhitmiss(bw,interval)
3/31/2008
48
Download