Binary Images

advertisement
3-D Computer Vision
CSc 83020
Binary Images
Horn (Robot Vision): pages 46-64.
3-D Computer Vision CSc 83020 – Ioannis Stamos
Binary Images
Binary Image b(x,y): Obtained from Gray-Level (or other image) g(x,y)
By Thresholding.
Characteristic Function:
1 g(x,y) < T
b(x,y)=
0 g(x,y) >= T
1)
2)
3)
4)
Geometrical Properties
Discrete Binary Images
Multiple objects
Sequential and Iterative Processing.
3-D Computer Vision CSc 83020 – Ioannis Stamos
Selecting the Threshold (T)
g(x,y)
h(i)
BIMODAL
HISTOGRAM
T
b(x,y)
3-D Computer Vision CSc 83020 – Ioannis Stamos
i (intensity)
Histogram Thresholding
T
3-D Computer Vision CSc 83020 – Ioannis Stamos
Geometric Properties
Assume:
1) b(x,y) is continuous
2) Only one object
y
b(x,y)
x
3-D Computer Vision CSc 83020 – Ioannis Stamos
Geometric Properties
Assume:
1) b(x,y) is continuous
2) Only one object
y
b(x,y)
x
Area:
A   b( x, y )dxdy
(Zeroth Moment)
I
3-D Computer Vision CSc 83020 – Ioannis Stamos
Geometric Properties
Assume:
1) b(x,y) is continuous
2) Only one object
y
b(x,y)
x
Area:
A   b( x, y )dxdy
(Zeroth Moment)
I
Position: “Center” (x,y) of Area
_
x  (1 / A)  x * b( x, y )dxdy
(First Moment)
I
_
y  (1 / A)  y * b( x, y )dxdy
I
3-D Computer
Vision CSc 83020 – Ioannis Stamos
Orientation
Difficult to define!
We use axis of least second moment
y
(x,y)
axis
r
ρ
θ
3-D Computer Vision CSc 83020 – Ioannis Stamos
x
Orientation
Difficult to define!
We use axis of least second moment
For mass distribution: Axis of minimum Inertia.
y
(x,y)
axis
r
ρ
θ
Minimize:
E   r b( x, y )dxdy
2
I
3-D Computer Vision CSc 83020 – Ioannis Stamos
x
Orientation
Difficult to define!
We use axis of least second moment
For mass distribution: Axis of minimum Inertia.
y
(x,y)
axis
r
ρ
x
θ
Minimize:
E   r b( x, y )dxdy
2
I
Equation of Axis: y=mx+b ???
0<= m <= infinity
x sin( )  y cos( )    0
We use:
(ρ, θ) finite.
Find (ρ, θ) that minimize E for a given b(x,y)
r 2  ( x sin( )  y cos( )   )2
We can show that:
So:
E   ( x sin( )  y cos(  )   )2 b( x, y )dxdy
I
3-D Computer Vision CSc 83020 – Ioannis Stamos
r 2  ( x sin( )  y cos( )   )2
We can show that:
So:
E   ( x sin( )  y cos(  )   )2 b( x, y )dxdy
I
_
Using dE/dρ=0 we get:
_
A( x sin( )  y cos( )   )  0
3-D Computer Vision CSc 83020 – Ioannis Stamos
r 2  ( x sin( )  y cos( )   )2
We can show that:
So:
E   ( x sin( )  y cos(  )   )2 b( x, y )dxdy
I
_
Using dE/dρ=0 we get:
_
A( x sin( )  y cos( )   )  0
Note: Axis passes through center (x,y)!!
So, change coordinates: x’=x-x, y’=y-y
3-D Computer Vision CSc 83020 – Ioannis Stamos
r 2  ( x sin( )  y cos( )   )2
We can show that:
So:
E   ( x sin( )  y cos(  )   )2 b( x, y )dxdy
I
_
Using dE/dρ=0 we get:
_
A( x sin( )  y cos( )   )  0
Note: Axis passes through center (x,y)!!
So, change coordinates: x’=x-x, y’=y-y
2
2
2
E

a
sin
(

)

b
sin
(

)
cos(

)

c
cos
( )
We get:
a   ( x ' ) 2 b( x, y )dx'dy'
I
b  2  ( x ' y ' )b( x, y )dx'dy'
I
Second Moments
w.r.t.
(x, y)
c   ( y ' ) 2 b( x, y )dx'dy'
I3-D Computer Vision CSc 83020 – Ioannis Stamos
r 2  ( x sin( )  y cos( )   )2
We can show that:
So:
E   ( x sin( )  y cos(  )   )2 b( x, y )dxdy
I
_
Using dE/dρ=0 we get:
_
A( x sin( )  y cos( )   )  0
Note: Axis passes through center (x,y)!!
So, change coordinates: x’=x-x, y’=y-y
2
2
2
E

a
sin
(

)

b
sin
(

)
cos(

)

c
cos
( )
We get:
a   ( x ' ) 2 b( x, y )dx'dy'
I
Mistake in
your
handout.
b  2  ( x ' y ' )b( x, y )dx'dy'
I
Second Moments
w.r.t.
(x, y)
c   ( y ' ) 2 b( x, y )dx'dy'
I3-D Computer Vision CSc 83020 – Ioannis Stamos
E  a sin 2 ( )  b sin ( ) cos( )  c cos2 ( )
Using dE/dθ=0, we get: tan(2θ)=b/(a-c)
b2  (a  c)2
2θ
a-c
3-D Computer Vision CSc 83020 – Ioannis Stamos
b
E  a sin 2 ( )  b sin( ) cos( )  c cos2 ( )
Using dE/dθ=0, we get: tan(2θ)=b/(a-c)
b2  (a  c)2
2θ
a-c
So:
sin(2 )  b / b2  (a  c)2
cos(2 )  (a  c) / b  (a  c)
2
2
3-D Computer Vision CSc 83020 – Ioannis Stamos
b
E  a sin 2 ( )  b sin 2 ( ) cos( )  c cos2 ( )
Using dE/dθ=0, we get: tan(2θ)=b/(a-c)
b2  (a  c)2
2θ
a-c
So:
sin(2 )  b / b2  (a  c)2
cos(2 )  (a  c) / b  (a  c)
2
b
2
Solutions with positive sign may be used to find θ that minimizes
E (why??).
Emin/Emax -> (ROUDNESS of the OBJECT).
3-D Computer Vision CSc 83020 – Ioannis Stamos
Discrete Binary Images
bij: value at pixel in row i & column j.
j (y)
O
i
(x)
n
1
1
1 11 1 1
1 1 1 1 1
1 1 1
1
1
3-D Computer Vision CSc 83020 – Ioannis Stamos
m
Discrete Binary Images
bij: value at pixel in row i & column j.
O
Assume pixel area is 1.
n m
Area:
A   bij
i 1 j 1
i
(x)
Position (Center of Area): n
_
n
m
i 1
j 1
n
m
i 1
j 1
x  (1 / A)  ibij
_
j (y)
1
1
1 11 1 1
1 1 1 1 1
1 1 1
1
1
y  (1 / A)  jbij
3-D Computer Vision CSc 83020 – Ioannis Stamos
m
Discrete Binary Images
bij: value at pixel in row i & column j.
O
Assume pixel area is 1.
n m
Area:
A   bij
i 1 j 1
n
m
i 1
j 1
1
1
1 11 1 1
1 1 1 1 1
1 1 1
1
1
n
m
i 1
j 1
x  (1 / A)  ibij
_
m
i
(x)
Position (Center of Area): n
_
j (y)
y  (1 / A)  jbij
Second Moments.
a' 
n
m
n
m
2
'
'
i
b
,
b

2
ij
b
,
c

 3-DijComputer Vision CSc

ij
83020 – Ioannis Stamos
i 1
j 1
i 1
j 1
n
m

i 1
j 1
j 2bij
Discrete Binary Images (cont)
Note: a’,b’,c’ are second moments w.r.t ORIGIN
a,b,c (w.r.t “center”) can be found from
(a’,b’,c’,x,y,A).
Note: UPDATE (a’,b’,c’,x,y,A) during RASTER SCAN.
3-D Computer Vision CSc 83020 – Ioannis Stamos
Multiple Objects
Need to SEGMENT image into separate COMPONENTS
(regions).
Connected Component:
Maximal Set of Connected Points:
B
A
Points A and B are connected: Path exists between A and
B along which b(x,y) is constant.
3-D Computer Vision CSc 83020 – Ioannis Stamos
Connected Components
4-way connected 8-way connected
Label all pixels that are connected
3-D Computer Vision CSc 83020 – Ioannis Stamos
Region Growing Algorithm
(Connected Component Labeling)




Start with “seed” point where bij=1.
Assign LABEL to seed point.
Assign SAME LABEL to its NEIGHBORS (b=1).
Assign SAME LABEL to NEIGHBORS of
NEIGHBORS.
Terminates when a component is completely labeled.
Then pick another UNLABELED seed point.
3-D Computer Vision CSc 83020 – Ioannis Stamos
What do we mean by NEIGHBORS?
Connectedness
8-Connectedness (8-c)
4-Connectedness (4-c)
Neither is perfect!
3-D Computer Vision CSc 83020 – Ioannis Stamos
What do we mean by NEIGHBORS?
Jordan’s Curve Theorem: Closed curve -> 2 connected regions
0
1
0
B1 O1 B1
1
0
1
O2 B2 O3
0
1
0
(4-c) B1 O4 B1
Hole without closed curve!
3-D Computer Vision CSc 83020 – Ioannis Stamos
What do we mean by NEIGHBORS?
Jordan’s Curve Theorem: Closed curve -> 2 connected regions
0
1
0
B1 O1 B1
B O
B
1
0
1
O2 B2 O3
O
O
0
B
(8-c)
1 0
(4-c) B1 O4 B1
ConnectedB O
Hole without closed curve! background
with closed ring!
B
Solution: Introduce Assymetry
Use:
or
(a)
Using
(a)
(b)
0
1
0
B O1 B
1
0
1
O2 B
0
1
0
B
Hexagonal
Tesselation
O1
Two separate line
segments.
O2 B
Above assymetry makes
SQUARE grid like
HEXAGONAL grid.
3-D Computer Vision CSc 83020 – Ioannis Stamos
Sequential Labeling Algorithm
D
B
C A
Raster Scan
Note: B,C,D are already labeled
3-D Computer Vision CSc 83020 – Ioannis Stamos
Sequential Labeling Algorithm
D
a.
b.
B
Raster Scan
C A
Note: B,C,D are already labeled
X
X
Label(A) = background
X
0
D
X
X
1
Label(A) = label(D)
3-D Computer Vision CSc 83020 – Ioannis Stamos
Sequential Labeling Algorithm
D
c.
d.
d.
B
Raster Scan
C A
Note: B,C,D are already labeled
0
0
Label(A) = label(C)
C
1
0
B
0
1
0
B
C
1
Label(A) = label(B)
If Label(B) = label(C ), then Label(A)=Label(B)=
3-D Computer Vision CSc 83020 – Ioannis Stamos
Label(C)
Sequential Labeling Algorithm
D
a.
b.
c.
d.
d.
B
Raster Scan
C A
Note: B,C,D are already labeled
X
X
Label(A) = background
X
0
D
X
X
1
0
0
C
1
0
B
0
1
0
B
C
1
Label(A) = label(D)
Label(A) = label(C)
Label(A) = label(B)
If Label(B) = label(C ), then Label(A)=Label(B)=
3-D Computer Vision CSc 83020 – Ioannis Stamos
Label(C)
Sequential Labeling (Cont.)
What if B & C are labeled but label(B)  label(C) ?
3-D Computer Vision CSc 83020 – Ioannis Stamos
Sequential Labeling (Cont.)
What if B & C are labeled but label(B)  label(C) ?
2
22
22
2222
2
2
2
2
1
1
2
1
222
1 1
222
2 2 2 22 2 2 2 2 ?
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
111
111
111
3-D Computer Vision CSc 83020 – Ioannis Stamos
Sequential Labeling (Cont.)
Solution: Let: Label(A)=Label(B) =2
& create an EQUIVALENCE TABLE.
Resolve Equivalences in SECOND PASS.
21
7  3,6,4
…
3-D Computer Vision CSc 83020 – Ioannis Stamos
Download