Professional Documents
Culture Documents
Professor Fei-Fei Li
Stanford Vision Lab
Another, very in-depth linear algebra review from CS229 is available here:
http://cs229.stanford.edu/section/cs229-linalg.pdf
And a video discussion of linear algebra from EE263 is here (lectures 3 and 4):
http://see.stanford.edu/see/lecturelist.aspx?coll=17005383-19c6-49ed-9497-2ba8bfcfe5f6
=
• MATLAB represents an image as a matrix of
pixel brightnesses
• Note that matrix coordinates are NOT
Cartesian coordinates. The upper left corner is
[y,x] = (1,1)
=
Fei-Fei Li Linear Algebra Review 9 6/11/20
Basic Matrix Operations
• We will discuss:
– Addition
– Scaling
– Dot product
– Multiplication
– Transpose
– Inverse / pseudoinverse
– Determinant / trace
• Scaling
• A useful identity:
• Diagonal matrix
– Square matrix with numbers along
diagonal, 0’s elsewhere
– A diagonal ∙ [another matrix] scales
the rows of that matrix
• Skew-symmetric matrix
P’ P ( x, y ) ( x, y,1)
t
ty P t (t x , t y ) (t x , t y ,1) t
y P
x tx x t x 1 0 t x x
P' y t y 0 1 t y y
1 0 0 1 1
I t
P TP
0 1
Fei-Fei Li Linear Algebra Review 35 6/11/20
Scaling
P’
P
y
P ( x, y ) ( x, y,1)
P ' ( s x x, s y y ) ( s x x, s y y,1)
x sx x
sx x sx 0 0 x
S' 0
P' s y y 0 sy 0 y P SP
0 1
1 0 0 1 1
S
Fei-Fei Li Linear Algebra Review 37 6/11/20
Scaling & Translating
P’’
P
P’=S∙P
P’’=T∙P’
P’’=T ∙ P’=T ∙(S ∙ P)= T ∙ S ∙P = A ∙ P
Fei-Fei Li Linear Algebra Review 38 6/11/20
Scaling & Translating
1 0 t x s x 0 0 x
P ' ' T S P 0 1 t y 0 s y 0 y
0 0 1 0 0 1 1
sx 0 t x x sx x t x x x
S t
0 s y t y y s y y t y y y
0 1
0 0 1 1 1 1 1
A
Fei-Fei Li Linear Algebra Review 39 6/11/20
Translating & Scaling
!= Scaling & Translating
1 0 t x s x 0 0 x s x 0 t x x s x x t x
P ' ' ' T S P 0 1 t y 0 sy 0 y 0 sy t y y s y y t y
0 0 1 0 0 1 1 0 0 1 1 1
s x 0 0 1 0 t x x
P ' ' ' S T P 0 s y 0 0 1 t y y
0 0 1 0 0 1 1
s x 0 s x t x x s x x s x t x
0 sy s y t y y s y y s y t y
0 0 1 1 1
Fei-Fei Li Linear Algebra Review 40 6/11/20
Rotation
P’
R RT RT R I
det( R ) 1
R RT RT R I
det( R ) 1
Fei-Fei Li Linear Algebra Review 44 6/11/20
Rotation+ Scaling +Translation
P’= (T R S) P
1 0 t x cos θ sin θ 0 s x 0 0 x
P ' T R S P 0 1 t y sin θ cos θ 0 0 sy 0 y
0 0 1 0 0 1 0 0 1 1
cos θ sin θ t x s x 0 0 x
sin θ cos θ t y 0 sy 0 y
This is the form of the
0 0 1 0 0 1 1 general-purpose
transformation matrix
x x
R t S 0 R S t
y y
0 1 0 1 0 1
1 1
• E.g.
>> x = A\B
x =
1.0000
-0.5000
• Matrix rank
UΣVT = A
• Where U and V are rotation matrices, and Σ is
a scaling matrix. For example:
• Beyond 2D:
– In general, if A is m x n, then U will be m x m, Σ will
be m x n, and VT will be n x n.
– (Note the dimensions work out to produce m x n
after multiplication)
+
=
• Each product of (column i of U)∙(value i from Σ)∙(row i of
VT) produces a component of the final A.
We can look at Σ to
see that the first while the second
column has a large column has a much
effect smaller effect in this
example