rotations in the plane we have p = x px + ypy = û pu + vpv. âdottingâ with x yields. ãx,xã px + ãx,yã py = ãx, ûã pu + ãx,vã pv since x ⥠y and x = 1, this simplifies to.
Image Processing Prof. Christian Bauckhage
outline lecture 05 recap
linear (in)dependence and bases
coordinate systems and coordinate transformations affine transformations affine transformations and matrices
summary
recap our long term goal is to understand image transformations
recap
vector space, inner product space, and normed space over a field K V, +, · V, +, ·, h i V, +, ·, k k where +:V ×V →V · :K×V →V hi:V ×V →K kk:V→R
recap
distance of x, y ∈ V ⇔ a function d(x, y) ∈ R, such that d(x, y) > 0 d(x, y) = 0 if and only if x = y d(x, y) = d(y, x) d(x, z) 6 d(x, y) + d(y, z)
recap
linear coordinate system ⇔ origin, axes, and unit Cartesian coordinate system ⇔ axes are pairwise perpendicular and positively oriented and the unit length is 1
qˆ
yˆ
u ˆ
p
rˆ
sˆ
v ˆ tˆ
x ˆ
recap if B = b1 , b2 , . . . , bm is a set of linearly independent vectors in an m-dim vector space V over K, then the linear combinations v = v1 b1 + v2 b2 + . . . + vm bm span the space V and the set B forms a basis of V the vi ∈ K are the coordinates of vector v and we write v1 v2 v= . .. vm
linear (in)dependence and bases
example: vectors in R2
since b2 = α b1 the problem b1
0 = v1 b1 + v2 b2 = v1 b1 + v2 α b1 = v1 + v2 α b1 can be solved for v1 , v2 6= 0
b2
example: vectors in R2
since b2 = α b1 the problem b1
0 = v1 b1 + v2 b2 = v1 b1 + v2 α b1 = v1 + v2 α b1
b2
can be solved for v1 , v2 6= 0
⇒ b1 and b2 are not linearly independent and do not form a basis
example: vectors in R2
in both cases, b1 and b2 are linearly independent
b2
they are oblique and not of the same length but still form valid bases for R2
b1
b2
b1
example: vectors in R2
here, b1 and b2 are linearly independent moreover kb1 k = 1
b2
kb2 k = 1 and hb1 , b2 i = 0
⇒ b1 and b2 form an orthonormal basis of R2
b1
note if B = b1 , b2 , . . . , bm is a basis of an m-dim space V such that kbi k = 1 for all i, the co-variant coordinates of v ∈ V with respect to B are given by vi = hv, bi i
v
v v2
v
v2
v2 b2
b2 v1 b1
b2 b1 v1
b1
v1
note
in this case, we have
v=
m X i=1
m m X m X X vi bi = hv, bi i bi = vj bji bi i=1
i=1 j=1
coordinate systems and coordinate transformations
affine transformations
an affine transformation translates a coordinate system O, ˆx, ˆy into another one O 0 , ˆ x 0 , ˆy 0
affine transformations
an affine transformation translates a coordinate system O, ˆx, ˆy into another one O 0 , ˆ x 0 , ˆy 0 the axes of O 0 , xˆ 0 , ˆy 0 may have different unit lengths and may include different angles
types of affine transformations
affine transformations include identity mappings rotations scalings shears reflections translations
compositions of affine transformations are affine, too
2D examples
original
identity
rotation
scaling x
scaling y
scaling xy
2D examples (continued)
shearing x
shearing y
shearing xy
reflection x
reflection y
reflection xy
2D examples (continued)
translation
general affine transformation
affine transformations of a digital image
original
first scaled . . .
affine transformations of a digital image
then sheared . . .
then translated . . .
affine transformations of a digital image
then rotated . . .
and finally mirrored
rotations in the plane
consider a point p in a Cartesian system ˆ, ˆv Suv = O, u p v ˆ
O
u ˆ
rotations in the plane
consider a point p in a Cartesian system ˆ, ˆv Suv = O, u p
consider a rotated Cartesian system Sxv = O, ˆ x, ˆy
yˆ
v ˆ
x ˆ O
u ˆ
rotations in the plane
consider a point p in a Cartesian system ˆ, ˆv Suv = O, u consider a rotated Cartesian system Sxv = O, ˆ x, ˆy consider the coordinates of p in either system
pv yˆ
p
v ˆ
py px x ˆ O
u ˆ pu
rotations in the plane
consider a point p in a Cartesian system ˆ, ˆv Suv = O, u consider a rotated Cartesian system Sxv = O, ˆ x, ˆy consider the coordinates of p in either system consider the rotation angle ϕ
pv yˆ
p
v ˆ
py px x ˆ O
u ˆ pu
ϕ
question | | if we knew pu , pv and ϕ, could we compute px , py ?
question | | if we knew pu , pv and ϕ, could we compute px , py ?
answer let’s see . . .
rotations in the plane
we have ˆ pu + ˆv pv p=ˆ x px + ˆy py = u
pv yˆ
p
v ˆ
py px x ˆ O
u ˆ pu
ϕ
rotations in the plane
we have ˆ pu + ˆv pv p=ˆ x px + ˆy py = u
pv yˆ
“dotting” with ˆ x yields
p
v ˆ
py px
ˆi pu + hˆ hˆ x, ˆ xi px + hˆ x, ˆyi py = hˆ x, u x, ˆvi pv
x ˆ O
u ˆ pu
ϕ
rotations in the plane
we have ˆ pu + ˆv pv p=ˆ x px + ˆy py = u
pv yˆ
“dotting” with ˆ x yields
p
v ˆ
py px
ˆi pu + hˆ hˆ x, ˆ xi px + hˆ x, ˆyi py = hˆ x, u x, ˆvi pv since ˆ x ⊥ ˆy and kˆ xk = 1, this simplifies to ˆi pu + hˆ px = hˆ x, u x, ˆvi pv
x ˆ O
u ˆ pu
ϕ
rotations in the plane
we have ˆ pu + ˆv pv p=ˆ x px + ˆy py = u
pv yˆ
“dotting” with ˆ x yields
p
v ˆ
py px
ˆi pu + hˆ hˆ x, ˆ xi px + hˆ x, ˆyi py = hˆ x, u x, ˆvi pv since ˆ x ⊥ ˆy and kˆ xk = 1, this simplifies to ˆi pu + hˆ px = hˆ x, u x, ˆvi pv and similarly ˆi pu + h ˆy, ˆvi pv py = h ˆy, u
x ˆ O
u ˆ pu
ϕ
note
the resulting system of linear equations ˆi pu + h ˆ px = h ˆx, u x, ˆvi pv ˆi pu + h ˆy, ˆvi pv py = h ˆy, u can be written in matrix-vector notation ˆi h ˆ px h ˆx, u x, ˆvi pu = ˆi h ˆy, ˆvi pv py h ˆy, u
note
we can write this even more compact, namely ˆi hˆ px hˆx, u x, ˆvi pu = ˆi hˆy, ˆvi pv py hˆy, u cos ϕ sin ϕ pu = − sin ϕ cos ϕ pv ˆi = kˆ ˆ, and ˆv are unit vectors, we have recall that hˆ x, u xk kˆ uk cos ϕ and since ˆ x, ˆy, u ˆi = kˆ hˆ x, u xk kˆ uk cos ϕ = cos ϕ π π hˆ x, ˆvi = kˆ xk kˆvk cos − ϕ = cos −ϕ 2 2 π π ˆi = kˆyk kˆ hˆy, u uk cos + ϕ = cos +ϕ 2 2 hˆy, ˆvi = kˆyk kˆvk cos ϕ = cos ϕ which together with cos(α ± β) = cos α cos β ∓ sin α sin β yields the above result
note
to reduce clutter, we substitute x = pxy u = puv so as to obtain x = Ru
note
to reduce clutter, we substitute x = pxy u = puv so as to obtain x = Ru
for which we note that matrix R ∈ R2×2 is rather special
group G,
∀ a, b ∈ G : a b ∈ G ∀ a, b, c ∈ G : (a b) c = a (b c)
closure associativity
∃I ∈G:∀a∈G:I a=a I =a
identity element
∀ a ∈ G : ∃ a−1 ∈ G : a a−1 = a−1 a = I
inverse element
Abelian group G,
a group where is commutative, that is where ∀ a, b ∈ G : a b = b a is called an Abelian group
note
groups are a dime a dozen, too e.g. R \ {0}, ·, I = 1 ,
Q \ {0}, ·, I = 1 ,
Z, +, I = 0 , . . .
many groups, however, are not commutative certain kinds of (square!) matrices form groups
examples
the general linear group, the orthogonal group, and the special orthogonal group of m × m matrices over R
GL(m) = M ∈ R
m×m
det M 6= 0
O(m) = M ∈ Rm×m det M 6= 0 ∧ M| M = MM| = I
SO(m) = M ∈ Rm×m det M = 1 ∧ M| M = MM| = I
note
R ∈ SO(2) it is square its columns are pairwise orthonormal its rows are pairwise orthonormal its transpose equals its inverse R| = R−1 ⇔ R| R = RR| = I its determinant is det R = cos2 ϕ + sin2 ϕ = 1
note
R ∈ SO(2) is a 2 × 2 rotation matrix it is square its columns are pairwise orthonormal its rows are pairwise orthonormal its transpose equals its inverse R| = R−1 ⇔ R| R = RR| = I its determinant is det R = cos2 ϕ + sin2 ϕ = 1
note
rotations R ∈ SO(m) are unitary operators ⇔ they preserve inner products and norms
note
rotations R ∈ SO(m) are unitary operators ⇔ they preserve inner products and norms for example, let q, p ∈ Rm and r = R q, s = R p, then
|
r, s = r| s = R q R p = q| R| R p = q| p = q, p
note
rotations R ∈ SO(m) are unitary operators ⇔ they preserve inner products and norms for example, let q, p ∈ Rm and r = R q, s = R p, then
|
r, s = r| s = R q R p = q| R| R p = q| p = q, p
and
2
r = r| r = R q | R q = q| R| R q = q| q = q 2
convention
if a transformation matrix T is applied to (the points in) the domain of a function g(u) to produce a function ˜g(x), we write ˜g x = ˜g Tu = g u
convention
if a transformation matrix T is applied to (the points in) the domain of a function g(u) to produce a function ˜g(x), we write ˜g x = ˜g Tu = g u
y
v
u
g u
x
˜ g x =˜ g Tu
scaling, shear, reflection (a.k.a. flipping)
other (planar) affine transformations, too, can be realized by means of (2 × 2) matrices
scaling, shear, reflection (a.k.a. flipping)
other (planar) affine transformations, too, can be realized by means of (2 × 2) matrices scaling in x−, y− and x, y−direction a 0 1 0 a 0 , , 0 1 0 b 0 b
scaling, shear, reflection (a.k.a. flipping)
other (planar) affine transformations, too, can be realized by means of (2 × 2) matrices scaling in x−, y− and x, y−direction a 0 1 0 a 0 , , 0 1 0 b 0 b shearing in y−, x− and x, y−direction 1 c 1 0 1 c , , 0 1 d 1 d 1
scaling, shear, reflection (a.k.a. flipping)
other (planar) affine transformations, too, can be realized by means of (2 × 2) matrices scaling in x−, y− and x, y−direction a 0 1 0 a 0 , , 0 1 0 b 0 b shearing in y−, x− and x, y−direction 1 c 1 0 1 c , , 0 1 d 1 d 1 reflecting about the x- and y-axis and about the origin −1 0 1 0 −1 0 , , 0 1 0 −1 0 −1
composing affine transformations
we may compose several affine transformation by applying them in succession
composing affine transformations
we may compose several affine transformation by applying them in succession the corresponding result can be accomplished in a single step, if the corresponding matrices are combined into a single operation to this end, we simply multiply them together
note: matrices do not generally commute
original g(u)
rotation ˜ g(Ru)
shearing ˜ g(Su)
˜ g(SRu)
˜ g(RSu)
linear transformations
affine transformations that can be realized through matrix multiplications are linear transformations
linear transformations
affine transformations that can be realized through matrix multiplications are linear transformations a mapping T is a linear mapping, if, for any two vectors u and v and a scalar a, it is characterized by T u+v =T u +T v T a u) = a T u
translations are not linear
a translation can not be realized by means of matrix multiplication for instance, in 2D, we have px p a = u + py pv b
general affine transformations
in 2D, a general affine transformation is therefore given by px a b pu e = + py c d pv f
or equivalently x = Mu + t
general affine transformations
in 2D, a general affine transformation is therefore given by px a b pu e = + py c d pv f
or equivalently x = Mu + t
⇔ general affine transformations consist of a linear map and a translation
note
to see that affine transformations are not necessarily linear, let T u) = Mu + t be an affine transformation
note
to see that affine transformations are not necessarily linear, let T u) = Mu + t be an affine transformation, then T u+v =M u+v +t = Mu + Mv + t 6= Mu + t + Mv + t = T u + T v
note
every linear transformation is affine not every affine transformation is linear
summary
we now know about
affine transformations types of affine transformations, especially rotations the relationship between linear and affine transformations
exercises
recall that a mapping T is linear, if T u+v =T u +T v T au = aT u in the lecture, we applied property (1) to show that an affine transformation T u = Mu + t is not linear if t 6= 0 now, use property (2) to show this can you think of a way of turning affine transformations like the one in (3) into linear transformations?
(1) (2)
(3)