Binary Image Analysis
Binary Image Analysis
Binary Image Analysis
00010010001000
00011110001000
00010010001000
1
Binary Image Analysis
• is used in a number of practical applications
• part inspection
• riveting
• fish counting
• document processing
2
What kinds of operations?
4
Results of analysis
63 separate
objects
detected
Single cells
have area
about 50
Noise spots
Gobs of cells
5
Useful Operations
6
Thresholding
Background is black
Healthy cherry is
bright
Bruise is medium dark
Histogram shows two
cherry regions (black
background has been
removed)
pixel
counts
0 256
gray-tone values 7
Histogram-Directed Thresholding
Grp 1 Grp 2
Assumption: the histogram is bimodal
10
Connected Components Labeling
Once you have a binary image, you can identify and
then analyze each connected set of pixels.
11
Methods for CC Analysis
1. Recursive Tracking (almost never used)
12
Equivalent Labels
Original Binary Image
0 0 0 1 1 1 0 0 0 0111100001
0 0 0 1 1 1 1 0 0 0111100011
0 0 0 1 1 1 1 1 0 0111100111
0 0 0 1 1 1 1 1 1 0111100111
0 0 0 1 1 1 1 1 1 1111100111
0 0 0 1 1 1 1 1 1 1111100111
0 0 0 1 1 1 1 1 1 1111111111
0 0 0 1 1 1 1 1 1 1111111111
0 0 0 1 1 1 1 1 1 0000011111
13
Equivalent Labels
The Labeling Process
0001110000222200003 12
0001111000222200033 13
0001111100222200333
0001111110222200333
0001111111111100333
0001111111111100333
0001111111111111111
0001111111111111111
0001111110000011111
14
Run-Length Data Structure
01234
0 11 11
row scol ecol label
1 11 1
2 1 1 1 1 Binary 0 UNUSED 0
3 Image 1
0 0 1 0
4 1111 2
0 3 4 0
3
1 0 1 0
Rstart Rend 4
1 4 4 0
01 2 5
2 0 2 0
13 4 6
2 4 4 0
25 6 Row Index 7
4 1 4 0
30 0
Runs
47 7 15
Run-Length Algorithm
Procedure run_length_classical
{
initialize Run-Length and Union-Find data structures
count <- 0
16
Case 1: No Overlap
Q Q
/* new label */
count <- count + 1 /* check Q’s next run */
label(P) <- count Q <- Q + 1
P <- P + 1
17
Case 2: Overlap
Subcase 1: Subcase 2:
P’s run has no label yet P’s run has a label that is
different from Q’s run
Q Q
|///////| |/////| |///////| |/////|
|/////////////| |/////////////|
P P
label(P) <- label(Q) union(label(P),label(Q))
move pointer(s) move pointer(s)
}
18
Pass 2 (by runs)
/* Relabel each run with the name of the
equivalence class of its label */
For each run M
{
label(M) <- find(label(M))
}
}
where union and find refer to the operations of the
Union-Find data structure, which keeps track of sets
of equivalent labels.
19
Labeling shown as Pseudo-Color
connected
components
of 1’s from
thresholded
image
connected
components
of cluster
labels
20
Mathematical Morphology
Binary mathematical morphology consists of two
basic operations
21
Dilation
Dilation expands the connected sets of 1s of a binary image.
1. growing features
22
Erosion
Erosion shrinks the connected sets of 1s of a binary image.
1. shrinking features
23
Structuring Elements
box
hexagon disk
something
box(length,width) disk(diameter)
24
Dilation with Structuring Elements
The arguments to dilation and erosion are
1. a binary image B
2. a structuring element S
origin
0 0 1 1 0 0 0 0 0 0
1 erode
0 0 1 1 0 0 0 1 1 0
1
0 0 1 1 0 0 0 1 1 0
1
1 1 1 1 1 0 0 0 0 0
B S B S
26
Example 1 to Try
0 0 1 0 0 1 0 0
0 0 1 1 1 1 1 0
1 1 1 1 1 1 0 0 S
B 1 1 1 1 1 1 1 1
111 erode
0 0 1 1 1 1 0 0
111
0 0 1 1 1 1 0 0
111
0 0 1 1 1 1 0 0
27
Example 2 to Try
B
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
S
0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 0
0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1
0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1
0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 0
0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
29
Gear Tooth Inspection
original
binary
image
How did
they do it?
detected
defects
30
Region Properties
Properties of the regions can be used to recognize objects.
• gray-tone properties
• color properties
• texture properties
• motion properties
• relationship properties (1 in Ch 3)
31
Geometric and Shape Properties
• area
• centroid
• perimeter
• perimeter length
• circularity
• elongation
• mean and standard deviation of radial distance
• bounding box
• extremal axis length from bounding box
• second order moments (row, column, mixed)
• lengths and orientations of axes of best-fit ellipse
32
Region Adjacency Graph
33