Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
Naeem A. Mahoto e-‐mail: [email protected]
Department of So9ware Engineering, Mehran UET
Jamshoro, Sind, Pakistan
Wednesday, August 5, 2015
Week No. 04 Imaging Geometry
(course: Computer Vision)
• Imaging Geometry
• TranslaRon
• Scaling
• RotaRon
Naeem A. Mahoto
Outline
Wednesday, August 5, 2015
• Any real world scene exists in a 3-‐dimensional space. • Imaging Geometry deals with the techniques and
transformaRon for mapping Real world objects and their characterisRcs on Image plane
• Any point in 3D co ordinate system is represented by BLOCK le]ers -‐ World Coordinate system -‐ W(X, Y, Z)
• Any point in 2D co-‐ordinate system/Image plane is represented by small le]ers -‐ Camera coordinate system – f (x, y)
• The process of acquiring an image of a 3-‐D scene involves projecRng the scene on a 2-‐D surface.
• The projecRon from 3-‐D to 2-‐D is a perspecRve projecRon. Naeem A. Mahoto
Imaging Geometry
Wednesday, August 5, 2015
Naeem A. Mahoto
TranslaRon
Wednesday, August 5, 2015
X
Z
P1(X1,Y1,Z1)
P2(X2,Y2,Z2)
(dx,dy,dz)
YConsider to translate a point P1, with coordinate values (x1 , y1 , z1 ) to new locaRon P2 by a displacement (dx, dy, dz)
The translaRon is easily accomplished by using the equaRon: I. X2 = X1 + dx II. Y2 = Y1 + dy III. Z2 = Z1 + dz
• Where (X2, Y2, Z2) are new points and can be represented in Matrix form, as:
Naeem A. Mahoto
TranslaRon
Wednesday, August 5, 2015
1 0 0 X2 Y2 Z2
X1 Y1 Z1
dx dy dz
0 1 0 0 0 1
=
V* = T V
where, V* is the new point, T is the translaRon matrix, and
V is the original point.
• The product of Matrices T & V seems Invalid, as Columns of T ≠ Rows of V
• Generalize this transformaRon by inserRng a DUMMY row in all three matrices
Naeem A. Mahoto
TranslaRon
Wednesday, August 5, 2015
1 0 0 X2 Y2 Z2
X1 Y1 Z1
dx dy dz
0 1 0 0 0 1
= V* = T V
1 1 1 0 0 0
1 0 0 dx dy dz
0 1 0 0 0 1
1 0 0 0
T = Transla'on Matrix
• The IniRal Point P1 can be traced back by applying the Inverse TranslaRon, that is:
Naeem A. Mahoto
Inverse TranslaRon
Wednesday, August 5, 2015
1 0 0 X2 Y2 Z2
X1 Y1 Z1
-‐dx -‐dy -‐dz
0 1 0 0 0 1
=
V = T-‐1 V*
1 1 1 0 0 0
1 0 0 -‐dx -‐dy -‐dz
0 1 0 0 0 1
1 0 0 0
T-‐1 = Inverse Transla'on Matrix
T . T-‐1 = I (IdenRty Matrix) IdenRty Matrix: Square matrix having diagonal elements equal to one
Naeem A. Mahoto
TranslaRon
Wednesday, August 5, 2015
Original Image Translated Image
Naeem A. Mahoto
TranslaRon
Wednesday, August 5, 2015
Translated Image Translated Image
This property is used in adjusRng the Objects on Monitor screen
• The scale operator performs a geometric transformaRon which can be used to shrink or zoom the size of an image
• The shrink or Zoom, depends upon the vales of scaling factor
• For values between 0 &1, the resultant Image is shrinked
• For values greater than 1, the resultant Image is expanded by that factor
Naeem A. Mahoto
Scaling
Wednesday, August 5, 2015
• The Scaling is easily accomplished by using the equaRons: I. X2 = X1 * sx II. Y2 = Y1 * sy III. Z2 = Z1 * sz
• Where (X2, Y2, Z2) are new points and expressed in Matrix form as:
Naeem A. Mahoto
Scaling
Wednesday, August 5, 2015
X2 Y2 Z2
X1 Y1 Z1
=
V* = S V
1 1
Where S represents the Scaling Matrix
sx 0 0 0 0 0
0 sy 0 0 0 sz
1 0 0 0
Naeem A. Mahoto
Scaling
Wednesday, August 5, 2015
Original Image Scaled Image at 0.5*0.5
• The IniRal Scale can be traced back by applying the Inverse Scaling, that is:
Naeem A. Mahoto
Inverse Scaling
Wednesday, August 5, 2015
1/sx 0 0 X2 Y2 Z2
X1 Y1 Z1
0 0 0
0 1/sy 0 0 0 1/sz
=
V = S-‐1 V*
1 1 1 0 0 0
S-‐1 = Inverse Scaling Matrix
S . S-‐1 = I (IdenRty Matrix) IdenRty Matrix: Square matrix having diagonal elements equal to one
1/sx 0 0 0 0 0
0 1/sy 0 0 0 1/sz
1 0 0 0
• The transformaRon used for 3-‐D rotaRon is inherently more complex than the TransformaRons (TranslaRon and Scaling)
• The simplest from of these transformaRons is for RotaRon of a point about the coordinate axes
• To rotate a point about another arbitrary Point in space, we require three transformaRon – The first translate the arbitrary point to the Origin, – The second performs the rotaRon, and – The third translates the point back to its Original posiRon
Naeem A. Mahoto
RotaRon
Wednesday, August 5, 2015
• RotaRon of a point about the Z coordinate axis by an angle θ is achieved by using the transformaRon
• The rotaRon angle θ is measured clockwise when looking at the region from a Point on the +Z axis. – This transformaRon affects only the values of X and Y coordinates
• The rotaRon operator performs a geometric transform which
maps the posiRon ( x1, y1 ) of a picture element in an input image onto a posiRon ( x2, y2 ) in an output image by rotaRng it through a user-‐specified angle θ about an origin (0,0)
Naeem A. Mahoto
RotaRon
Wednesday, August 5, 2015
Naeem A. Mahoto
RotaRon along Z-‐axis
Wednesday, August 5, 2015
P1(X1,Y1,Z1)
P2(X2,Y2,Z2)
0 X2
X1
Y 1 Y 2
φ
θ
X
Z
Y
R R
R is length of vector
φ is iniRal angle with X axis.
RotaRon is in clockwise direction.
• Assume that the Vector (R) is making an angle of φ with X axis
• IniRally, the components can be achieved as: – X1 = R cos φ – Y1 = R sin φ – Z1 = Z1
• If we rotate the vector R by θ around Z-‐axis in Counter clock
wise DirecRon, then now point formed will be given by: – X2 = R cos (φ+θ) – Y2 = R sin (φ+θ ) – Z2 = Z1 (Un changed axis)
Naeem A. Mahoto
RotaRon along Z-‐axis
Wednesday, August 5, 2015
• By expanding the terms of Sine and Cosine, we get: – X2 = R cosθ cosφ -‐ R sinφ sinθ – Y2 = R sinθ cosφ + R sinφ cosθ – Z2 = Z1
• But, we have assumed iniRally that: – R cos φ = X1 – R sin φ = Y1
• So the new point (x2,Y2,z2) becomes:
– X2 = X1 cosθ -‐ Y1 sinθ – Y2 = X1 sinθ + Y1 cosθ – Z2 = Z1
Naeem A. Mahoto
RotaRon along Z-‐axis
Wednesday, August 5, 2015
• For matrix representaRon, these equaRons can be interpreted as: – X2 = X1 cosθ -‐ Y1 sinθ + 0 – Y2 = X1 sinθ + Y1 cosθ + 0 – Z2 = 0 + 0 + Z1
• In form of matrices, the rotaRon operaRon can be given as:
Naeem A. Mahoto
RotaRon along Z-‐axis
Wednesday, August 5, 2015
cosθ -‐sinθ 0 X2 Y2 Z2
X1 Y1 Z1
sinθ cosθ 0 0 0 1
=
V* = RθZ V
• In form of matrices, the Inverse rotaRon operaRon can be given as:
Naeem A. Mahoto
Inverse RotaRon along Z-‐axis
Wednesday, August 5, 2015
cosθ sinθ 0 X1 Y1 Z1
X2 Y2 Z2
-‐sinθ cosθ 0 0 0 1
=
V = (RθZ)-1 V*
(RθZ)-‐1 represents the Inverse RotaRon Matrix
(RθZ). (RθZ)-‐1 = I (IdenRty Matrix)
• Assume that the Vector (R) is making an angle of φ with Z-‐axis
• IniRally, the components can be achieved as: – X1 = R sin φ – Y1 = Y1 – Z1 = R cos φ
• If we rotate the vector R by β around Y-‐axis in Counter clock wise DirecRon, then now point formed will be given by: – X2 = R sin (φ+ β) – Y2 = Y1 (Unchanged axis) – Z2 = R cos (φ+ β)
Naeem A. Mahoto
RotaRon along Y-‐axis
Wednesday, August 5, 2015
• By expanding the terms of Sine and Cosine, we get: – X2 = R sinφ cosβ + R cosφ sinβ – Y2 = Y1 – Z2 = R cosφ cosβ -‐ R sinφ sinβ
• But, we have assumed iniRally that: – R sin φ = X1 – R cos φ = Z1
• So the new point (x2,Y2,z2) becomes:
– X2 = X1 cosβ + Z1 sinβ – Y2 = Y1 – Z2 = Z1 cosβ -‐ X1 sinβ
Naeem A. Mahoto
RotaRon along Y-‐axis
Wednesday, August 5, 2015
• For matrix representaRon, these equaRons can be interpreted as: – X2 = X1 cosβ + Z1 sinβ + 0 – Y2 = 0 + Y1 + 0 – Z2 = -‐ X1 sinβ + 0 + Z1 cosβ
• In form of matrices, the rotaRon operaRon can be given as:
Naeem A. Mahoto
RotaRon along Y-‐axis
Wednesday, August 5, 2015
cosβ 0 sinβ X2 Y2 Z2
X1 Y1 Z1
0 1 0 -‐sinβ 0 cosβ
=
V* = Rβy V
• In form of matrices, the Inverse rotaRon operaRon can be given as:
Naeem A. Mahoto
Inverse RotaRon along Y-‐axis
Wednesday, August 5, 2015
V = (Rβy)-1 V*
(Rβy)-‐1 represents the Inverse RotaRon Matrix
(Rβy). (Rβ
y)-‐1 = I (IdenRty Matrix)
cosβ 0 -‐sinβ X1 Y1 Z1
X2 Y2 Z2
0 1 0 sinβ 0 cosβ
=
• Assume that the Vector (R) is making an angle of φ with Y-‐axis
• IniRally, the components can be achieved as: – X1 = X1 – Y1 = R cos φ – Z1 = R sin φ
• If we rotate the vector R by α around X-‐axis in Counter clock
wise DirecRon, then now point formed will be given by: – X2 = X1 (Un changed axis) – Y2 = R cos (φ+ α ) – Z2 = R sin(φ+ α )
Naeem A. Mahoto
RotaRon along X-‐axis
Wednesday, August 5, 2015
• By expanding the terms of Sine and Cosine, we get: – X2 = X1 – Y2 = R cosφ cos α -‐ R sinφ sin α – Z2 = R sinφ cos α + R cosφ sin α
• But, we have assumed iniRally that: – R cos φ = Y1 – R sin φ = Z1
• So the new point (x2,Y2,z2) becomes:
– X2 = X1 – Y2 = Y1 cos α -‐ Z1 sin α – Z2 = Z1 cos α + Y1 sin α
Naeem A. Mahoto
RotaRon along X-‐axis
Wednesday, August 5, 2015
• For matrix representaRon, these equaRons can be interpreted as: – X2 = X1 + 0 + 0 – Y2 = 0 + Y1 cos α -‐ Z1 sin α – Z2 = 0 + Y1 sin α + Z1 cos α
• In form of matrices, the rotaRon operaRon can be given as:
Naeem A. Mahoto
RotaRon along X-‐axis
Wednesday, August 5, 2015
1 0 0 X2 Y2 Z2
X1 Y1 Z1
0 cosα -‐sinα
0 sinα cosα
=
V* = Rαx V
• In form of matrices, the Inverse rotaRon operaRon can be given as:
Naeem A. Mahoto
Inverse RotaRon along X-‐axis
Wednesday, August 5, 2015
V = (Rαx)-1 V*
(Rαx)-‐1 represents the Inverse RotaRon Matrix
(Rαx). (Rα
x)-‐1 = I (IdenRty Matrix)
X1 Y1 Z1 =
1 0 0 0 cosα sinα
0 -‐sinα cosα
X2 Y2 Z2
• The Inverse rotaRon of an angle, say (θo), around an axis is, equivalent to the rotaRon by (–θo) around same axis
• For example, Inverse RotaRon of θ around Z-‐axis is equivalent to the rotaRon of –θ around Z-‐axis
Naeem A. Mahoto
Inverse RotaRon
Wednesday, August 5, 2015
(RθZ)-‐1 = R-‐θ
Z
cosθ sinθ 0 -‐sinθ cosθ 0
0 0 1
cosθ sinθ 0 -‐sinθ cosθ 0
0 0 1
=
⎩⎨⎧ =
=⋅otherwise0
1 jiRR j
Ti
Remember that Rotation Matrices are Ortho normal!
(RθZ)T.(Rθ
Z) = (RθZ).(Rθ
Z)T = I (IdenRty Matrix)
Therefore, inverse of a rotation matrix is just its transpose.
Naeem A. Mahoto
RotaRon
Wednesday, August 5, 2015
Original Image
Naeem A. Mahoto
RotaRon
Wednesday, August 5, 2015
Rotated @ 180o Rotated @ 270o
• A class of linear 2D geometric transformaRon, which maps variables (i.e., pixel intensity values) located at (x1, y1) of input image into new variables (x2, y2) of output image.
• The general affine transformaRon is commonly wri]en in homogeneous coordinates as shown:
• Homogenous coordinates: A coordinate system used in projecRve geometry including points at infinity. It represents infinity using finite coordinates
Naeem A. Mahoto
Affine TransformaRon
Wednesday, August 5, 2015
• Lets consider a, w two real numbers, then v = a/w tends to infinity if w tends to zero. If w != 0 then v = a/w, and if w = 0, infinite value is represented by v = (a,0). Thus concept of infinity is represented as number pair like (a,w)
• Replace x-‐y coordinates in digital image with x/w, y/w. A funcRon f(x,y) becomes f(x/w, y/w)
• • By defining only the B matrix, this transformaRon can carry out
pure TranslaRon:
Naeem A. Mahoto
Affine TransformaRon: TranslaRon
Wednesday, August 5, 2015
• Similarly, pure Scaling is:
Naeem A. Mahoto
Affine TransformaRon: Scaling
Wednesday, August 5, 2015
• Pure RotaRon uses the A matrix and is defined as (for posiRve angles being clockwise rotaRons):
Naeem A. Mahoto
Affine TransformaRon: RotaRon
Wednesday, August 5, 2015
• Some of the important characterisRcs of PerspecRve ProjecRon are: – Objects which are of the same size but at different distances from the
image plane would appear to be of different sizes. – Parallel lines in the scene would appear to converge at some finite
point. – The expanse of an object along the line of sight appears much smaller
compared to the expanse along a direcRon perpendicular to the line of sight.
– Consider a plane which is parallel to the image plane and passing through the center of projecRons. All the world points lying on this plane will not get projected on to the image plane. Naeem A. Mahoto
PerspecRve ProjecRon
Wednesday, August 5, 2015
1. Show that following idenRRes are true: I. R90
Y . R90X = R270
Z . R90Y
II. R90Y . R180
X = R180Z . R90
Y III. R180
Y . R90X = R180
Z . R270X
IV. R180Y . R270
X = R180Z . R90
X
3. Consider a vector (7,3,2) which is rotated around Z-‐axis by 900, and then rotated around Y-‐axis by 900 and finally translated by (4,-‐3,7). Find the new coordinates of the vector. All rotaRons are clockwise.
Naeem A. Mahoto
Homework
Wednesday, August 5, 2015
3. What is rotaRon for an object rotated by 300 around z-‐axis, followed by 600 around x-‐axis and followed by 900 a rotaRon of around y-‐axis. All rotaRons are counter clockwise.
Naeem A. Mahoto
Homework
Wednesday, August 5, 2015
Naeem A. Mahoto Wednesday, August 5, 2015