Professional Documents
Culture Documents
MATRICES ADDITION
Given two matrices A and B if we want to add B to
A (that is form A+B) then if A is (nm), B must be
(nm), Otherwise, A+B is not defined.
2D TRANSFORMATIONS
Ci, j = Ai , j + Bi , j
1 2 5 6 1 + 5 2 + 6 6 8
3 4 + 7 8 = 3 + 7 4 + 8 = 10 12
MATRICES MULTIPLICATION
Given two matrices A and B if we want to multiply
B by A (that is form AB) then if A is (nm), B must
be (mp), i.e., the number of columns in A must be
equal to the number of rows in B. Otherwise, AB is
not defined.
9 2 3 2 6 66 96
6 8
2 6
4 5 3 3
2 6
ik kj
k =1
Undefined!
2x2 x 3x2 2!=3
8/27/2009
MATRICES -- BASICS
TRANSFORMATION
a1, 2
a2, 2
a1,1
a1,3
A
'
=
a1, 2
a2,3
a1,3
a2 ,1
a2, 2
a2, 3
2D GEOMETRICAL TRANSFORMATIONS
Translate
TYPES OF TRANSFORMATIONS
Geometric transformation when the object is moved
relative to a stationary coordinate system or
background it is called geometric transformation.
Shear
Rotate Scale
8/27/2009
TRANSLATION
SCALING
We can specify how much bigger or smaller by means of a
scale factor
x' = x + t x
y' = y + t y
x' = s x x
In matrix format:
y' = s y y
x' x t x
y ' = y + t
y
x' s x
y ' = 0
t x
T =
t y
, then we have
If we define
ROTATION
sx 0
S sx , sy =
, then we have P =SP
0 sy
Nihar Ranjan Roy
10
MIRROR REFLECTION
Mirror reflection about x axis
| OP ' |=| OP |= l
p`= M x ( p)
x ' 1 0 x
y ' = 0 1 X y
P(x,y)
0 x
s y y
P(x,y)
x ' cos
y ' = sin
sin x
cos y
p`= M y ( p )
x ' 1 0 x
y ' = 0 1 X y
= x sin + y cos
P =RP
Nihar Ranjan Roy
11
12
8/27/2009
SUMMERY
SHEARING TRANSFORMATION
The shear transformation cause the image to slant. X shear
maintains the y-coordinate but changes the x values which cause
the vertical lines tilt left to right
SH
1
= 0
Simultaneous shearing
SH
a
1
0
xy
0
0
1
= b
SH
a
1
0
1
= b
0
1
0
0
0
0
0
Translate:
Scale:
Rotate:
Mirror
Shear
P = P+T
P = Ssx,sy(P)
P = R(P)
P = Mx(P) or P = My(P)
p=SHx(P) or p=SHx(P) or p=SHxy(P)
13
14
TRANSLATION AS HOMOGENEOUS
TRANSFORMATIONS
HOMOGENEOUS COORDINATES
For a given 2D coordinates (x, y), we introduce a third
dimension:
[x, y, 1]
In general, a homogeneous coordinates for a 2D point has
the form:
[wx, wy, w]
Advantages
Similarly, we have:
tx x
ty y
1 1
0
1
0
P ' = Tv P
Scaling
x ' s x
y ' = 0
1 0
[1/2
1/3] in homogenous it can be represented as
[3 2 6]
P
Nihar Ranjan Roy
x ' 1
y ' = 0
1 0
x ' x t x
y ' = y + t
y
15
0
sy
0
Ssx,sy
Rotation
0 x
0 y
1 1
x ' cos
y ' = sin
1 0
sin
cos
0
0 x
0 y
1 1
16
8/27/2009
p`= M x ( p)
p`= M y ( p )
x' 1 0 0 x
y ' = 0 1 0 X y
z ' 0 0 1 z
x ' 1 0 0 x
y ' = 0 1 0 X y
z ' 0 0 1 z
R,p=Tv.R T-v
Simultaneous shearing
SH xy
1
= b
0
a
1
0
where
0
0
1
1 0 h
Tv = 0 1 k
0 0 1
17
1 0 h
Tv = 0 1 k
0 0 1
Ssx, sy
0
sy
0
0
0
1
1 0 h
Tv = 0 1 k
0 0 1
18
S(sx,sy),p=TV.Ssxsy .T-V
s x
= 0
0
cos sin 0
R = sin cos 0
0
0
1
1 0 h
Tv = 0 1 k
0 0 1
19
20
8/27/2009
TRANSFORMATION ROUTINES
1 0
Tv = 0 1
0 0
1
Tv = 0
0
0
c
1
0 h
1 k
0 1
cos sin 0
cos sin 0
R = sin cos 0 R = sin cos 0
0
0
1
0
0
1
1 0 0
M x = 0 1 0
m
1
sin =
& cos =
0 0 1
m2 + 1
m2 + 1
finally
1 m 2
2
m +1
2m
ML = 2
m +1
0
2m
m2 + 1
m2 1
m2 + 1
0
2cm
m 2 + 1
2c
m 2 + 1
1
21
IDENTITY-MATRIX(H)
FOR J=0 TO 3 DO
IF (I=J) THEN H[I,J]1
ELSE
H[I,J]0;
RETURN;
END
22
TRANSFORMATION ROUTINES:-SCALE
MULTIPLY-IN-SCALE(SX,SY,H)
ARGUMENTS sx and sy scaling factor
H an identity matrix
LOCAL
I,J to iterate through matrix
BEGIN
FOR I=1 TO 3 DO
BEGIN
H[I,1]H[I,1]*SX
S sx , sy
H[I,2]H[I,2]*SY
END
RETURN
END
sx 0 0
= 0 sy 0
0 0 1
23
24
8/27/2009
DISPLAY PROCEDURE
PROBLEM
25
26
ML=TV MX T-V
B(0,6) C(1,4) D(0,2)
1 m 2
2
m +1
2m
ML = 2
m +1
0
A(-2,1) B(-4,2)
2m
m2 +1
m2 1
m2 +1
0
C(-2,3)
2cm
m 2 + 1 0 1 2
2c
= 1 0 2
m 2 + 1
1 0 0 1
D(0,2)
Nihar Ranjan Roy
27