KEMBAR78
Question Bank: Module1: Computer Graphics and Fundamentals of Image Processing | PDF | 2 D Computer Graphics | Cartesian Coordinate System
0% found this document useful (0 votes)
34 views33 pages

Question Bank: Module1: Computer Graphics and Fundamentals of Image Processing

Hi hi Bob Hughes, Mike Cotterell, Rajib Mall: Software Project Management, 6th Edition, McGraw Hill Education, 2018

Uploaded by

Kavana Kn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views33 pages

Question Bank: Module1: Computer Graphics and Fundamentals of Image Processing

Hi hi Bob Hughes, Mike Cotterell, Rajib Mall: Software Project Management, 6th Edition, McGraw Hill Education, 2018

Uploaded by

Kavana Kn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2

Question Bank: Module1


1. Illustrate the working of Refresh Cathode-Ray Tubes in detail with suitable diagrams.
2. Define resolution of a CRT.
3. Explain Raster-Scan Displays and Random Scan Displays
4. List and explain the applications of Computer Graphics.
5. Explain the working of Color CRT Monitors
6. List and explain the various types of Flat panel display devices.
7. Explain the architecture of Raster scan system and Video controller with suitable diagrams.
8. Explain the architecture of Raster-Scan Display Processor with suitable diagram.
9. List and explain the different libraries used in OpenGL.
10. Describe the general structure of OpenGL programs with an example.
11. Explain Coordinate reference frames.
12. Illustrate OpenGL Point Functions with a suitable example.
13. Illustrate OpenGL Line Functions with a suitable example.
14. Illustrate the OpenGL Point attributes functions and Line attribute functions.
15. Illustrate DDA Line drawing Algorithm.
16. Apply DDA Line drawing algorithm to Calculate the points between the starting point (5, 6) and
ending point (13, 10).
17. Illustrate the Bresenhams Line Drawing Algorithm.
18. Apply the Bresenhams Line Drawing Algorithm to Calculate the points between the starting
coordinates (9, 18) and ending coordinates (14, 22).
19. List and explain the different types of Input devices.
20. List and explain the OpenGL Polygon Fill-Area Functions with suitable examples.

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

Session9: Basic 2D Geometric Transformations, matrix


representations and homogeneous coordinates.
Two-Dimensional Geometric Transformations
Operations that are applied to the geometric description of an object to change its position,
orientation, or size are called geometric transformations.
The geometric-transformation functions that are available in all graphics packages are those
for translation, rotation, and scaling.

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 values of x’ and y’ is calculated as

• 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

• Translation is a rigid-body transformation that moves objects without deformation.

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

• The original coordinates of the point in polar coordinates are

SHATANANDA BHAT 4
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2

• Substituting expressions of x and y in the equations of x’ and y’ we get


• We can write the rotation equations in the matrix form
P’ = R·P
Where the rotation matrix is,

• Rotation of a point about an arbitrary pivot position is illustrated in Figure

• 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

Where S is the 2 × 2 scaling matrix


Any positive values can be assigned to the scaling factors sx and sy.

• Values less than 1 reduce the size of objects

SHATANANDA BHAT 5
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2

• Values greater than 1 produce enlargements.


• Specifying a value of 1 for both sx and sy leaves the size of objects unchanged.
• When sx and sy are assigned the same value, a uniform scaling is produced, which
maintains relative object proportions.
• Unequal values for sx and sy result in a differential scaling that is often used in design
applications.
• In some systems, negative values can also be specified for the scaling parameters.
This not only resizes an object, it reflects it about one or more of the coordinate axes.
• Figure below illustrates scaling of a line by assigning the value 0.5 to both sx and sy

• 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:

• We can rewrite Equations to separate the multiplicative and additive terms as

• Where the additive terms xf (1 − sx) and yf(1 − sy) are constants for all points in the
object.

Matrix representations and homogeneous


coordinates
Matrix Representations and Homogeneous Coordinates:
• Each of the three basic two-dimensional transformations (translation, rotation, and
scaling) can be expressed in the general matrix form

• With coordinate positions P and P’ represented as column vectors.


• Matrix M1 is a 2 × 2 array containing multiplicative factors, and M2 is a two-element
column matrix containing translational terms.
• For translation, M1 is the identity matrix.
• For rotation or scaling, M2 contains the translational terms associated with the pivot
point or scaling fixed point.

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

• A general two-dimensional homogeneous coordinate representation could also be


written as (h·x, h·y, h).
• A convenient choice is simply to set h = 1. Each two-dimensional position is then
represented with homogeneous coordinates (x, y, 1).
• The term homogeneous coordinates is used in mathematics to refer to the effect of
this representation on Cartesian equations.

Two-Dimensional Translation Matrix:


• The homogeneous-coordinate for translation is given by

• This translation operation can be written in the abbreviated form

with T(tx,ty) as the 3 × 3 translation matrix


Two-Dimensional Rotation Matrix:
• Two dimensional rotation transformation equations about the coordinate origin can be
expressed in the matrix form

• 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

Two-Dimensional Scaling Matrix:


• A scaling transformation relative to the coordinate origin can now be expressed as the
matrix multiplication

• 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

• An inverse rotation is accomplished by replacing the rotation angle by its negative.


• A two-dimensional rotation through an angle θ about the coordinate origin has the
inverse transformation matrix

• We form the inverse matrix for any scaling transformation by replacing the scaling
parameters with their reciprocals. the inverse transformation matrix is

Session11: 2D Composite transformations, other 2D transformations

SHATANANDA BHAT 8
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2

Session10: Two-Dimensional Composite Transformations,


other 2D transformations
Two-Dimensional Composite Transformations:
• Forming products of transformation matrices is often referred to as a concatenation, or
composition, of matrices if we want to apply two transformations to point position P,
the transformed location would be calculated as
• The coordinate position is transformed using the composite matrix M, rather than
applying the individual transformations M1 and then M2.

Composite Two-Dimensional Translations:


• If two successive translation vectors (t1x, t1y) and (t2x, t2y) are applied to a two
dimensional coordinate position P, the final transformed location P’ is calculated as

where P and P’ are represented as three-element, homogeneous-coordinate column


vectors

• Also, the composite transformation matrix for this sequence of translations is

Composite Two-Dimensional Rotations:


• Two successive rotations applied to a point P produce the transformed position

• By multiplying the two rotation matrices, we can verify that two successive rotations
are additive:

R(θ2) · R(θ1) = R(θ1 + θ2)

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

Composite Two-Dimensional Scalings:


• Concatenating transformation matrices for two successive scaling operations in two
dimensions produces the following composite scaling matrix

General Two-Dimensional Pivot-Point Rotation:


• We can generate a two-dimensional rotation about any other pivot point (xr , yr ) by
performing the following sequence of translate-rotate-translate operations:

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

which can be expressed in the form

where T(−xr , −yr ) = T−1(xr , yr ).

General Two-Dimensional Fixed-Point Scaling:


• To produce a two-dimensional scaling with respect to a selected fixed position (xf , yf ),
when we have a function that can scale relative to the coordinate origin only. This
sequence is

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

General Two-Dimensional Scaling Directions:


• Parameters sx and sy scale objects along the x and y directions.
• We can scale an object in other directions by rotating the object to align the desired
scaling directions with the coordinate axes before applying the scaling
transformation.
• Suppose we want to apply scaling factors with values specified by parameters s1 and
s2 in the directions shown in Figure

• The composite matrix resulting from the product of these three transformations is

Matrix Concatenation Properties:


Property 1:
• Multiplication of matrices is associative.
• For any three matrices,M1,M2, andM3, the matrix product M3 · M2 · M1 can be
performed by first multiplying M3 and M2 or by first multiplying M2 and M1:
M3 ·M2 · M1 = (M3 · M2) · M1 = M3 · (M2 · M1)

• We can construct a composite matrix either by multiplying from left to right


(premultiplying) or by multiplying from right to left (postmultiplying)

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

• Reversing the order in which a sequence of transformations is performed may affect


the transformed position of an object. In (a), an object is first translated in the x
direction, then rotated counterclockwise through an angle of 45◦. In (b), the object is
first rotated 45◦ counterclockwise, then translated in the x direction.

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

• An example of reflection about the origin is shown in Figure

• 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

which transforms coordinate positions as

• 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

Now, coordinate positions are transformed as

• A y-direction shear relative to the line x = xref is generated with the


transformation Matrix

which generates the transformed coordinate values

SHATANANDA BHAT 16
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2

Session11: Raster methods for geometric transformations


Raster Methods for Geometric Transformations
• Raster systems store picture information as color patterns in the frame buffer.
• Therefore, some simple object transformations can be carried out rapidly by
manipulating an array of pixel values
• Few arithmetic operations are needed, so the pixel transformations are particularly
efficient.
• Functions that manipulate rectangular pixel arrays are called raster operations and
moving a block of pixel values from one position to another is termed a block transfer,
a bitblt, or a pixblt.
• Figure below illustrates a two-dimensional translation implemented as a block transfer
of a refresh-buffer area

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.

• Rotations in 90-degree increments are accomplished easily by rearranging the


elements of a pixel array.
• We can rotate a two-dimensional object or pattern 90◦ counterclockwise by reversing
the pixel values in each row of the array, then interchanging rows and columns.
• A 180◦ rotation is obtained by reversing the order of the elements in each row of the
array, then reversing the order of the rows.
• Figure below demonstrates the array manipulations that can be used to rotate a pixel
block by 90◦ and by 180◦.

• 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

• The general procedure is illustrated in Figure below.

• 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

Session12: OpenGL raster transformations, Transformation


between 2D coordinate system
OpenGL Raster Transformations
• A translation of a rectangular array of pixel-color values from one buffer area to another
r can be accomplished in OpenGL as the following copy operation:
glCopyPixels (xmin, ymin, width, height, GL_COLOR);

• 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);

• A two-dimensional scaling transformation can be performed as a raster operation in


OpenGL by specifying scaling factors and then invoking either glCopyPixels or
glDrawPixels.
• For the raster operations, we set the scaling factors with
glPixelZoom (sx, sy);

• We can also combine raster transformations with logical operations to produce various
effects with the exclusive or operator

Transformations betweenTwo-Dimensional Coordinate Systems


Computer-graphics applications involve coordinate transformations from one reference frame
to another during various stages of scene processing. The viewing routines transform object
descriptions from world coordinates to device coordinates. For modeling and design
applications, individual objects are typically defined in their own local Cartesian references.
These local-coordinate descriptions must then be transformed into positions and orientations
within the overall scene coordinate system.
A facility-management program for office layouts, for instance, has individual coordinate
descriptions for chairs and tables and other furniture that can be placed into a floor plan, with
multiple copies of the chairs and other items in different positions.
Also, scenes are sometimes described in non-Cartesian reference frames that take advantage
of object symmetries. Coordinate descriptions in these systems must be converted to
Cartesian world coordinates for processing. Some examplesof non-Cartesian systems are
polar coordinates, spherical coordinates, elliptical coordinates, and parabolic coordinates.

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.

Translation of the coordinate origin is accomplished with the matrix transformation

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

Session13: OpenGL geometric transformations function,


OpenGL geometric transformations function

OpenGL Functions for Two-Dimensional Geometric


Transformations
• To perform a translation, we invoke the translation routine and set the components for
the three-dimensional translation vector.
• In the rotation function, we specify the angle and the orientation for a rotation axis that
intersects the coordinate origin.
• In addition, a scaling function is used to set the three coordinate scaling factors relative
to the coordinate origin. In each case, the transformation routine sets up a 4 × 4 matrix
that is applied to the coordinates of objects that are referenced after the transformation
call.

OpenGL geometric transformations function

Basic OpenGL Geometric Transformations


• A 4× 4 translation matrix is constructed with the following routine:
glTranslate* (tx, ty, tz);
o Translation parameters tx, ty, and tz can be assigned any real-number values,
and the single suffix code to be affixed to this function is either f (float) or d
(double).
o For two-dimensional applications, we set tz = 0.0; and a two-dimensional
position is represented as a four-element column matrix with the z component
equal to 0.0.
o example: glTranslatef (25.0, -10.0, 0.0);
• Similarly, a 4 × 4 rotation matrix is generated with
glRotate* (theta, vx, vy, vz);
o where the vector v = (vx, vy, vz) can have any floating-point values for its
components.
o This vector defines the orientation for a rotation axis that passes through the
coordinate origin.

o If v is not specified as a unit vector, then it is normalized automatically before


the elements of the rotation matrix are computed.
o The suffix code can be either f or d, and parameter theta is to be assigned a
rotation angle in degree.
o For example, the statement: glRotatef (90.0, 0.0, 0.0, 1.0);
• We obtain a 4 × 4 scaling matrix with respect to the coordinate origin with the following
routine:
glScale* (sx, sy, sz);
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

Session14:3D Geometric Transformations:


Translation, rotation, scaling
Three-Dimensional Geometric Transformations
• Methods for geometric transformations in three dimensions are extended from
two dimensional methods by including considerations for the z coordinate.
• A three-dimensional position, expressed in homogeneous coordinates, is
represented as a four-element column vector

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:

• We can express these three-dimensional translation operations in matrix form

Or

• Moving a coordinate position with translation vector T = (tx , ty , tz )

• Shifting the position of a three-dimensional object using translation vector T.


COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2

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.

Three-Dimensional Coordinate-Axis Rotations:


Along z axis:

• In homogeneous-coordinate form, the three-dimensional z-axis rotation equations are

• 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

• An inverse three-dimensional rotation matrix is obtained in the same by replacing θ


with −θ.

General Three-Dimensional Rotations:


• A rotation matrix for any axis that does not coincide with a coordinate axis can be set
up as a composite transformation involving combinations of translations and the
coordinate- axis rotations the following transformation sequence is used:

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.

• A coordinate position P is transformed with the sequence shown in this figure as

Where the composite rotation matrix for the transformation is

• 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

• The three-dimensional scaling transformation for a point position can be represented


as

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

Session15: composite 3D transformations,Other Three-


Dimensional Transformations:

Composite Three-Dimensional Transformations


• We form a composite three dimensional transformation by multiplying the matrix
representations for the individual operations in the transformation sequence.
• We can implement a transformation sequence by concatenating the individual
matrices from right to left or from left to right, depending on the order in which the
matrix representations are specified

Three-Dimensional Reflections:

• A reflection in a three-dimensional space can be performed relative to a selected


reflection axis or with respect to a reflection plane.
• Reflections with respect to a plane are similar; when the reflection plane is a coordinate
plane (xy, xz, or yz), we can think of the transformation as a 180◦ rotation in four-
dimensional space with a conversion between a left-handed frame and a right-handed
frame
• An example of a reflection that converts coordinate specifications from a right handed
system to a left-handed system is shown below

SHATANANDA BHAT 24
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2

• The matrix representation for this reflection relative to the xy plane is

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:

➔ The Below figure shows the shear transformation of a cube

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

Session16:Transformation between 3D coordinate


system.,OpenGL geometric transformations functions
Transformations between Three-Dimensional Coordinate
Systems
Coordinate-system transformations are employed in computer-graphics packages to construct
(model) scenes and to implement viewing routines for both two-dimensional and three-
dimensional applications. A transformation matrix for transferring a two-dimensional scene
description from one coordinate system to another is constructed with operations for
superimposing the coordinate axes of the two systems. The same procedures apply to three-
dimensional scene transfers.
We again consider only Cartesian reference frames, and we assume that an x’y’z’ system is
defined with respect to an xyz system. To transfer the xyz coordinate descriptions to the x’y’z’
system, we first set up a translation that brings the x’y’z’ coordinate origin to the position of
the xyz origin. This is followed by a sequence of rotations that align corresponding coordinate
axes. If different scales are used in the two coordinate systems, a scaling transformation may
also be necessary to compensate for the differences in coordinate intervals.
The following Figure shows an x’y’z’ coordinate system with origin (x0, y0, z0) and unit axis
vectors defined relative to an xyz reference frame.

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

OpenGL Geometric Transformation functions


OpenGL Matrix Stacks

• The default argument for the glMatrixMode function is GL_MODELVIEW.


• Once we are in the modelview mode (or any other mode), a call to a
transformation routine generates a matrix that is multiplied by the current matrix
for that mode.
• In addition, we can assign values to the elements of the current matrix, and
there are two functions in the OpenGL library for this purpose.
• With the following function, we assign the identity matrix to the current matrix:
glLoadIdentity ( );

• Alternatively, we can assign other values to the elements of the current matrix
using
glLoadMatrix* (elements16);

• A single-subscripted, 16-element array of floating-point values is specified with


parameter elements16, and a suffix code of either f or d is used to designate
the data type.
• The elements in this array must be specified in column-major order. That is, we
first list the four elements in the first column, and then we list the four elements
in the second column, the third column, and finally the fourth column.
• To illustrate this ordering, we initialize the modelview matrix with the following
code:

which produces the matrix

SHATANANDA BHAT 27
COMPUTER GRAPHICS AND FUNDAMENTALS OF IMAGE PROCESSING MODULE 2

• We can also concatenate a specified matrix with the current matrix:


glMultMatrix*(otherElements16);

• The suffix code is either f or d, and parameter otherElements16 is a 16-element


, single subscripted array that lists the elements of some other matrix in column-
major order.
• The current matrix is postmultiplied by the matrix specified in glMultMatrix, and
this product replaces the current matrix. Thus, assuming that the current matrix
is the modelview matrix, which we designate as M, then the updated modelview
matrix is compted as
M = M.M1

❖ OpenGL supports a modelview stack depth of at least 32,


glGetIntegerv (GL_MAX_MODELVIEW_STACK_DEPTH, stackSize);
❖ determine the number of positions available in the modelview stack for a
particular implementation of OpenGL.
❖ It returns a single integer value to array stackSize

❖ other OpenGL symbolic constants:


GL_MAX_PROJECTION_STACK_DEPTH,
GL_MAX_TEXTURE_STACK_DEPTH, or
GL_MAX_COLOR_STACK_DEPTH.
❖ We can also find out how many matrices are current ly in the stack with
glGetIntegerv (GL_MODELVIEW_STACK_DEPTH,
numMats);

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

You might also like