cs 395/495-26: spring 2004 ibmr: 2-d projective geometry --introduction-- jack tumblin...

40
CS 395/495-26: Spring CS 395/495-26: Spring 2004 2004 IBMR: IBMR: 2-D Projective Geometry 2-D Projective Geometry --Introduction-- --Introduction-- Jack Tumblin Jack Tumblin [email protected] [email protected]

Post on 20-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

CS 395/495-26: Spring 2004CS 395/495-26: Spring 2004

IBMR: IBMR: 2-D Projective Geometry2-D Projective Geometry

--Introduction----Introduction--

Jack TumblinJack Tumblin

[email protected]@cs.northwestern.edu

Page 2: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Recall: Scene & ImageRecall: Scene & Image

Light + 3D Scene:Light + 3D Scene:Illumination, Illumination,

shape, movement, shape, movement, surface BRDF,… surface BRDF,…

Image PlaneImage PlaneI(x,y)I(x,y)

Ang

le(

Ang

le(

,, ))

Pos

ition

(x,y

)P

ositi

on(x

,y)

2D Image:2D Image:Collection of rays Collection of rays

through a point through a point

GOAL: a Reversible MappingGOAL: a Reversible MappingScene anglesScene angles image positions image positions

Page 3: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

View Interpolation: How?View Interpolation: How?

• LATER:LATER: 3D Projection 3D Projection(Hartley,Zisserman Chapter 2)(Hartley,Zisserman Chapter 2)

From a 3D sceneFrom a 3D scene Find new views of that sceneFind new views of that scene

view1view1view2view2

Page 4: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

View Interpolation: How?View Interpolation: How?

• BUT FIRST,BUT FIRST, the simpler case the simpler caseHartley, Zisserman Chapter 1: 2D ProjectionHartley, Zisserman Chapter 1: 2D Projection

From a flat 2D image, From a flat 2D image, Find new views of Find new views of thatthat image image

view1view1view2view2

Page 5: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Answer: 2D Homogeneous CoordsAnswer: 2D Homogeneous Coords

Chapter 1: 2D ProjectionChapter 1: 2D Projection

From a flat 2D image,From a flat 2D image, Find new views of that image Find new views of that image

view1view1view2view2

Cartesian (x,y) Cartesian (x,y)

coordinates in coordinates in RR22

2D Homogeneous (2D Homogeneous (x1 x2 x3) )

coordinates in coordinates in PP22

Page 6: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

OverviewOverview

• Chapter 1: Chapter 1: anyany 2D plane, as seen by 2D plane, as seen by anyany 3D camera view 3D camera view (texture mapping (texture mapping

generalized)generalized)

• Homogeneous Coordinates are WonderfulHomogeneous Coordinates are Wonderful

• Everything is a Matrix: Everything is a Matrix: – Conics (you can skip for now) Conics (you can skip for now) – Aside: interpolation of pixels and points…Aside: interpolation of pixels and points…

• Transform your Point of View: Transform your Point of View: HH matrix matrix

• Parts of Parts of HH: useful kinds of Transforms: useful kinds of Transforms

Page 7: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

2-D Homogeneous Coordinates2-D Homogeneous Coordinates

• WHY? makes WHY? makes MUCHMUCH cleaner math! cleaner math!– Unifies lines and pointsUnifies lines and points– Puts perspective projection into matrix formPuts perspective projection into matrix form– NoNo divide-by-zero; defines horizon, infinities … divide-by-zero; defines horizon, infinities …

xx

yy

But in But in PP22, write , write same point same point xx as aswhere:where:

(x,y)(x,y)

in in RR22, , write point write point xx as as

xy

x1 x2 x3 x = x1 / x3,

y = x2 / x3,x3 = anything non-zero! (but usually defaults to 1)

Page 8: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

• Every Homog. point (xEvery Homog. point (x11,x,x22,x,x33) describes a ) describes a 3D ray3D ray

• ‘‘Phantom’ dimension xPhantom’ dimension x3 3 is the ‘z-buffer’ valueis the ‘z-buffer’ value

• 3D3D2D ‘hard-wired’:2D ‘hard-wired’:

(Fig 1.1, pg 8)(Fig 1.1, pg 8)

• ““Homogeneous coords allows translation matrix:”Homogeneous coords allows translation matrix:” (true. (true. But there is more!) But there is more!)

Useful 3D Graphics IdeasUseful 3D Graphics Ideas

(0,0

,-1)

(0,0

,-1) (x(xmaxmax, y, ymaxmax, -1), -1)

An ‘Ideal Point’ at (0,0,0)An ‘Ideal Point’ at (0,0,0)CCenter enter oof f PProjectionrojection

x x y =y =1 1

1 0 31 0 30 1 50 1 50 0 10 0 1

x+3 x+3 y+5y+51 1

‘‘Image Plane’ (x,y,-1)Image Plane’ (x,y,-1)

Page 9: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

2-D Homogeneous Coordinates2-D Homogeneous Coordinates

WHAT?!WHAT?! Why Why x3? Why ‘default’ value of 1? Why ‘default’ value of 1?

• Look at lines in Look at lines in RR2 2 ::– ‘‘line’ == all (x,y) points whereline’ == all (x,y) points where– scale by ‘k’ scale by ‘k’ no change: no change:

• Using ‘Using ‘xx33’ for points ’ for points UNIFIESUNIFIES notation: notation:

– line is a 3-vector named line is a 3-vector named ll– now point (x,y) is a 3-vector too, named now point (x,y) is a 3-vector too, named xx

ax + by + c = 0

kax + kby + kc = 0

ax + by + c = 0 = 0x1 x2 x3 abc

xxT.T.l l = = 00

Page 10: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

ll11 l l22 = =

xxxx11 x x22 = =

ll

2D Homogeneous Coordinates2D Homogeneous Coordinates

Important PropertiesImportant Properties 1 1(see book for details)(see book for details)

• 3 coordinates, but only 3 coordinates, but only 2 degrees of freedom2 degrees of freedom(only 2 ratios (only 2 ratios (x(x1 1 / x/ x33), (x), (x2 2 / x/ x33)) can change) can change)

• DUALITY:DUALITY: points, lines are interchangeable points, lines are interchangeable

– Line Intersections = point:Line Intersections = point: (a 3D (a 3D

cross-product)cross-product)– Point ‘Intersections’ = line:Point ‘Intersections’ = line:

– Projective theorem for lines Projective theorem for lines theorem for points! theorem for points!

Page 11: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Homogeneous CoordinatesHomogeneous Coordinates

Important PropertiesImportant Properties 2 2(see book for details)(see book for details)

• Neatly Sidesteps ‘divide-by-zero’: Neatly Sidesteps ‘divide-by-zero’: – in (x,y) space (in (x,y) space (RR22))

– Remember, we store Remember, we store (x(x1 1 ,x,x22, x, x33))TT, ,

then compute then compute (x(x1 1 / x/ x33), (x), (x2 2 / x/ x33)) onlyonly if OK. if OK.

• ““OK, yeah, sure, but so what?” ...OK, yeah, sure, but so what?” ...

Page 12: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Homogeneous CoordinatesHomogeneous Coordinates

Why is deferring divide-by-zero so important?Why is deferring divide-by-zero so important?

• Cleanly Defines all ‘Points at Infinity’ or Cleanly Defines all ‘Points at Infinity’ or ‘Ideal Points’ ‘Ideal Points’ (x,y,0)(x,y,0)TT

– ==outermost pixels (+/-==outermost pixels (+/-, +/-, +/-) of an infinite image plane ((x,y), or ) of an infinite image plane ((x,y), or RR22))

– (x,y,0) is an entire plane of points in the (x,y,0) is an entire plane of points in the

(semi-bogus) 3D space (semi-bogus) 3D space (x(x1 1 ,x,x22, x, x33))T T spacespace

– but it is a ‘circle around infinity’ in the but it is a ‘circle around infinity’ in the

(legitimate) (legitimate) PP22 projective space projective space (x(x1 1 /x/x33, x, x2 2 /x/x33))TT

– Note! ‘Center of Projection’ is an ideal point. Note! ‘Center of Projection’ is an ideal point. (Do outer limits of image plane ‘wrap around’ to that point?!?!)(Do outer limits of image plane ‘wrap around’ to that point?!?!)

Page 13: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Homogeneous CoordinatesHomogeneous Coordinates

Why is deferring divide-by-zero so important?Why is deferring divide-by-zero so important?

Cleanly defines one ‘Line at infinity’ Cleanly defines one ‘Line at infinity’ ll (0,0,1) (0,0,1)TT, or “0x +0y +1=0”, or “0x +0y +1=0”

• All ideal points are on All ideal points are on ll: proof? : proof? ll••(x(x11,x,x22,0),0)TT = 0 = 0

• Any line Any line ll intersects with intersects with ll line at an ideal pointline at an ideal point

• Two parallel lines Two parallel lines ll and and l’l’ always meet at an ideal point always meet at an ideal point

Let Let l = (a,b,c)l = (a,b,c)T T andand l’ = (a,b,c’) l’ = (a,b,c’)TT … …(page 7)(page 7)

Page 14: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Homogeneous CoordinatesHomogeneous Coordinates

Important PropertiesImportant Properties 3 3(see book for details)(see book for details)

• View Interpolation (‘Projective Transform’)View Interpolation (‘Projective Transform’)– ‘‘Central’ image plane (x,y,-1)Central’ image plane (x,y,-1)TT

• Choose a known point Choose a known point x’x’

– Apply 3x3 Matrix Apply 3x3 Matrix HH to (x,y,-1) to (x,y,-1)TT

to make point on OTHER planeto make point on OTHER plane• Ray through Ray through knownknown point point x’ x’

pierces pierces ununknown point known point xx

(0,0

,-1)

(0,0

,-1) ‘‘Image Plane’Image Plane’

(x,y,-1)(x,y,-1)

(0,0,0)(0,0,0)

xx

x’x’

x1 x2 x3

h11 h12 h13 h21 h22 h21 h31 h32 h33

= x’1 x’2 x’3

H x = x’H x = x’

3D w

orld plane

3D w

orld plane

Page 15: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

ENDEND

Page 16: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

• Every Every xyxy point describes a point describes a 3D ray 3D ray in in (x(x11,x,x22,x,x33))• ‘‘Phantom’ dimension xPhantom’ dimension x3 3 is the is the (lost)(lost) distance-to-camera distance-to-camera • Homogeneous coords allows matrix for 2-D translation:Homogeneous coords allows matrix for 2-D translation:

• ((BUTBUT a 3x3 transform in a 3x3 transform in RR33 Euclidean Space (x,y,z) Euclidean Space (x,y,z) can’tcan’t translate—only rotate,scale, skew!) translate—only rotate,scale, skew!)

Useful 3D Graphics IdeasUseful 3D Graphics Ideas

An ‘Ideal Point’ An ‘Ideal Point’ (0,0,0) at(0,0,0) at CCenter enter oof f PProjectionrojection

x x y =y =1 1

1 0 31 0 30 1 50 1 50 0 10 0 1

x+3 x+3 y+5y+51 1

‘‘Central Image Central Image Plane’ (x,y,1)Plane’ (x,y,1)

-x-x33

xx22

xx11

x x y =y =z z

1 0 31 0 30 1 50 1 50 0 10 0 1

x+z x+z y+zy+zz z

RayRay

Page 17: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

ll11 l l22 = =

xxxx11 x x22 = =

ll

2D Homogeneous Coordinates2D Homogeneous Coordinates

• 3 coords, but only 3 coords, but only 2 degrees of freedom (2DOF)2 degrees of freedom (2DOF)(x(x1 1 / x/ x33), (x), (x2 2 / x/ x33))

– Ideal points == Ideal points == (x,y,0)(x,y,0)(every line hits the horizon at an ideal point)(every line hits the horizon at an ideal point)

– Line Intersections = point:Line Intersections = point: (a 3D (a 3D

cross-product)cross-product)– Point ‘Intersections’ = line:Point ‘Intersections’ = line:

– Duality: PDuality: P22 theorem for lines theorem for lines P P22 theorem for points! theorem for points!

An ‘Ideal Point’ An ‘Ideal Point’ (0,0,0) at(0,0,0) at CCenter enter oof f PProjectionrojection

‘‘Central Image Central Image Plane’ (x,y,1)Plane’ (x,y,1)

-x-x33

xx22

xx11

RayRay

Page 18: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

ll11 l l22 = =

xxxx11 x x22 = =

ll

2D Homogeneous Coordinates2D Homogeneous Coordinates

• 3 coords, but only 3 coords, but only 2 degrees of freedom (2DOF)2 degrees of freedom (2DOF)(x(x1 1 / x/ x33), (x), (x2 2 / x/ x33))

– Ideal points == Ideal points == (x,y,0)(x,y,0) – Line Intersections = point:Line Intersections = point:

(a 3D (a 3D cross-product)cross-product)

– Point ‘Intersections’ = line:Point ‘Intersections’ = line:

– Duality: PDuality: P22 theorem for lines theorem for lines P P22 theorem for points! theorem for points!

An ‘Ideal Point’ An ‘Ideal Point’ (0,0,0) at(0,0,0) at CCenter enter oof f PProjectionrojection

‘‘Central Image Central Image Plane’ (x,y,1)Plane’ (x,y,1)

-x-x33

xx22

xx11

RayRay

Left-Handed: use –xLeft-Handed: use –x33 or or

(x,y,-1) image ctr, or...(x,y,-1) image ctr, or...

Page 19: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

x’x’

Apply the Apply the 3x3 matrix 3x3 matrix HH

x’ = Hx x’ = Hx

Projective Transform Projective Transform HH

xx33

xx22

xx11

xx

yy

x’x’

y’y’

(x,y)(x,y) xx

(x’,y’)(x’,y’)

Homog. coordsHomog. coords x’ =x’ = [x’,y’,1][x’,y’,1]TT

2D image 2D image (x’,y’)(x’,y’)

2D image 2D image (x,y)(x,y)

Homog. coords Homog. coords

[x,y,1][x,y,1]TT = x = x

Page 20: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

x’x’

Apply the Apply the 3x3 matrix 3x3 matrix HH

x’ = Hx x’ = Hx

Recall: Projective Transform Recall: Projective Transform HH

xx33

xx22

xx11

xx

yy

x’x’

y’y’

(x,y)(x,y) xx

(x’,y’)(x’,y’)

Homog. coordsHomog. coords x’ =x’ = [x’,y’,1][x’,y’,1]TT

2D image 2D image (x’,y’)(x’,y’)

2D image 2D image (x,y)(x,y)

Homog. coords Homog. coords

[x,y,1][x,y,1]TT = x = x

Goal: Find H forGoal: Find H for‘‘Image Rectification’Image Rectification’

‘‘World Plane’World Plane’ ‘‘View Plane’View Plane’

Page 21: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

H matrix: Plane-to-Plane mappingH matrix: Plane-to-Plane mapping

What if What if HH is unknown, is unknown,

but we have four or morebut we have four or more

pairs of x,x’ points?pairs of x,x’ points?(see pg 15, Zisserman)(see pg 15, Zisserman)

xx11, x, x22, x, x33, x, x44, ,

x’x’11, x’, x’22, x’, x’33, x’, x’44 … …

Projective Transform Projective Transform HH

(0,0

,-1)

(0,0

,-1) ‘‘Image Plane’Image Plane’

(x,y,-1)(x,y,-1)

(0,0,0)(0,0,0)

xx

x’x’

xx11

xx22

xx33

hh11 11 h h1212 h h1313

hh2121 h h2222 h h2121

hh3131 h h32 32 h h3333 = =

x’x’11

x’x’22

x’x’33

H x’ = xH x’ = x

Page 22: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Projective Transform: Projective Transform: HH

• Matrix Matrix HH transforms Points: transforms Points:– Given a point Given a point xx: : (x(x11,x,x22,x,x33)) (or in R (or in R2 2 : : (x(x11/x/x33, x, x22/x/x33))))

x’ = Hx’ = H xx

• And matrix And matrix HH-T-T transform Lines: transform Lines: – Given a line Given a line ll: : (a,b,c) (a,b,c)

in R in R2 2 : : (a(a··x+ bx+ b··y + c = 0y + c = 0)) in P in P2 2 : : (a(a··xx11 + b + b··xx22 + c + c··xx33

= 0= 0) ) l’ = Hl’ = H-T -T ll

Recall point Recall point xx is on line is on line ll iff iff xxTTll =0 =0Jargon:Jargon: points transform ‘covariantly’; lines transform ‘contravariantly’ points transform ‘covariantly’; lines transform ‘contravariantly’

Page 23: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

The bits and pieces of The bits and pieces of HH

HH has 8 independent variables (DOF) has 8 independent variables (DOF)• Cartesian (‘3D’) decomposition:Cartesian (‘3D’) decomposition:

2D Translation2D Translation(t(txx, t, tyy))3D Scale 3D Scale (s(sxx,s,sy,y,sszz))3D Rotation 3D Rotation ((xx,,yy,,zz))

• Computer Vision (Projective 2D) decomp.Computer Vision (Projective 2D) decomp.Isometry Isometry --3DOF (2D translate --3DOF (2D translate ttxx,t,tyy; 2D rotate ; 2D rotate zz; ); )

Similarity Similarity --4DOF (add uniform scale --4DOF (add uniform scale s;s;))

AffineAffine --6DOF (add orientable scale --6DOF (add orientable scale ss,/s, s,/s, s/s/s))

ProjectiveProjective--8DOF (changes --8DOF (changes xx33; 3D-rotation-like); 3D-rotation-like)

Page 24: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

The bits and pieces of The bits and pieces of HH

HH has 8 independent variables (DOF) has 8 independent variables (DOF)• Computer Graphics method (3x3 matrix):Computer Graphics method (3x3 matrix):

2D Translation2D Translation(t(txx, t, tyy))3D Scale 3D Scale (s(sxx,s,sy,y,sszz))3D Rotation 3D Rotation ((xx,,yy,,zz))

• Computer Vision method(2D projective):Computer Vision method(2D projective):Isometry Isometry --3DOF (2D translate --3DOF (2D translate ttxx,t,tyy; 2Drotate ; 2Drotate zz; ); )

Similarity Similarity --4DOF (add uniform scale --4DOF (add uniform scale s;s;))

AffineAffine --6DOF (add orientable scale --6DOF (add orientable scale ss,/s, s,/s, s/s/s))

ProjectiveProjective--8DOF (changes --8DOF (changes xx33; 3D-rotation-like); 3D-rotation-like)

Affects only x1,x2Affects only x1,x2

Page 25: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

The bits and pieces of The bits and pieces of HH

HH has has 88 independent variables (DOF), not 9! independent variables (DOF), not 9!• Decomposable into 3 useful parts: Decomposable into 3 useful parts: (pg 22)(pg 22)

H = HH = HSS H HA A HHP P ==

• Similarity Similarity HHSS: : • 2D translate, rotate, uniform scale only (4DOF)2D translate, rotate, uniform scale only (4DOF)

• Affine Affine HHAA: : • non-uniform scale (2DOF)non-uniform scale (2DOF)

• Projective Projective HHPP::• Projective coupling for xProjective coupling for x3 3 (2DOF)(2DOF)

ssRR tt

00TT 11

II 00

vvTT vv

KK 00

00TT 11

Page 26: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

HH has has 88 independent variables (DOF), not 9! independent variables (DOF), not 9!• Decomposable into 3 useful parts: Decomposable into 3 useful parts: (pg 22)(pg 22)

H = HH = HSS H HA A HHP P ==

• Similarity Similarity HHSS: : • 2D translate, rotate, uniform scale only (4DOF) s=scale, 2D translate, rotate, uniform scale only (4DOF) s=scale, =translate details…=translate details…

• Affine Affine HHAA: : • non-uniform scale (2DOF)non-uniform scale (2DOF)

• Projective Projective HHPP::• Projective coupling for xProjective coupling for x3 3 (2DOF)(2DOF)

The bits and pieces of The bits and pieces of HH

s s cos cos - -s sin s sin ttxx

s sin s sin s s cos cos t tyy

0 0 10 0 1

1 01 0 000 1 0 1 00vv11 v v22 vvSS

1 k21 k2 00k3 1k3 1 000 00 0 11

Page 27: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Compare HCompare HAA and H and HPP

(recall)(recall)H = H = HHSS H HA A HHP P ==

2D world space 2D world space

2D image 2D image space space

HHAALL MM

mm

2D image 2D image space space

HHPP

mmLL

LL (parallelogram)(parallelogram)

(quadrilateral)(quadrilateral)

(square)(square)(K matrix, 2DOF)(K matrix, 2DOF)

( v vector)( v vector)

K K 00

00T T 11

ssR R tt

00T T 11

I I 00 vvT T vv

Page 28: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

1-D Projective Geometry1-D Projective Geometry

(?Why? We’ll use it soon…)(?Why? We’ll use it soon…)

• A ‘side’ view of 2D projective geometryA ‘side’ view of 2D projective geometry

• Convert Convert RR11 scalar scalar bb to a 2-vector in to a 2-vector in PP11

• As with As with PP22, we can transform points: , we can transform points: – ((use various use various HH2x2 2x2 s to change cyan lines below)s to change cyan lines below)

b b 11

HH2a2a

HH2b2b

Page 29: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

1-D Projective Geometry1-D Projective Geometry

What is invariant here?What is invariant here?all the positions, lengths and ratios change with all the positions, lengths and ratios change with each transform…each transform…

Answer: Answer: ‘Cross Ratio’‘Cross Ratio’: cross(a,b,c,d): cross(a,b,c,d)• let a= , b= …let a= , b= …

cross = |across = |a--b||cb||c--d|d| |a |a--c||bc||b--d|d|

cross(a,cross(a,’’b,b,’’c,dc,d’’) = ) = cross(a’,b’,c’,d’)cross(a’,b’,c’,d’)

aa bb cc dd

aa11

aa22

bb11

bb22

a’a’

c’c’ d’d’b’b’

Page 30: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Image Rectifying: Image Rectifying: UndoUndo parts of H parts of H

x’ = H xx’ = H x where where H = HH = HS S HHA A HHPP

GOAL: GOAL: Put world plane x’ into view planePut world plane x’ into view plane– Affine Rect.; Affine Rect.; (find only (find only HHPP (2DOF)); (2DOF)); – Similarity Rect.;Similarity Rect.; (find only (find only HHA A HHP P (6DOF));(6DOF));– Full Rect.;Full Rect.; (find all of (find all of HH (8DOF)); (8DOF));

METHODS:METHODS: (mix & match?)(mix & match?)

1.1. Full: 4-point correspondence Full: 4-point correspondence 2.2. ‘‘Vanishing Point’, Infinity line methodsVanishing Point’, Infinity line methods3.3. Other feature points, conics, …Other feature points, conics, …

Page 31: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Image Rectifying: Image Rectifying: UndoUndo parts of H parts of H

x’ = H xx’ = H x where where H = HH = HS S HHA A HHPP

GOAL: GOAL: Put world plane x’ into view planePut world plane x’ into view plane– Affine Rect.; Affine Rect.; (find only (find only HHPP (2DOF)); (2DOF)); – Similarity Rect.;Similarity Rect.; (find only (find only HHA A HHP P (6DOF));(6DOF));– Full Rect.;Full Rect.; (find all of (find all of HH (8DOF)); (8DOF));

METHODS:METHODS: (mix & match?)(mix & match?)

1.1. Full: 4-point correspondence Full: 4-point correspondence 2.2. ‘‘Vanishing Point’, Infinity line methodsVanishing Point’, Infinity line methods3.3. Conics and circular pointsConics and circular points

Other DOF? make Other DOF? make assumptions, or ignoreassumptions, or ignore

Page 32: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Vanishing-Point Methods: 1Vanishing-Point Methods: 1

– In 2D image, find two pairs of lines In 2D image, find two pairs of lines that are parallel in ‘world’ space. that are parallel in ‘world’ space.

world space world space 2D image 2D image

HH

Page 33: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Vanishing-Point Methods: 1Vanishing-Point Methods: 1

– Find intersection (vanishing points) p1, p2Find intersection (vanishing points) p1, p2(compute line intersections with 3D cross-products (see last lecture)(compute line intersections with 3D cross-products (see last lecture)

– Horizon line Horizon line IIhh connects p1, p2. connects p1, p2.

world space world space 2D image 2D image

p1p1 p2p2

HH

IIhh

Page 34: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Vanishing-Point Methods: 1Vanishing-Point Methods: 1

– HH-T-T transforms world infinity line transforms world infinity line ll (0,0,1) (0,0,1)TT to to IIhh

– Answer Answer (see old book)(see old book) find, copy the find, copy the llhh coordinates! coordinates!

HHpp ==

world space world space 2D image 2D image

p1p1 p2p2

HH

IIhh

11 0 0 0 0

0 1 0 0 1 0 llh1h1 l lh2 h2 l lh3h3

Page 35: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Vanishing-Point Methods: 1Vanishing-Point Methods: 1

Limitations:Limitations:– Accurate point, line-finding can be trickyAccurate point, line-finding can be tricky– Can have high error sensitivity: ‘twitchy’Can have high error sensitivity: ‘twitchy’

– Only rectifies Only rectifies HHpp-- but what if -- but what if HHAA, H, HSS needed? needed?

world space world space 2D image 2D image

p1p1 p2p2

HH

IIhh

Page 36: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Vanishing-Point Methods: 2Vanishing-Point Methods: 2

No parallel lines? No parallel lines? – find 2D image line with a known distance ratiofind 2D image line with a known distance ratio– Use Cross-Ratio (in Use Cross-Ratio (in PP11 along that line) to along that line) to – Find vanishing point distance at point d’Find vanishing point distance at point d’

world space world space 2D image 2D image

p1p1 p2p2

HH

IIhh

aa bb cca’a’

b’b’

c’c’

d’d’

dd(at infinity)(at infinity)

Page 37: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Projective Transform: Projective Transform: Hx = x’Hx = x’

xx11

xx22

xx33

hh11 11 h h1212 h h1313

hh2121 h h2222 h h2121

hh3131 h h32 32 h h3333

= = x’x’11

x’x’22

x’x’33

Finding H from point pairs Finding H from point pairs (correspondences)(correspondences)

x’ = =x’ = =

y’ = =y’ = =

= = xx

yy

1 1

Input (or output) Input (or output) image is on image is on central planecentral plane

xx11

xx22

xx33

hh21 21 x + hx + h22 22 y + hy + h2121

hh31 31 x + hx + h32 32 y + hy + h3333

x’x’11

x’x’33

x’x’22

x’x’33

Write RWrite R22 expressions; expressions;(for each x,x’ pair)(for each x,x’ pair)

hh11 11 x + hx + h12 12 y + hy + h1313

hh31 31 x + hx + h32 32 y + hy + h3333

x’ (hx’ (h31 31 x + hx + h32 32 y + hy + h3333) = (h) = (h11 11 x + hx + h12 12 y + hy + h1313))

y’ (hy’ (h31 31 x + hx + h32 32 y + hy + h3333) = (h) = (h11 11 x + hx + h12 12 y + hy + h1313))Rearrange, solve as Rearrange, solve as a matrix problem…a matrix problem…

Page 38: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Projective Transform: Projective Transform: Hx = x’Hx = x’

xx11

xx22

xx33

hh11 11 h h1212 h h1313

hh2121 h h2222 h h2121

hh3131 h h32 32 h h3333

= = x’x’11

x’x’22

x’x’33

Finding H from point pairs Finding H from point pairs (correspondences)(correspondences)

x’ = =x’ = =

y’ = =y’ = =

= = xx

yy

1 1

Input (or output) Input (or output) image is on image is on central planecentral plane

xx11

xx22

xx33

hh21 21 x + hx + h22 22 y + hy + h2121

hh31 31 x + hx + h32 32 y + hy + h3333

x’x’11

x’x’33

x’x’22

x’x’33

Write RWrite R22 expressions; expressions;(for each x,x’ pair)(for each x,x’ pair)

hh11 11 x + hx + h12 12 y + hy + h1313

hh31 31 x + hx + h32 32 y + hy + h3333

x’ (hx’ (h31 31 x + hx + h32 32 y + hy + h3333) = (h) = (h11 11 x + hx + h12 12 y + hy + h1313))

y’ (hy’ (h31 31 x + hx + h32 32 y + hy + h3333) = (h) = (h11 11 x + hx + h12 12 y + hy + h1313))Rearrange, solve as Rearrange, solve as a matrix problem…a matrix problem…

——!STOP! — !STOP! —

Trucco Book Does This…Trucco Book Does This…

Zisserman Book calls it “naïve”, Zisserman Book calls it “naïve”, gives better method:gives better method:

‘‘DLT’: direct linear xfm.) DLT’: direct linear xfm.)

Page 39: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

Projective Transform Projective Transform HH

xx11

xx22

xx33

hh11 11 h h1212 h h1313

hh2121 h h2222 h h2121

hh3131 h h32 32 h h3333 = =

x’x’11

x’x’22

x’x’33

H x’ = xH x’ = x

Finding H from point pairs Finding H from point pairs (correspondences)(correspondences)

• We know that We know that Hx’ = xHx’ = x, and , and

• we know at least 4 point pairs we know at least 4 point pairs x’ x’ and and xx that satisfy it: that satisfy it:

• ATTEMPT 1:ATTEMPT 1:‘plug & chug’: make a matrix ‘plug & chug’: make a matrix of of xx and and x’x’ values… values…

HH = = x’x’11 x’x’22 x’x’33 x’x’44 xx11 xx22 xx33 xx44

Page 40: CS 395/495-26: Spring 2004 IBMR: 2-D Projective Geometry --Introduction-- Jack Tumblin jet@cs.northwestern.edu

ENDEND--Please download the starter code, compile and run.--Please download the starter code, compile and run.--Then you can get started on Project 1 right away.--Then you can get started on Project 1 right away.