Computer Vision Colorado School of Mines Professor William Hoff

advertisement
Colorado School of Mines
Computer Vision
Professor William Hoff
Dept of Electrical Engineering &Computer Science
Colorado School of Mines
Computer Vision
http://inside.mines.edu/~whoff/
1
2D-2D Coordinate Transforms
Colorado School of Mines
Computer Vision
2D Rigid Frame Transformations
• The pose of one 2D frame
with respect to another is
described by
– Translation vector t=(Dx,Dy)T
– Rotation angle q
• Rotation can also be
represented as a 2x2 matrix R
• Object shape and size is
preserved
y’
y
q
t
x’
x
• Number of degrees of
freedom for a 2D rigid
transformation?
Colorado School of Mines
Computer Vision
3
Rotations in 2D
• Let’s derive the formula for a 2D rotation
y’
y
x’
q
x
Colorado School of Mines
Computer Vision
4
Rotations in 2D
x  OA  OP cos(q  f )
y
y’
y  AP  OP sin(q  f )
cos(q  f )  cos q cos f  sin q sin f
P
sin(q  f )  cos q sin f  sin q cos f
x  OP cos f cos q  OP sin f sin q
f
 x' cos q  y ' sin q
B
q
A
O
 x   cos q
So    
 y   sin q
x
 sin q  x' 
 
cos q  y ' 
R
Colorado School of Mines
y’
x’
Computer Vision
Similarly, y  x' sin q  y ' cos q
 cos q
R  
 sin q
 sin q 

cos q 
5
Rotations in 2D
y’
𝑥
𝑥′
=
𝐑
𝑦
𝑦′
y
𝐑=
cos 𝜃
sin 𝜃
− sin 𝜃
cos 𝜃
R describes the orientation of the “primed” frame (x’,y’)
with respect to the “unprimed” frame (x,y)
•
x’
q
x
Colorado School of Mines
Computer Vision
R is orthonormal
– Rows, columns are
orthogonal (r1∙r2 = 0,
c1∙c2 = 0)
– Transpose is the inverse;
RRT = I
– Determinant is |R| = 1
𝑥
𝑥′
T
=𝐑 𝑦
𝑦′
6
Homogeneous Coordinates
• Points can be represented using homogeneous coordinates
– This simply means to append a 1 as an extra element
– If the 3rd element becomes ≠ 1, we divide through by it
 x   sx 
   
~
x   y    sy 
1  s 
   
• Effectively, vectors that differ only by scale are considered to be
equivalent
• This simplifies transform equations; instead of
 x' 
 x   tx 
   R    
 y' 
 y  ty 
• we have
Colorado School of Mines
 x' 
 x
   R t  
 y 
 y '   
0
0
1
 1 
1 
 
 
𝐱′ = 𝐑𝐱 + t
𝐱′ = 𝐇𝐱
𝐱 ∈ 𝑃2, where 𝑃2 = 𝑅3 – (0,0,0) is
called a 2D projective space
Computer Vision
7
Example
• Transform the 2D point x = (10, 20)T using a rotation
of 45 degrees and translation of (+40, -30).
Colorado School of Mines
Computer Vision
8
Example
• Transform the 2D point x = (10, 20)T using a rotation of 45
degrees and translation of (+40, -30).
• Solution:
– The point in homogeneous coords is
– The transformation matrix is
T
~
x  10,20,1
{A}
 cos 45  sin 45 40   .707  .707 40 
 

 R t 
   sin 45 cos 45  30    .707 .707  30 
H  
 0 0 1  0
0
1   0
0
1 

B
A
– Transforming the point:
 .707  .707 40  10   32.9 

  

H~
x   .707 .707  30  20     8.8 
 0
0
1  1   1 

Computer Vision
R
describes the
orientation of A
with respect to B
{B}
{A}
Colorado School of Mines
{B}
Other 2D-2D Transforms
• Scaled (similarity) transform
– preserves angles but not distances
 xB   s 0 0  cos q
  

y

0
s
0
B
  
 sin q
 1   0 0 1  0
  

 sin q
cos q
0
t x  x A 
 
t y  y A 

1 
 1 
• Affine transform
– Models rotation, translation, scaling, shearing, and reflection
 xB   a11 a12
  
 yB    a21 a22
1  0
0
  
t x  x A 
 
t y  y A 

1 
 1 
# pairs of corresponding points needed?
Colorado School of Mines
Computer Vision
10
Example
• Image “A” is modified by the affine transform below. Sketch image “B”
0 0  xA 
 xB   1
  
 
y

0.25
1.5
0
B
  
 y A 
1  0

0 1 
  
 1 
0,0
50,0
0,50
50,50
A
Colorado School of Mines
Computer Vision
11
Example
• Image “A” is modified by the affine transform below. Sketch image “B”
0 0  xA 
 xB   1
  
 
y

0.25
1.5
0
B
  
 y A 
1  0

0 1 
  
 1 
0,0
50,0
0,50
50,50
A
Colorado School of Mines
Computer Vision
Example Affine Warp
from http://www.cse.msu.edu/~stockman/CV
Colorado School of Mines
Computer Vision
13
Projective Transform (Homography)
• Most general type of linear 2D-2D transform
• H is an arbitrary 3x3 matrix
~
x  H ~
x
 x1   h11
  
 x2    h21
 x  h
 3   31
h12
h22
h32
h13  x 
 
h23  y 
h33  1 
• We still need to divide by the 3rd element
 x   x1 / x3 
  


y

x
/
x
   2 3
1  1 
  

Colorado School of Mines
As we will see later, a
homography maps
points from the
projection of one plane
to the projection of
another plane
Computer Vision
14
From Szeliski, Computer Vision: Algorithms and Applications
Colorado School of Mines
Computer Vision
15
Download