Question Bank: Module1: Computer Graphics and Fundamentals of Image Processing
Question Bank: Module1: Computer Graphics and Fundamentals of Image Processing
SHATANANDA BHAT 1
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
Module 2
Question Bank:
1. Explain the Two-Dimensional Geometric Transformations.
2. Explain the homogenous representation Two-Dimensional Geometric Transformation
matrices.
3. Explain the Two-Dimensional Inverse Transformations.
4. Explain Two-Dimensional Composite Transformations.
5. Explain Two-Dimensional Composite Translation Transformations.
6. Explain Two-Dimensional Composite Rotation Transformations.
7. Explain Two-Dimensional Composite Scaling Transformations.
8. Illustrate the General Two-Dimensional Pivot-Point Rotation.
9. Illustrate the General Two-Dimensional Fixed-Point Scaling.
10. Explain the matrix concatenation properties.
11. Explain the 2D reflection transformation.
12. Explain the Raster Methods for Geometric Transformations.
13. Explain the OpenGL raster transformations functions.
14. Explain the OpenGL geometric transformations functions.
15. Explain the 3D Geometric Transformations.
16. Explain composite 3D transformations.
17. Explain the 3D Reflection transformation.
18. Explain the 3D rotation about an axis parallel to a coordinate axes.
19. Explain the 3D about an axis that is not parallel to one of the coordinate axes.
20. Explain the 3D Reflection Transformation.
21. Explain Transformation between 3D coordinate system.
22. Explain Transformation between 3D coordinate system.
SHATANANDA BHAT 2
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
Two-Dimensional Translation:
• We perform a translation on a single coordinate point by adding offsets to its
coordinates so as to generate a new coordinate position.
• We are moving the original point position along a straight-line path to its new location.
• To translate a two-dimensional position, we add translation distances tx and ty to the
original coordinates (x, y) to obtain the new coordinate position (x’, y’) as shown in
Figure
• The translation distance pair (tx,ty) is called a translation vector or shift vector
Column vector representation is given as
• This allows us to write the two-dimensional translation equations in the matrix Form
SHATANANDA BHAT 3
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
Two-Dimensional Rotation:
• We generate a rotation transformation of an object by specifying a rotation axis and a
rotation angle.
• A two-dimensional rotation of an object is obtained by repositioning the object along
a circular path in the xy plane.
• In this case, we are rotating the object about a rotation axis that is perpendicular to the
xy plane (parallel to the coordinate z axis).
• Parameters for the two-dimensional rotation are the rotation angle θ and a position (xr,
yr) , called the rotation point (or pivot point), about which the object is to be rotated.
• A positive value for the angle θ defines a counterclockwise rotation about the pivot
point, as in above Figure , and a negative value rotates objects in the clockwise
direction.
• The angular and coordinate relationships of the original and transformed point
positions are shown in Figure
• In this figure, r is the constant distance of the point from the origin, angle φ is the
original angular position of the point from the horizontal, and θ is the rotation angle.
• we can express the transformed coordinates in terms of angles θ and φ as
SHATANANDA BHAT 4
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• The transformation equations for rotation of a point about any specified rotation
position (xr , yr ):
Two-Dimensional Scaling:
• To alter the size of an object, we apply a scaling transformation.
• A simple two dimensional scaling operation is performed by multiplying object positions
(x, y) by scaling factors sx and sy to produce the transformed coordinates (x’, y’):
• The basic two-dimensional scaling equations can also be written in the following matrix
form
SHATANANDA BHAT 5
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• We can control the location of a scaled object by choosing a position, called the fixed
point, that is to remain unchanged after the scaling transformation.
• Coordinates for the fixed point, (x f , yf ), are often chosen at some object position,
such as its centroid but any other spatial position can be selected.
• For a coordinate position (x, y), the scaled coordinates (x’, y’) are then calculated from
the following relationships:
• Where the additive terms xf (1 − sx) and yf(1 − sy) are constants for all points in the
object.
SHATANANDA BHAT 6
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
Homogeneous Coordinates:
• Multiplicative and translational terms for a two-dimensional geometric transformation
can be combined into a single matrix if we expand the representations to 3 × 3 matrices
• We can use the third column of a transformation matrix for the translation terms, and
all transformation equations can be expressed as matrix multiplications.
• We also need to expand the matrix representation for a two-dimensional coordinate
position to a three-element column matrix
• A standard technique for accomplishing this is to expand each two dimensional
coordinate-position representation (x, y) to a three-element representation (xh, yh, h),
called homogeneous coordinates, where the homogeneous parameter h is a
nonzero value such that
• The rotation transformation operator R(θ ) is the 3 × 3 matrix with rotation parameter
θ.
SHATANANDA BHAT 7
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• The scaling operator S(sx, sy) is the 3 × 3 matrix with parameters sx and sy
Inverse Transformations:
• For translation, we obtain the inverse matrix by negating the translation distances.
Thus, if we have two-dimensional translation distances tx and ty, the inverse translation
matrix is
• We form the inverse matrix for any scaling transformation by replacing the scaling
parameters with their reciprocals. the inverse transformation matrix is
SHATANANDA BHAT 8
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• By multiplying the two rotation matrices, we can verify that two successive rotations
are additive:
SHATANANDA BHAT 9
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• So that the final rotated coordinates of a point can be calculated with the composite
rotation matrix as
P’ = R(θ1 + θ2) · P
1. Translate the object so that the pivot-point position is moved to the coordinate origin.
2. Rotate the object about the coordinate origin.
3. Translate the object so that the pivot point is returned to its original position.
• The composite transformation matrix for this sequence is obtained with the
concatenation which can be expressed in the form
SHATANANDA BHAT 10
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
1. Translate the object so that the fixed point coincides with the coordinate origin.
2. Scale the object with respect to the coordinate origin.
3. Use the inverse of the translation in step (1) to return the object to its original
position.
• Concatenating the matrices for these three operations produces the required scaling
matrix
SHATANANDA BHAT 11
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• The composite matrix resulting from the product of these three transformations is
Property 2:
• Transformation products, on the other hand, may not be commutative. The matrix
product M2 · M1 is not equal to M1 ·M2, in general.
• This means that if we want to translate and rotate an object, we must be careful
about the order in which the composite matrix is evaluated
SHATANANDA BHAT 12
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
other 2D transformations
Reflection:
• A transformation that produces a mirror image of an object is called a reflection.
• For a two-dimensional reflection, this image is generated relative to an axis of reflection
by rotating the object 180◦ about the reflection axis.
• Reflection about the line y = 0 (the x axis) is accomplished with the transformation
Matrix
• This transformation retains x values, but “flips” the y values of coordinate positions.
• The resulting orientation of an object after it has been reflected about the x axis is
shown in Figure
• A reflection about the line x = 0 (the y axis) flips x coordinates while keeping y
coordinates the same. The matrix for this transformation is
SHATANANDA BHAT 13
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• Figure below illustrates the change in position of an object that has been reflected
about the line x = 0.
• We flip both the x and y coordinates of a point by reflecting relative to an axis that is
perpendicular to the xy plane and that passes through the coordinate origin the matrix
representation for this reflection is
• If we choose the reflection axis as the diagonal line y = x (Figure below), the reflection
matrix is
SHATANANDA BHAT 14
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• To obtain a transformation matrix for reflection about the diagonal y = −x, we could
concatenate matrices for the transformation sequence:
(1) clockwise rotation by 45◦,
(2) reflection about the y axis, and
(3) counterclockwise rotation by 45◦. The
resulting transformation matrix is
Shear
• A transformation that distorts the shape of an object such that the transformed
shape appears as if the object were composed of internal layers that had been
caused to slide over each other is called a shear.
• Two common shearing transformations are those that shift coordinate x values
and those that shift y values. An x-direction shear relative to the x axis is
produced with the transformation Matrix
• Any real number can be assigned to the shear parameter shx Setting parameter
shx to the value 2, for example, changes the square into a parallelogram is
shown below. Negative values for shx shift coordinate positions to the left.
SHATANANDA BHAT 15
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
A unit square (a) is converted to a parallelogram (b) using the x -direction shear with shx = 2.
• We can generate x-direction shears relative to other reference lines with
SHATANANDA BHAT 16
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
Translating an object from screen position (a) to the destination position shown in (b) by
moving a rectangular block of pixel values. Coordinate positions Pmin and Pmax specify the
limits of the rectangular block to be moved, and P0 is the destination reference position.
• For array rotations that are not multiples of 90◦, we need to do some extra processing.
SHATANANDA BHAT 17
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• Each destination pixel area is mapped onto the rotated array and the amount of overlap
with the rotated pixel areas is calculated.
• A color for a destination pixel can then be computed by averaging the colors of the
overlapped source pixels, weighted by their percentage of area overlap.
• Pixel areas in the original block are scaled, using specified values for sx and sy, and
then mapped onto a set of destination pixels.
• The color of each destination pixel is then assigned according to its area of overlap
with the scaled pixel areas
SHATANANDA BHAT 18
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• The first four parameters in this function give the location and dimensions of the pixel
block; and the OpenGL symbolic constant GL_COLOR specifies that it is color values
are to be copied.
• A block of RGB color values in a buffer can be saved in an array with the function
glReadPixels (xmin, ymin, width, height, GL_RGB, GL_UNSIGNED_BYTE, colorArray);
• If color-table indices are stored at the pixel positions, we replace the constant GL_RGB
with GL_COLOR_INDEX.
• To rotate the color values, we rearrange the rows and columns of the color array, as
described in the previous section. Then we put the rotated array back in the buffer with
glDrawPixels (width, height, GL_RGB, GL_UNSIGNED_BYTE, colorArray);
• We can also combine raster transformations with logical operations to produce various
effects with the exclusive or operator
SHATANANDA BHAT 19
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
The above Figure shows a Cartesian x’ y’ system specified with coordinate origin(x0, y0) and
orientation angle θ in a Cartesian xy reference frame. To transform object descriptions from xy
coordinates to x’y’ coordinates, we set up a transformation that superimposes the x’y’ axes onto
the xy axes. This is done in two steps:
1. Translate so that the origin (x0, y0) of the xy system is moved to the origin(0, 0) of the
xy system.
2. Rotate the x’ axis onto the x axis.
SHATANANDA BHAT 20
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
The orientation of the two systems after the translation operation would then appear as in
above Figure. To get the axes of the two systems into coincidence, we then perform the
clockwise rotation
Concatenating these two transformation matrices gives us the complete composite matrix for
transforming object descriptions from the xy system to the x’y’ system:
SHATANANDA BHAT 21
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
o The suffix code is again either f or d, and the scaling parameters can be
assigned any real-number values.
o Scaling in a two-dimensional system involves changes in the x and y
dimensions, so a typical two-dimensional scaling operation has a z scaling
factor of 1.0
o Example: glScalef (2.0, -3.0, 1.0);
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
Three-Dimensional Translation
• A position P = (x, y, z) in three-dimensional space is translated to a location P’= (x’,
y’,z’) by adding translation distances tx, ty, and tz to the Cartesian coordinates of P:
Or
Three-Dimensional Rotation:
• By convention, positive rotation angles produce counterclockwise rotations about
a coordinate axis.
• Positive rotations about a coordinate axis are counterclockwise, when looking along
the positive half of the axis toward the origin.
• Transformation equations for rotations about the other two coordinate axes can
be obtained with a cyclic permutation of the coordinate parameters x, y, and z
x → y→ z→ x
Along x axis
SHATANANDA BHAT 20
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
Along y axis
1. Translate the object so that the rotation axis coincides with the parallel coordinate
axis.
2. Perform the specified rotation about that axis.
3. Translate the object so that the rotation axis is moved back to its original position.
• When an object is to be rotated about an axis that is not parallel to one of the
coordinate axes, we must perform some additional transformations we can accomplish
the required rotation in five steps:
1. Translate the object so that the rotation axis passes through the coordinate origin.
SHATANANDA BHAT 21
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
2. Rotate the object so that the axis of rotation coincides with one of the coordinate
axes.
3. Perform the specified rotation about the selected coordinate axis.
4. Apply inverse rotations to bring the rotation axis back to its original orientation.
5. Apply the inverse translation to bring the rotation axis back to its original spatial
position
• The transformation matrix for rotation about an arbitrary axis can then be expressed
as the composition of these seven individual transformations:
Three-Dimensional Scaling:
• The matrix expression for the three-dimensional scaling transformation of a position P
= (x, y, z) is given by
where scaling parameters sx, sy, and sz are assigned any positive values.
SHATANANDA BHAT 22
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• Explicit expressions for the scaling transformation relative to the origin are
• Because some graphics packages provide only a routine that scales relative to
the coordinate origin, we can always construct a scaling transformation with respect
to any selected fixed position (xf , yf , zf ) using the following transformation sequence:
1. Translate the fixed point to the origin.
2. Apply the scaling transformation relative to the coordinate origin
3. Translate the fixed point back to its original position.
This sequence of transformations is demonstrated
SHATANANDA BHAT 23
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
Three-Dimensional Reflections:
SHATANANDA BHAT 24
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
Three-Dimensional Shears
➔ These transformations can be used to modify object shapes.
➔ For three-dimensional we can also generate shears relative to the z axis.
➔ A general z-axis shearing transformation relative to a selected reference
position is produced with the following matrix:
A unit cube (a) is sheared relative to the origin (b) by Matrix 46, with sh zx = shzy = 1.
SHATANANDA BHAT 25
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
The coordinate origin of the x’y’z’ system is brought into coincidence with the xyz origin
using the translation matrix T(−x0, −y0, −z0). Also, we can use the unit axis vectors to form
the coordinate-axis rotation matrix
which transforms unit vectors u’x, u’y, and u’z onto the x, y, and z axes, respectively. The
complete coordinate transformation sequence is then given by the composite matrix R · T.
This matrix correctly transforms coordinate descriptions from one Cartesian system to
another, even if one system is left-handed and the other is right-handed.
SHATANANDA BHAT 26
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
• Alternatively, we can assign other values to the elements of the current matrix
using
glLoadMatrix* (elements16);
SHATANANDA BHAT 27
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2
We have two functions available in OpenGL for processing the matrices in a stack
glPushMatrix ( );
Copy the current matrix at the top of the active stack and store that copy in
the second stack position
glPopMatrix ( );
which destroys the matrix at the top of the stack, and the second matrix
in the stack becomes the current matrix
SHATANANDA BHAT 28