Title: CS 39549526: Spring 2003
1CS 395/495-26 Spring 2003
- IBMR Week 2 B2-D Projective Geometry
- Jack Tumblin
- jet_at_cs.northwestern.edu
2Admin Starter Code
- Website Ready Plans evolving...
- Starter Code Ready also evolves...
- About Your Projects
- Simple directory-based version control
- Save Number everything that worksNEVER edit
an unsaved working program - Always, Always One Little Step at a Time!
- Explain it as you write it (comments)Writing IS
thinking
3Admin Starter Code
- Website Ready Plans evolving...
- Starter Code Ready also evolves...
- About Your Projects
- Simple directory-based version control
- What works well for me
- One master directory for the project
- All files of latest version in one directory
- Numbered previous versions snapshot copies
- Copy master directory EVERY time something works.
- Program is ALWAYS working one step at a time...
- gt 1 hour without compile/run? too big a step!
42D Homogeneous Coordinates
- 3 coords, but only 2 degrees of freedom
(2DOF)(x1 / x3), (x2 / x3) - Ideal points (x,y,0)
-
- Line Intersections point
- (a 3D cross-product)
- Point Intersections line
- Duality P2 theorem for lines ?? P2 theorem for
points!
l1 ? l2 x
x1 ? x2 l
52D Homogeneous Coordinates
Left-Handed use x3 or (x,y,-1) image ctr, or...
- 3 coords, but only 2 degrees of freedom
(2DOF)(x1 / x3), (x2 / x3) - Ideal points (x,y,0)
-
- Line Intersections point
- (a 3D cross-product)
- Point Intersections line
- Duality P2 theorem for lines ?? P2 theorem for
points!
l1 ? l2 x
x1 ? x2 l
6Useful 3D Graphics Ideas
- Every xy point describes a 3D ray in (x1,x2,x3)
- Phantom dimension x3 is the z-buffer value
- Homogeneous coords allows translation matrix
- (BUT a 3x3 transform in R3 Euclidean Space
(x,y,z) cant translateonly rotate,scale, skew!)
Central Image Plane (x,y,1)
x y 1
1 0 3 0 1 5 0 0 1
x3 y5 1
x2
An Ideal Point (0,0,0) at Center of Projection
Ray
-x3
y
x1
x
x y z
1 0 3 0 1 5 0 0 1
xz yz z
7Projective Transform H
- Matrix H transforms Points
- Given a point x (x1,x2,x3) (or in P2
(x1/x3, x2/x3)) - x H x
- And H-T can also transform Lines
- Recall point x is on line l iff xTl 0
- Lines transform covariantly (points
contravariantly x Hx) - l H-T l
Line Homographies of many kinds are often
denoted by a star H
8Projective Transform H
2D image (x,y) ?? Homog. coords x,y,1T x
- Apply the 3x3 matrix H Hx x
Homog. coords x x,y,1T ?? 2D image
(x,y)
x
x
x2
(x,y)
y
x
y
y
y
x3
x
x
x
y
(x,y)
x2
x
9Projective Transform Hx x
Finding H from point pairs (correspondences)
x1 x2 x3
h11 h12 h13 h21 h22 h21 h31 h32 h33
x1 x2 x3
x y 1
Input (or output) image is on central plane
x1 x2 x3
x y
Write R2 expressions(for each x,x pair)
x (h31 x h32 y h33) (h11 x h12 y h13)
Rearrange, solve as a matrix problem
y (h31 x h32 y h33) (h11 x h12 y h13)
10Projective Transform Hx x
Finding H from point pairs (correspondences)
x1 x2 x3
h11 h12 h13 h21 h22 h21 h31 h32 h33
x1 x2 x3
x y 1
Input (or output) image is on central plane
x1 x2 x3
!STOP! You get Easier, Robust, but Partial
results using l? or conics methods! Lets try
them first. Later well return to this method
(called DLT direct linear xfm.)
x y
Write R2 expressions (for each x,x pair)
x (h31 x h32 y h33) (h11 x h12 y h13)
Rearrange, solve as a matrix problem
y (h31 x h32 y h33) (h11 x h12 y h13)
11Projective Transform H
- Comp. Graphics View interpolation notion
- Fixed, rigid 2D viewing point, viewing plane
- Rigid 2D world plane positioned in 3D (x1 x2
x3) - only 6 DOF world plane rotate position.
- Comp. Vision Projective Transform notion
- Fixed, rigid 2D viewing point, viewing plane
- Stretchy 2D world plane allow affine changes
- result (up to) 8 DOF
12 The bits and pieces of H
- H has 8 independent variables (DOF)
- Computer Graphics method (3x3 matrix)
- 2D Translation(tx, ty)3D Scale
(sx,sy,sz)3D Rotation (?x,?y,?z) - Computer Vision method(2D projective)
- Isometry --3DOF (2D translate tx,ty 2Drotate
?z ) - Similarity --4DOF (add uniform scale s)
- Affine --6DOF (add orientable scale s?,/s,
s??/s) - Projective--8DOF (changes x3 3D-rotation-like)
13 The bits and pieces of H
- H has 8 independent variables (DOF)
- Computer Graphics method (3x3 matrix)
- 2D Translation(tx, ty)3D Scale
(sx,sy,sz)3D Rotation (?x,?y,?z) - Computer Vision method(2D projective)
- Isometry --3DOF (2D translate tx,ty 2Drotate
?z ) - Similarity --4DOF (add uniform scale s)
- Affine --6DOF (add orientable scale s?,/s,
s??/s) - Projective--8DOF (changes x3 3D-rotation-like)
Affects only x1,x2
14 The bits and pieces of H
- H has 8 independent variables (DOF), not 9!
- Decomposable into 3 useful parts (pg 22)
- H HS HA HP
- Similarity HS
- 2D translate, rotate, uniform scale only (4DOF)
- Affine HA
- non-uniform scale (2DOF)
- Projective HP
- Projective coupling for x3 (2DOF)
?
?
?
sR t 0T 1
I 0 vT v
K 0 0T 1
?
?
?
?
?
?
?
?
?
?
?
?
15 The bits and pieces of H
- H has 8 independent variables (DOF), not 9!
- Decomposable into 3 useful parts (pg 22)
- H HS HA HP
- Similarity HS
- 2D translate, rotate, uniform scale only (4DOF)
- Affine HA
- non-uniform scale (2DOF)
- Projective HP
- Projective coupling for x3 (2DOF)
s ? cos? -s sin? tx s ? sin? s cos?
ty 0 0 1
1 0 0 0 1 0 v1 v2 vS
1 k2 0 k3 1 0 0 0 1
161-D Projective Geometry
- (?Why? we use it later)
- A side view of 2D projective geometry
- Convert R1 scalar b to a 2-vector in P1
- As with P2, we can transform points
- (use various H2x2 s to change cyan lines below)
b 1
H2b
H2a
171-D Projective Geometry
- What is invariant here?
- all the positions, lengths and ratios change
with each transform - Answer Cross Ratio cross(a,b,c,d)
- let a , b
- THEN
- cross abcd acbd
a
b
c
d
a
b
c
d
18Image Rectifying Undo parts of H
- x H x where H HS HA HP
- GOAL Put world plane x into view plane
- Affine Rect. (find only HP (2DOF))
- Similarity Rect. (find only HA HP (6DOF))
- Full Rect. (find all of H (8DOF))
-
- METHODS (mix match?)
- Full 4-point correspondence
- Vanishing Point, Infinity line methods
- Conics and circular points
19Image Rectifying Undo parts of H
- x H x where H HS HA HP
- GOAL Put world plane x into view plane
- Affine Rect. (find only HP (2DOF))
- Similarity Rect. (find only HA HP (6DOF))
- Full Rect. (find all of H (8DOF))
-
- METHODS (mix match?)
- Full 4-point correspondence
- Vanishing Point, Infinity line methods
- Conics and circular points
Other DOF? make assumptions, or ignore
20Vanishing-Point Methods 1
- In 2D image, find two pairs of lines that are
parallel in world space.
H
world space
2D image
21Vanishing-Point Methods 1
- Find intersection (vanishing points) p1, p2
- (compute line intersections with 3D
cross-products (see last lecture) - Horizon line Ih connects p1, p2.
Ih
p1
p2
H
world space
2D image
22Vanishing-Point Methods 1
- H-T transforms world infinity line l? ? (0,0,1)T
to Ih - Answer (see book) find, copy the lh coordinates!
- Hp
1 0 0 0 1 0 lh1 lh2 lh3
Ih
p1
p2
H
world space
2D image
23Vanishing-Point Methods 1
- Limitations
- Accurate point, line-finding can be tricky
- Can have high error sensitivity twitchy
- Only rectifies Hp-- but what if HA, HS needed?
Ih
p1
p2
H
world space
2D image
24Vanishing-Point Methods 2
- No parallel lines?
- find 2D image line with a known distance ratio
- Use Cross-Ratio (in P1 along that line) to
- Find vanishing point distance at point d
Ih
p1
p2
d
c
H
b
a
b
c
d(at infinity)
a
2D image
world space
25END --Please download the starter code, compile
and run. --Then you can get started on Project 1
right away.
26Conic Methods
- Better-behaved, easier to use (? maybe...)
- Determines HA HP (4DOF) (all but 2D trans, rot,
scale) - Must go back and review conics first (pg.8)
- Conics intersection of cone plane
- Many possible shapescircles, ellipses,
parabola, hyperbola, degenerates (lines points
27Conic Methods
- Equation of any/all conics solve a 2D quadratic
ax2 bxy cy2 dx ey f 0 - Write in homogeneous coordinates
- xTCx 0
- C is symmetric, 5DOF (not 6, because x3 scaling)
- Find any C from 5 homogeneous points (solve
for null spacesee book pg 9)
x1 x2 x3
a b/2 d/2 b/2 c e/2 d/2 e/2
f
x1 x2 x3
0
a Point Conic
28Conic Methods
- Matrix C makes conics from points xTCx
0 C is a point conic - Given a point x on a conic curve, the homog.
tangent line l is given by l C x - Matrix C makes conics from lines
- lTCl 0 C is a Dual Conic
- defined by tangent lines l instead of points.
29Conic Methods
- If C is non-singular (rank 3), then C C-1
- If C (or C) has
- Rank 3 it is an ellipse, circle, parab.,
hyperb. - Rank 2 it is a pair of lines (forms an x)
- THE BIG IDEA---MOST USEFUL PROPERTYProjective
transform of a conic C is conic C - C H-T C H-1