Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for...
-
Upload
hoangtuyen -
Category
Documents
-
view
234 -
download
0
Transcript of Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for...
![Page 1: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/1.jpg)
Chapter 3 – Binary Image Analysis
Comunicação Visual Interactiva
![Page 2: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/2.jpg)
Pixels and Neighborhoods
Vizinhança N4
• Most common neighborhoods
• Use of masks
– Example:
Vizinhança N8
origem
input output
CVI - Binary Image Analysis 2
![Page 3: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/3.jpg)
Example
input saída
0 1 0
1 0 1
0 1 0
80 160 200 240 160
120 200 280 320 240
120 200 280 320 240
120 200 280 320 240
80 160 200 240 160
output
0 0 0
0 1 0
0 0 0
and with the mask ?
CVI - Binary Image Analysis 3
![Page 4: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/4.jpg)
Counting objects
• Algorithm
– Hypothesis: An object is a set of connected pixels (connectivity 4) and
without inner holes
Outer corners Inner corners
CVI - Binary Image Analysis 4
![Page 5: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/5.jpg)
How many objects?
e - 21
i - 5
44
16
4
521#
e
i
e
e e
e
e e
e
e e
e
e
e
e e
e
i
i
e
i
e
e
i
e
e
CVI - Binary Image Analysis 5
![Page 6: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/6.jpg)
And now?
e
i
e
e
e
e e
e
e e
e
e
e
e e
e
i
i
e
i
e
e
i
e
e
e
e e
e - 23
i - 4
?4
19
4
423#
CVI - Binary Image Analysis 6
![Page 7: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/7.jpg)
Connected Component Analysis – recursive algorithm
input
output
CVI - Binary Image Analysis 7
![Page 8: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/8.jpg)
Recursive algorithm - Example
Neighbor 4
Neighbor 8
CVI - Binary Image Analysis 8
![Page 9: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/9.jpg)
Union-Find structure
CVI - Binary Image Analysis 9
![Page 10: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/10.jpg)
Classic CCA using Union-Find
input
1º step
2º step
equiv. classes
CVI - Binary Image Analysis 10
![Page 11: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/11.jpg)
Exercise
• Apply the CCA algorithm considering connectivity 4
• What would be the result considering connectivity 8?
1 2
1 1 1 1
1
0
2
0 0
3
1 1
1 1
3 3
4
1
3
3 3
3
1
5 4
0
4
0
5
4
CVI - Binary Image Analysis 11
![Page 12: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/12.jpg)
Morphological operators
• Structuring elements
– We need to define the center (i.e. origin)
• Definition: A dilation of the binary image B by the structuring
element S is defined as
• Definition: A erosion of the binary image B by the structuring
element S is defined as
Bb
bSSB
SsBsbbSB
ones(3,5) disk(5) ring(5)
SsbsSb
CVI - Binary Image Analysis 12
![Page 13: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/13.jpg)
Morphological operations - Examples
CVI - Binary Image Analysis 13
![Page 14: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/14.jpg)
Dilation and erosion – Generalization for monochromatic images
Operação Rule
Dilation
The output pixel value is the maximum value of all
pixels in the neighborhood of the input pixel. It is
assigned minimum value (0) to the other pixels
Erosion
The output pixel value is the minimum value of all
pixels in the neighborhood of the input pixel. It is
assigned a maximum value (1 or 255) to the other pixels
Dilation of the binary image Dilation of a monochromatic image
CVI - Binary Image Analysis 14
![Page 15: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/15.jpg)
Morphological operations
• Definition: The closing of binary imge B by the structuring
element S is defined by
• Definition: A opening of a binary image B by the structuring
element S is defined by
SSBSB
SSBSB
B
S
SB
SB SB
SB
CVI - Binary Image Analysis 15
![Page 16: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/16.jpg)
• Medical applications (image resolution of 512x512)
– opening with disk (13) folowed by closing with disk (2)
• Extraction of shape primitives
– Subtraction between the original image and the image obtained with the
opening operator (using a disck as the structuring element)
Examples of morphology to extract shape primitives
original binarized processed
CVI - Binary Image Analysis 16
original opening corners
![Page 17: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/17.jpg)
Inspection procedure
input
output
a) b)
c) d)
e) f)
CVI - Binary Image Analysis 17
![Page 18: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/18.jpg)
Conditional Dilation
• Definition: Given two binary images, original B, and processed
C, and the structuring element S, and let
The conditional dilation of C by S with respect to B is defined by
BSCCCC nn 10 e
mB CSC
where m is the smallest integer satisfying 1 mm CC
B
V
VBC SC B
S
CVI - Binary Image Analysis 18
![Page 19: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/19.jpg)
Region properties
• Area
• Centroid
• Perimeter pixels
– Perimeter length
• Circularity (1)
Rcr
A),(
1
Rcr
Arr
),(
1
Rcr
Acc
),(
1
RcrNRcrP ),(),( 84
RcrNRcrP ),(),( 48
),(),(),(2
),(),(
4811
411
kkkkkk
kkkk
crNcrNcrk
crNcrkP
A
PC
2
1
CVI - Binary Image Analysis 19
![Page 20: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/20.jpg)
Properties (cont.)
• Circularity (2)
– Mean radial distance
– Standard deviation of radial distance
R
RC
2
1
0
),(),(1 K
k
kkR crcrK
2
11
0
2),(),(
1
K
k
RkkR crcrK
CVI - Binary Image Analysis 20
![Page 21: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/21.jpg)
Properties – lengths and boundaries
• Rectangle (and octagon) bounding box
• Axis length
º45:
º45:)(
)sin(1
)cos(1
Q
QccrrD 2
12
2
1222D
21
2D
º0 º45
CVI - Binary Image Analysis 21
![Page 22: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/22.jpg)
Properties– 2nd order moments
• Second order moments
• Relation between moments and elliptic regions
• Axis with least second order moment
– Formulation
– Solution
ccrr
rc
2ˆ2tan
12|, 22 fcercdrcrR
rrrc
rccc
rcccrrfe
ed
24
1
Rcr
Acc cc),(
21
Rcr
Arr rr),(
21
Rcr
Arc ccrr),(
1
RcrA
RcrAcr
V
d
),(
21
),(
21,,
sin,cos
2/
CVI - Binary Image Analysis 22
![Page 23: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/23.jpg)
Region Adjacency Graphs
• Problem: regions that have inner holes (in the background)
• Solution: algorithm with 3 steps
– Aplication of the CCA algorithm twice: (1) foreground pixels and (2)
background pixels
– (3) Building of graph relations
CVI - Binary Image Analysis 23
![Page 24: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/24.jpg)
Limiar Threshold
• Definition: the histogram h of a monochromatic image I is
defined by mcrIcrmh ),(),()(
CVI - Binary Image Analysis 24
![Page 25: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/25.jpg)
CVI - Análise de Imagens Binárias
Automatic computation of the Threshold
• Otsu Method
– Let us assume that we have an image , with and
denotes the gray level intensity in the coordinates .
– Also, assume that represents the gray levels in the
image .
– Defining as the nº of pixels at a given level , the total nº of the
pixels in the image is given by
– We can compute the weights of the pixels at the level as
– We are going to assume that we have two classes of gray levels,
using a threshold
RI :
),( yxI ),( yx
MaxValM ,...,3,2,1
I
2R
in Mi
MaxVal
i
inn1
mC ,...,2,11 MaxValmmC ,...,2,12 m
i
nniP i /)(
25 CVI - Binary Image Analysis
![Page 26: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/26.jpg)
Automatic computation of the Threshold
• Otsu Method
– Ideia: intra-class minimization variance
– The weights allow to compute the mean of the gray levels of the two
classes;
– Now, we can compute the variances, from the above means:
)()()()( 2
22
2
11
2 mmmmW
)()(1
1 iPmwm
i
MaxVal
mi
iPmw1
2 )()(
m
i
mwiiPm1
11 )(/)()(
MaxVal
mi
mwiiPm1
22 )(/)()(
m
ii
mwiPmim )(/)()()( 1
2
1
2
1
MaxVal
mi
mwiPmim1
2
2
2
2
2 )(/)()()(
CVI - Binary Image Analysis 26
![Page 27: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/27.jpg)
Cálculo automático do limiar
• Otsu then proposes the following “goodness” of the threshold
where
22111
2 )()()(1)( mmmwmwB
22 / WB
22121 )()()()( mmmwmw
)(1)( 12 mwmw
2
22
2
11
2 wwW
CVI - Binary Image Analysis 27
2
W
2
B
- within class (intra-class) variance
- between class (inter-class) variance
![Page 28: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/28.jpg)
Recursive Algorithm
• Synopsis of the Otsu algorithm to find the threshold t
– Initializaion
– For m := 0 to MaxVal
– Limiar computation
)1()()1( 11 mPmwmw
)0()0(1 Pw
)1(
)1()1()()()1(
1
111
mw
mPmmmwm
)1(1
)1()1()1(
1
112
mw
mmwm
0)0(1
22111
2 )()()(1)()( mmmwmwmB
MaxVal
i
iiP0
)(
CRihiP /)()(
)(maxarg 2 mm Bm
t = 93
Original (MaxVal=255)
CVI - Binary Image Analysis 28
![Page 29: Chapter 3 Binary Image Analysis - ULisboa · Dilation and erosion – Generalization for monochromatic images Operação Rule Dilation The output pixel value is the maximum value](https://reader030.fdocuments.in/reader030/viewer/2022021609/5b5014457f8b9a206e8dbfaa/html5/thumbnails/29.jpg)
1 Compute histogram and probabilities of each intensity level
2 Set up initial \omega_i(0) and \mu_i(0)
3 Step through all possible thresholds t = 1 … maximum intensity
3.1 Update \omega_i and \mu_i
3.2 Compute \sigma^2_b(t)
4 Desired threshold corresponds to the maximum \sigma^2_b(t)
CVI - Binary Image Analysis 29