You are on page 1of 20

CpE 584

Digital Image Processing

Geometric Operations
Part II

CpE 584 Al-Omari


Dot product

The dot product between u and v is defined


as:
uv = u[ j ]v[ j ]
j

= u v cos( (u ,v ))

CpE 584 Al-Omari


Dot product

Geometrically, the dot product is the product


of the lengths of the vectors and the amount
that the two directions align.
If one of the vectors is a unit vector, the dot
product is the projection of the other vector
onto it.

CpE 584 Al-Omari


Dot product in matrix form

Sometimes we need to calculate more than


one dot product:
a1 = u1 v
a2 = u2 v
M
an = un v
CpE 584 Al-Omari
Dot product in matrix form

In compact notation: put u1, u2, . . . , un as


the rows of a matrix:

u1 [1] u1 [2] L u1 [m] v[1]


a1 u1 u [1] u [2] L u [m] v[2]
2
=
2 2
a u v = 2 2

M M M M M
M M
a u un [1] un [2] L un [m] v[m]
n n

CpE 584 Al-Omari


Translation

Translation is just shifting left-right and/or up-


down:

x = x + x0
'

y = y + y0
'

CpE 584 Al-Omari


Scaling

Scaling is just stretching horizontally and/or


vertically:

x = Sx x
'

y = Sy y
'

CpE 584 Al-Omari


Rotation

For rotation, each component of the result is


a combination of both x and y:

x = cos( ) x sin ( ) y
'

y = sin ( ) x + cos( ) y
'

CpE 584 Al-Omari


Affine transformation

One simple class of transformations is the


affine transformations:

x = ax + by + c
'

y = d x + ey + f
'

CpE 584 Al-Omari


Affine transformation

Affine transformations are simply linear


combinations of x, y, and 1.
Translation, rotation, and scaling are all
affine transformations.

CpE 584 Al-Omari


Matrix form of affine transformation

a b c x
d e
f y

0 0 1 1

CpE 584 Al-Omari


Matrix form of translation

1 0 x0 x x + x0
0 1
y0 y = y + y0

0 0 1 1 1

CpE 584 Al-Omari


Matrix form of scaling

S x 0 0 x S x x
0 Sy
0 y = S y y

0 0 1 1 1

CpE 584 Al-Omari


Matrix form of rotation

cos( ) sin ( ) 0 x cos( ) x sin ( )


sin ( ) cos( ) 0 y = sin ( ) x + cos( )

0 0 1 1 1

CpE 584 Al-Omari


Multiple transformation

Example: rotation around the point (x0, y0):

1 0 x0 cos( ) sin ( ) 0 1 0 x0 x
0 1
y0 sin ( ) cos( ) 0 0 1 y0 y

0 0 1 0 0 1 0 0 1 1

CpE 584 Al-Omari


Matrix composition

Transformation of v by A and then by B:

(B( Av )) = (B A)v
Can composite multiple transformations into
a single matrix.

CpE 584 Al-Omari


More on affine transformation

Translation, rotation, and scale are rigid body


transformations.
General affine transformations also include
non-rigid transformations, e.g.,
Shearing
Skew

CpE 584 Al-Omari


Inverting matrix transformations

If
v' = M v
then
1 '
v=M v
So, to invert the transformation, invert the
matrix.

CpE 584 Al-Omari


Warp meshes

For more elaborate or free-form warps, we


can create a mesh of warped points.
Input mesh points transform to corresponding
output mesh points.
Interpolate between the mesh points to get the
transformation.

CpE 584 Al-Omari


Morphing

Instead of a warping mesh, use arbitrary


correspondence points: tip of a nose to the
tip of another nose, eyes to eyes, etc.
Interpolate between the correspondence
points to determine where the other points
move to.
Apply standard warping (forward or
backward).

CpE 584 Al-Omari

You might also like