Title: COMM2J Vision
1Topic 17 Geometrical transforms
The geometrical transforms are an essential
pre-requisite for understanding the calibration
and use of digital cameras. Image interpolation,
warping and morphing allow us to reconstruct 3-D
objects.
- Sub topics
- A simple 2-D data structure
- Translation,Scaling and rotation in 2-D
- A useful 3-D data structure
- Extension of transforms to 3-D
- Perspective projection.
- Image interpolation
- Warping and morphing
COMM2J Vision Intelligent Robots 2003
2Topic 17 A simple 2-D data structure
A 2-D drawing consists of nodes and lines which
connect the nodes.
COMM2J Vision Intelligent Robots 2003
A geometrical transformation has to be carried
out only on the nodes, the connections remain
unaffected.
3Topic 17 Translation
COMM2J Vision Intelligent Robots 2003
4Topic 17 Scaling
COMM2J Vision Intelligent Robots 2003
5Topic 17 Rotation
COMM2J Vision Intelligent Robots 2003
6Topic 17 Summary of rotation
COMM2J Vision Intelligent Robots 2003
7Topic 17 The transforms in matrix form
COMM2J Vision Intelligent Robots 2003
8Topic 17 Homogeneous co-ordinates
COMM2J Vision Intelligent Robots 2003
9Topic 17 Concatenation of transformations
COMM2J Vision Intelligent Robots 2003
10Topic 17 Inverse transforms
Take translation as an example
x T-1.T.x
COMM2J Vision Intelligent Robots 2003
11Topic 17 Scaling and rotation inverses
COMM2J Vision Intelligent Robots 2003
Remember cos(-?) cos(?) and sin(-?)
-sin(?)
12Topic 17 Rotation about a local origin
COMM2J Vision Intelligent Robots 2003
13Topic 17 MatLab example of rotation
function Rotatesquare(theta) First of all
define the nodes Node -2 -2 2 2 -2 -2 2 2 -2
-21 1 1 1 1 Now convert the rotation angle to
radians Remember 180 degs. pi radians thetarad
pitheta/180 Now let us define the rotation
matrix Ctheta cos(thetarad) Stheta
sin(thetarad) Rot Ctheta -Stheta 0 Stheta
Ctheta 0 0 0 1 Now rotate the square NewNode
RotNode Draw the square plot(NewNode(1,),NewNo
de(2,)) Set the limits to the axes and ensure
they are of equal dimension axis(-5,5,-5,5) axi
s square
COMM2J Vision Intelligent Robots 2003
14Topic 17 Transformations in 3D
Translation and scaling are simple extensions of
the 2D equivalents
COMM2J Vision Intelligent Robots 2003
15Topic 17 Rotation in 3D
Rotation about any axis (R) can be constructed
from a concatenation of rotations about the three
axes
COMM2J Vision Intelligent Robots 2003
16Topic 17 Three vanishing points
The z axis rotation is the same as the 2D
case. The other two can be obtained by cycling
the components through the co-ordinate axes
COMM2J Vision Intelligent Robots 2003
17Topic 17 A useful 3-D data structure
The most useful MatLab command for drawing
surfaces in 3-D is the patch command. A patch
is a plane polygon defined by an arbitrary number
nodes.
COMM2J Vision Intelligent Robots 2003
MatLab has various ways to define the patches
that make up an object check out the MatLab
help files
18Topic 17 A useful form of the patch command
In MatLab the patch command refers to a set of
polygonal faces not just a single patch.
The command can be very sophisticated covering
surface texture, lighting and shading etc. Here
we will introduce only the most basic use of
patch
COMM2J Vision Intelligent Robots 2003
- MatLab patches can be defined in two basic ways
- By specifying the coordinates of the vertices of
each polygon, which MATLAB connects to form the
patch - By specifying the coordinates of each unique
vertex and a matrix that specifies how to connect
these vertices to form the faces
19Topic 17 The simple patch command
Using the second form of patch specification
the simplest form is patch('Vertices',vertex_mat
rix,'Faces',faces_matrix) where Vertices and
Faces are reserved words. As a small extension
to this we can add colour information
patch('Vertices',vertex_matrix,'Faces',faces_mat
rix,... 'FaceColor', colourdata)
COMM2J Vision Intelligent Robots 2003
Example patch('Vertices',V,'Faces',F,
'FaceColor', 0.2, 0.5, 0.4)
20Topic 17 Example Drawing a church
Nodes
Faces
As a simple example of the patch command we
will define a model of a church and then display
the model. The first task is to draw up, as a
text file, the list of nodes and the node numbers
which correspond to each face.
10,9,8,7,6 1,2,3,4,5 4,9,10,5,NaN 3,8,9,4,NaN 7,8,
3,2,NaN 7,2,1,6,NaN 5,10,6,1,NaN 14,13,12,11,NaN 1
4,18,17,13,NaN 15,18,14,11,NaN 16,15,11,12,NaN 17,
16,12,13,NaN 15,16,17,18,NaN 15,16,19,Nan,Nan 16,1
7,19,Nan,Nan 17,18,19,NaN,NaN 18,15,19,NaN,NaN
-50, -15, 0 -50, -15, 20 -50, 0, 30 -50, 15,
20 -50, 15, 0 50, -15, 0 50, -15, 20 50,
0, 30 50, 15, 20 50, 15, 0 50, -10, 0 70,
-10, 0 70, 10, 0 50, 10, 0 50, -10, 50
70, -10, 50 70, 10, 50 50, 10, 50 60, 0, 90
COMM2J Vision Intelligent Robots 2003
21Topic 17 The church display function
function DisplayChurch To display a basic
church Node dlmread('churchnode.txt') Face
dlmread('churchface.txt') patch('vertices',Node,'
faces',Face,'facecolor','w') axis(-100 100 -100
100 -100 100 0 1) axis square set(gcf,'renderer'
,'zbuffer') rotate3d on
COMM2J Vision Intelligent Robots 2003
22Topic 17 Perspective
Perspective is one of the most important sources
of depth queues in a computer graphics
image. Interpreting digital images to determine
distance information requires an understanding of
perspective.
Perspective projection is built up by defining a
centre of projection (C) and drawing a straight
line from a point on the object (x,y,z), passing
through the view plane at (xp,yp) to C
COMM2J Vision Intelligent Robots 2003
X
23Topic 17 The normal perspective matrix
x
C
xp
z
d
By similar triangles
COMM2J Vision Intelligent Robots 2003
Also
24Topic 17 Geometrical transforms
COMM2J Vision Intelligent Robots 2003
Unlike our other transforms this is none affine
and is not reversible.
25Topic 17 Alternative form in homogeneous
co-ordinates
COMM2J Vision Intelligent Robots 2003
26Topic 17 Vanishing points
The perspective projection of parallel lines is
also parallel if the lines are parallel to the
plane of projection. The perspective projection
of parallel lines all pass through one point in
the plane of projection if the lines are not
parallel to the plane of projection
COMM2J Vision Intelligent Robots 2003
Lines in x and y are parallel to the projection
plane
27Topic 17 Two vanishing points
COMM2J Vision Intelligent Robots 2003
28Topic 17 Three vanishing points
COMM2J Vision Intelligent Robots 2003
29Topic 17 The perspective program
function DisplayChurch(distance) To display a
basic church Node dlmread('churchnode.txt') Fac
e dlmread('churchface.txt') camproj('perspectiv
e') set(gcf,'renderer','zbuffer') campos(distan
ce distance distance) camtarget(10 0
25) camva(45) patch('vertices',Node,'faces',Fac
e,'facecolor','w') axis(-100 100 -100 100 -10
70 0 1) axis square rotate3d on
COMM2J Vision Intelligent Robots 2003
30Topic 17 MatLab functions for orientating a
viewpoint
This is just a small sub set of a large class of
camera functions
camva
campos
COMM2J Vision Intelligent Robots 2003
camtarget