Introduction to Computer Graphics
Introduction to Computer Graphics
1
INTRODUCTION TO COMPUTER
GRAPHICS
Unit Structure
1.0 Objectives
1.1 Overview of Computer Graphics
1.1.1 Definitions
1.1.2 Advantages of Computer Graphics
1.2 Computer Graphics Applications
1.2.1 Computer Aided Design
1.2.2 Computer Art
.in
1.2.3 Entertainment
1.2.4 Education and Training
1.2.5 Presentation Graphics
es
1.2.6 Visualization
1.2.7 Image Processing
ot
1.2.8 Graphical User Interfaces
1.3 Computer Graphics Software
1.3.1 Coordinate Representations
un
1.4.1 Keyboards
1.4.2 Mouse
1.4.3 Trackball and Spaceball
1.4.4 Joysticks
1.4.5 Data Glove
1.4.6 Image Scanner
1.4.7 Touch Panels
1.4.8 Light Pens
1.4.9 Voice Systems
1.5 Active and Passive Graphics
1.6 Summary
1.7 Unit End Exercise
1.8 References
1.9 Bibliography
1
1.0 OBJECTIVES
.in
1.1.1 Definitions:
Computer Graphics: It is a field of computer science that deals with
es
creating, manipulating, storing and displaying pictures or objects on a
display device.
Pixel: It is a smallest element on the display screen.
ot
2
1.2.1 Computer Aided Design :
It is used in
Design processes of architecture and engineering systems.
Design of automobiles, textiles, spacecraft, aircrafts, buildings, etc.
.in
Fig. 1 Use of CAD in computer graphics
es
1.2.2 Computer Art :
It is majorly used in the field of fine arts and commercial applications.
Use of applications like mathematics package, paint package, animation
ot
program and desktop publishing software helps in computer art. E.g.,
cartoon drawing, painting.
un
m
1.2.3 Entertainment :
It can be used to create any motion pictures and videos.
Animated movies or video clips can be created.
Sound and music can be used to generate any movie clips, animated
shows or TV shows.
3
Games can also be made with interactivity features.
.in
understanding more easier.
In distance learning, where students are not at the same place, use of
computer graphics plays an important role, by means of conducting
es
tests. E.g., kahoot.it, quizzes.com.
For training, simulators can be made as hands on experience for
candidates for better understanding.
ot
un
m
1.2.6 Visualization :
.in
To check insights of data, to study behavior of processes, visualization
is required with proper use of computer graphics.
es
ot
un
5
1.2.8 Graphical User Interfaces :
A window manager is an important component in GUI that allows a
user to display multimedia window areas.
For fast selection processing, use of menus, icons and buttons are made
in an interface.
.in
Fig. 8 Use of GUI in computer graphics
es
1.3 COMPUTER GRAPHICS SOFTWARE
ot
Graphics software can be classified into two categories:
a. General Programming Packages
un
graphics functions.
o Basic functions include:
Generate picture components like circles, polygons, straight lines,
etc.
Filling colors and setting intensity values
Selecting views
Applying transformations
o E.g., graphics library system, Open GL, Open CV
b. Special Purpose Application Packages
o These set of graphics packages are designed for non-programmers.
o Users can create their own graphics without worrying about the
underlying concepts.
6
o The interface to the graphics routines in such packages allows users
to communicate with the programs in their own terms.
o E.g., Paint, CAD, etc.
.in
local coordinates or master coordinates.
Objects can be placed into appropriate positions within a scene using a
reference frame called as world coordinates, once the individual object
shapes have been specified.
es
For display, the world coordinate description of the scene is transferred
to one or more output device reference frames, called as device
ot
coordinates or screen coordinates.
Before final conversion to specific device coordinates, a graphics
un
7
Attributes: The properties of output primitives are referred to as
attributes that describes how a primitive is to be displayed. It includes
line styles, color specifications, intensity of colors and text styles.
Geometric transformations: It is used to change the size, orientation
or position of an object within a scene.
Viewing transformations: It is used to specify view that is to be
presented and portion of the output display area that is to be used.
Input functions: It is used to control and process the data flow from
interactive devices.
Control operations: It is used in clearing a display screen or
initializing parameters.
.in
be used with different hardware systems and used in different
implantation and applications.
The Graphical Kernel System (GKS) was developed to adopt the first
es
graphics software standard by the International Standard Organization
(ISO).
Another graphics standard developed and approved was Programmers
ot
Hierarchical Interactive Graphics System (PHIGS), which is an
extension of GKS.
un
1.4.1 Keyboards:
To enter any kind of string or number, an alphanumeric keyboard is
used as an input in a graphics system.
8
A general keyboard can consist of 84 keys or 101 keys.
A keyboard consists of numeric keys (0 to 9), alphabetic keys (A to Z),
control keys (Ctrl, Shift, Alt), special symbol keys (!, @, #,”, ?), cursor
control keys (arrow keys), function keys (F1 to F9).
Keyboards are not only used to enter any numbers, or symbols or
alphabets, it is also be used for menu selection.
A numeric keypad is on the right of keyboard for fast entry of numeric
data.
Fig. 10 Keyboard
1.4.2 Mouse:
.in
To position the cursor on the screen, mouse is used.
The roller present at the bottom of the mouse records the direction of
the movement.
es
The motion of the mouse can also be detected by option sensor in
which the mouse is moved over a special mouse pad that has a grid of
ot
horizontal and vertical lines.
The optical sensor detects movement across the lines in the grid.
un
The mouse consists of two or three buttons on the top to execute any
kind of operation.
There is a type of mouse called as Z mouse which can be used to pick
an object, rotate that object, move the object in any direction and
m
Fig. 11 Mouse
9
1.4.3 Trackball and Spaceball:
A trackball is a ball that is used to rotate with palm of the hand or with
the fingers, to produce screen-cursor movement.
A resistor with sliding or rotating contact (called potentiometers)
attached to the ball, is used to measure the amount and direction of
rotation.
Trackballs are generally mounted on keyboards and is a two-
dimensional positioning device.
A spaceball does not actually move.
A sensor whose resistance varies when force applied (called strain
gauges) measures the amount of pressure applied to the spaceball to
provide input for spatial positioning and orientation as the ball is
pushed or pulled in various directions.
Spaceballs are used for three-dimensional positioning and selection
operations in CAD, animation, virtual-reality systems, modeling and
other applications.
.in
es
ot
un
m
1.4.4 Joysticks:
A joystick consists of a small, vertical lever (called the stick) mounted
on a base that is used to move the screen cursor in all directions.
Position on the screen is selected with actual stick movement or by
applying pressure on stick.
10
Joysticks can be standalone device or can be mounted on a keyboard.
The direction of the screen-cursor movement depends upon the
direction in which the stick is moved.
Potentiometers mounted at the base of the joystick measure the amount
of movement, and springs return the stick to the center position when it
is released.
Fig. 13 Joystick
.in
Data glove is used to grasp a virtual object.
The glove is made up of many sensors that helps to detect motions of
fingers and hand.
es
The information about the position and orientation of hand is provided
by the electromagnetic coupling between transmitting and receiving
antennas.
ot
.in
1.4.7 Touch Panels :
A type of display screen that has a touch-sensitive transparent panel
es
covering the screen are called touch panels.
The input is recorded through finger when in contact with the screen.
It allows a user to interact directly what is being displayed instead of
ot
12
When its tip is moved over the monitor screen, the photocell-sensing
element detects screen location and sends corresponding signals to
CPU.
.in
These systems operate by matching an input against a predefined
dictionary of words and phrases. es
It is easy to use and most efficient device.
E.g., a microphone.
ot
un
m
1.6 SUMMARY
Computer graphics is a way in which pictures or object can be created
and manipulated.
It can be used in creation of 2D images, 3D images or animations.
The applications of computer graphics can be in the field of education,
training, CAD systems, entertainment, presentations, computer art,
image processing and many more.
The use of various graphics functions with graphics standard make up a
graphics software.
.in
Various devices like keyboard, mouse, data glove, joysticks, etc. can be
used to provide input to any graphics system.
es
1.9 UNIT END EXERCISE
1. Define computer graphics.
ot
2. List and explain any five applications of computer graphics.
3. Write a short note on computer graphics software.
un
1.7 REFERENCES
1.8 BIBLIOGRAPHY
J. Hughes, A. Van Dam, M. MCGuire, D. Sklar, J. Foley, and K.
Akeley, Computer Graphics, Principles and Practice, 3rd Edition,
Pearson, 2014.
P. Shirley and S. Marschner, “Fundamentals of Computer Graphics:
Ray Tracing,” CRC Press. p. 752, 2009.
*****
14
2
DISPLAY TECHNOLOGIES
Unit Structure
2.0 Objectives
2.1 Display Devices
2.1.1 Storage Tubes Graphics Displays
2.1.2 Calligraphic Refresh Graphics Displays
2.1.3 Raster Refresh Graphics Displays
2.1.4 Random Scan Display v/s Raster Scan Display
2.1.5 Cathode Ray Tube (CRT)
2.1.6 Color CRT
2.1.6.1 Beam-Penetration Technique
2.1.6.2 Shadow Mask Technique
.in
2.1.7 Liquid Crystal Display (LCD)
2.1.8 LCD Displays v/s CRT Monitors
2.2 Raster Scan Systems
2.2.1 Video Controller
es
2.2.2 Display Processor
2.3 Random Scan Systems
ot
2.4 Summary
2.5 Unit End Exercise
un
2.6 References
2.7 Bibliography
2.0 OBJECTIVES
m
.in
es
ot
Working Principle:
1. There are two electron guns, namely primary gun and flood gun.
m
2. The primary gun stores the picture pattern and the flood gun
maintains the picture display.
3. A primary gun produces high-speed electrons, which strike on the
storage grid to draw the picture pattern.
4. Continuous low speed electrons from flood gun pass through the
control grid and got attracted to the positive charged areas of the
storage grid.
5. The low speed electron then penetrates the storage grid and strike
the phosphor coating.
6. During this process, the collector behind the storage grid smooths
out the flows of food electrons.
Merits:
It has flat screen.
16
Refreshing of CRT is not required.
Complex picture can be displayed on high resolution.
Demerits:
The performance of DVST is poor compared to CRT.
Erasing requires removal of charge on the storage grid.
Selective or part erasing of screen is not possible.
Erasing of screen produces flash over the entire screen.
.in
A CRT, as a random scan display unit, has an electron beam directed
only to the parts of the screen where a picture is to be drawn.
Random scan monitors draw a picture one line at a time.
es
The component of a picture can be drawn and refreshed by a random
scan system in a specified order.
ot
A picture definition is stored as a set of line-drawing commands in an
area of memory called a refresh display file or refresh buffer.
un
.in
2.1.3 Raster Refresh Graphics Displays:
A raster scan display is the most common method of drawing
images on a CRT screen. es
Working Principle:
In this method, horizontal and vertical deflection signals are generated
to move a beam all over the screen in a pattern for displaying any
ot
image.
The electron beam is swept across the screen one row at a time from
top to bottom.
un
The electron beam sweeps back and forth from left to right across the
screen.
m
Horizontal Retrace
While electron beam moves from left to right the beam is on and when it
moves back from right to left the beam is off. This phenomenon is known
as horizontal retrace.
Vertical Retrace
As soon as the beam reaches the bottom of the screen, it is turned off and
is rapidly retraced back to the top to start again. This is known as vertical
retrace.
18
Fig 3. Horizontal and vertical retra
Raster scan displays maintain the steady image on the screen by
repeating scanning of the scan image. This process is known as
refreshing the screen.
.in
es
ot
un
.in
Thus, control grid controls the intensity of the spot where the electron
beam strikes the screen.
The focusing system concentrates the electron beam so that the beam
es
converges to a small point when it hits the phosphor.
The deflection system of CRT consists of two pairs of parallel plates,
namely horizontal and vertical deflection plates.
ot
The voltage applied to vertical deflection of the electron beam and the
voltage applied to the horizontal deflection plates controls the
un
20
2.1.6 Color CRT:
A CRT monitor displays color pictures by using a combination of
phosphors that emit different-colored light.
It generates a range of colors by combining the emitted light from
different phosphors.
There are two basic techniques used for producing color displays:
o Beam-penetration technique
o Shadow mask technique
.in
The outer layer is of red phosphor and the inner layer is of green
phosphor.
A beam of slow electrons excites only the outer red color.
es
A beam of very fast electrons penetrates through the red layer and
excites the inner green layer.
At intermediate beam speeds, combination of red and green light are
ot
emitted and two additional colors, orange and yellow are displayed.
The beam acceleration voltage controls the speed of electrons and
un
Merits:
It is inexpensive technique to produce color in random scan monitors.
m
Demerits:
It can display only four colors.
The quality of picture produced by this technique is not good as
compared to other techniques.
.in
A dot triangle consists of three small phosphor dots of red, green and
blue color. es
A dot triangle when activated appears as a small dot on the screen,
which has color of combination of three small dots.
By varying the intensity of three electron beams, we can obtain
ot
different colors in the shadow mask CRT.
un
m
22
The intersection of two conductors defines a pixel position.
In the ON state, polarized light passing through material is twisted so
that it will pass through the opposite polarizer.
It is then reflected back to the viewer.
To turn OFF the pixel, we apply a voltage to the two intersecting
conductors to align the molecules so that light is not twisted.
Merits:
Less bulky.
Suitable component for portable devices like laptops, mobile phones,
etc.
Power consumption is much less so ideal to be operated by batteries.
Demerits:
More expensive than the CRT and more difficult to manufacture.
.in
es
ot
un
m
23
Much expensive. Less expensive.
Portable. Not portable.
Restricted viewing angles. It Viewable from almost every
needs to be viewed from front to angle.
have better view.
.in
es
ot
un
Video controller reads the command from frame buffer and draw pixel
m
accordingly.
24
Fig 10. Architecture of a Raster Scan System
In some systems, origin is set at the top left corner. In such case, Y
coordinate increases from top to bottom.
.in
Two register are maintained to store the coordinates of pixel on screen.
After processing all the pixels on current scan line, content of x register
un
In high quality systems, use two frame buffers, so that one buffer can
be used for refreshing while other is being filled with intensity values.
25
.in
Fig 11. Refresh operation on video controller
es
2.2.2 Display Processor :
This method can also be used to scan convert curved lines or polygon
outlines.
.in
es
ot
un
2.4 SUMMARY
.in
In shadow mask technique, the three-phosphor dots produced are red,
green and blue, which produces more number of colors.
LCD are portable that consumes less electricity.
es
2.5 UNIT END EXERCISE
ot
2.6 REFERENCES
2.7 BIBLIOGRAPHY
.in
3.3.1 Midpoint Circle Algorithm
3.3.2 Bresenham’s Circle Algorithm
3.3.3 Midpoint Ellipse Algorithm
es
3.4 Aliasing and Problems in aliasing
3.5 Summary
3.6 Unit End Exercise
ot
3.7 References
3.8 Bibliography
un
3.0 OBJECTIVES
Scan conversion:
Scan conversion is defined as a process of representing continuous
graphic object as a collection of discrete pixels. It is also called as
Rasterization.
29
The graphics objects can be a point, line, circle, arc, rectangle, polygon
and other shapes.
Graphics objects are continuous.
Pixels are always discrete. Each pixel has two states: on and off. 0 is
addressed by pixel off and 1 is addressed by pixel on.
The video display device of the computer has a circuit that converts the
binary values of 0 and 1 into the information of pixel on and off.
Image is represented as collection of pixels.
Pixel:
Pixel is a smallest unit of a digital image or graphics object, which can
be displayed and represented on a display device. A pixel is also called
as a pel or picture element.
A pixel is a basic logical unit in the graphics and the number of pixel
are combined to form a complete image, video or text.
.in
A pixel is represented by a dot or a square on a display screen.
Pixels are the basic building blocks of an image that are generated
using geometric coordinates. es
Depending on the display monitor and graphics card, the size and color
combination of pixel varies and is measured in terms of display
resolution.
ot
un
m
30
The physical coordinates of the pixel on the computer screen based
upon the screen resolution is called as screen coordinates, device
coordinates, or pixel coordinates.
A display device deals with finite, discrete coordinates.
Both x-coordinate and y-coordinate are positive values.
On a display device, the origin (0, 0) is always on the top-left corner of
the screen.
(0,0)
.in
Fig 2. A pixel representation as screen coordinates on a display
device
The values in the x-coordinate increases from left to right and the
values of the y-coordinate increases from top to bottom.
es
A mathematical point (x, y) where x and y are real numbers within an
image area, needs to be scan-converted to a pixel location at (x’, y’).
ot
Each pixel on graphic display does not represent a mathematical point
like P (2.9, 4.22).
This may be done by making x’ and y’ to be the integer part of x and y,
un
to the argument
x’=Floor(x)
y’=Floor(y)
for point P (2.9, 4.22).
x’=Floor (2.9) and y’=Floor (4.22),
(x’, y’) will be (3, 4).
A line has two end points and is defined by an equation y=mx + c, where
m is the slope of the line and c is the y intercept.
Consider the two end points as P1 (x1, y1) and P2 (x2, y2). The equation
of the line is used to determine the x and y coordinates of all the points
that lie between P1 and P2 as shown in Fig 3.
31
The line is drawn on the screen when there are two end points as P1
and P2, and the computer fills it with pixels by the intermediate point
values. This can be done with various line drawing algorithms like
DDA and Bresenham’s.
.in
Fig 3. Line representation on coordinate system
Algorithm:
1. Start
2. Input the two end points of a line as (x1, y1) and (x2, y2)
3. Compute
dx=x2-x1 and dy=y2-y1
.in
4. if abs(dx) > abs(dy)
step = abs(dx)
else
step = abs(dy)
es
5. Compute
xinc = dx/step
ot
yinc = dy/step
6. Initialize x = x1 and y = y1
un
x = x + xinc
y = y + yinc
Plot pixel (ROUND(x), ROUND(y));
}
9. End
Merits:
It is simple.
It is fast to implement.
Demerits:
It involves floating values, which requires rounding off to plot on
screen.
Rounding to integers takes time.
33
3.3.2 Example of DDA Line Drawing Algorithm:
Consider a line PQ with P = (0, 0) and Q = (7, 4). Apply the simple
DDA algorithm and calculate the pixel on this line.
Solution to trace line PQ.
1. Start
2. Inputx1=0, y1=0, x2=7, y=4
3. Compute
dx=x2-x1=7-0=7
dy=y2-y1=4-0=4
4. abs(dx)=7 and abs(dy)=4, so abs(x)>abs(y)
so, step=abs(dx)=7
5. Compute
xinc=dx/step=7/7=1
yinc=dy/step=4/7=0.6
6. Initialize x=0, y=0
.in
7. Plot the pixel (0, 0)
8. For k=1 to 7,
Calculate new values of x and y as x = x + xinc and y = y + yinc.
es
Calculated values shown in Table 1.
9. End
Table 1. Pixel value to compute line PQ
ot
k Plot x y
0, 0 0 0
un
1 1, 1 1 0.6
2 2, 1 2 1.2
3 3, 2 3 1.8
m
4 4, 2 4 2.4
5 5, 3 5 3
6 6, 4 6 3.6
7 7,4 7 4.2
34
Fig 4. Screen plots of line PQ
3.3.3 Bresenham’s Line Drawing Algorithm:
Bresenham’s line drawing algorithm determines the points of an n-
dimensional raster that should be selected in order to form a close
approximation to a straight line between two points.
This algorithm provides the fast and efficient way to represent continuous
.in
line on a discrete plane of a computer display.
The algorithm is suitable for digital plotter and CRT.
es
Algorithm:
1. Start
2. Input the line end points (x1, y1) and (x2, y2)
ot
3. Plot pixel (x1, y1)
4. Compute
un
dx = x2 – x1
dy = y2 – y1
5. Initialize pk = 2*dy – dx
m
Merits:
It generates only integer values, so simple to use.
35
It is faster than DDA line drawing algorithm.
It avoids generation of duplicate points.
Points generated are more accurate.
Demerits:
The resultant line obtained is not smooth.
This algorithm is for basic line drawing. It cannot handle zigzag lines.
.in
4. Compute
dx=x2-x1=7-0=7
dy=y2-y1=4-0=4
es
5. Initialize pk = 2*dy-dx,
pk = 2*4-7=8-7=1
ot
6. For k=0 to 6,
Calculate new values of x and y based upon decision parameter
un
pk
If pk< 0,
increment x, y will be same, plot (xk+1, yk)
m
.in
Fig 5. Screen plots of line AB
es
3.4 SCAN CONVERSION OF CIRCLE
ot
A circle is defined as a set of points that are at the same distance from
center and the distance from center to any point on the circumference of
the circle is called a radius.
un
.in
where x and y coordinates of the circle is given by x=r cosθ and y =r
sinθ, and θ is the current angle.
es
ot
un
m
38
o If f(P) = 0, the given point lies on the circle boundary, then any
pixel can be chosen.
o If f(P) > 0, the given point lies outside the circle boundary, then
the lower pixel is chosen.
Algorithm:
1. Start
2. Declare x, y, r, P, xc, yc where (xc, yc) are center coordinates, x and y
points to be plotted, r is the radius, P is decision factor.
3. Initialize x = 0 and y = r.
4. Compute decision factor P = (5/4) – r.
5. Repeat the steps while x ≤ y
6. Plot (x, y)
7. If P < 0
Set P = P + 2x +3
.in
Else if P ≥ 0
Set P = P + 2(x-y) + 5
y=y–1
es
8. do x = x + 1
9. End
ot
Merits:
un
It is an efficient algorithm.
It is easy to implement.
It is based on simple circle equation x2 + y2 = r2
m
Demerits:
It is a time consuming algorithm.
Sometimes the point of the circle are not accurate.
39
The strategy is to select the pixel, which is at the least distance from
the true circle boundary, and then keep calculating the successive
points on the circle.
The circle follows the symmetric property.
In this algorithm, at any point (x, y) we have two options either to
choose the next pixel at the top i.e. (x+1, y) or at the bottom i.e. (x+1,
y-1).
This is done using decision parameter d where,
If d > 0, (x+1, y-1) will be the next pixel to plot
Else (x+1, y) will be the next pixel
To draw a circle with center (xc, yc) and radius r, it will start from (0, r)
and move in first quadrant till x=y with initial conditions:
d=3-2*r
x=0 and y=r
.in
Algorithm:
1. Start
2. Declare x, y, r, D, xc, yc where (xc, yc) are center coordinates, x and
es
y points to be plotted, r is the radius, D is decision factor.
3. Calculate decision parameter D as: D = 3–(2 * r)
ot
4. Initialize x = 0, y = r
5. Compute next pixels on circle based upon decision parameter
un
While x ≤ y
Plot (x, y)
if D<0, then
m
D = D + 4x + 6
else
D = D + 4(x - y) + 10
y=y–1
end if
x=x+1
6. End
Merits:
It is a simple algorithm.
It is easy to implement.
It is based on simple circle equation x2 + y2 = r2
40
Demerits:
It is not suitable for high graphics and complex images.
Accuracy issues while generating points.
.in
es
ot
un
where,
rxis the x radius
ryis the y radius
For any point (x, y) the next point to be plotted is based on the three
conditions as:
o If f(x, y) < 0, then (x, y) is inside the ellipse
o If f(x, y) > 0, then (x, y) is outside the ellipse
o If f(x, y) = 0, then (x, y) is on the ellipse
There will be two decision parameters based upon the two regions, P1
for region 1 and P2 for region 2.
For region 1, P1 = ry2 + rx2 / 4 – ryrx2
For region 2, P2 = ry2(x + 1 / 2)2 + rx2(y – 1)2 – rx2ry2
41
Algorithm:
1. Start
2. Declare rx , ry , x , y, dx , dy , P1 , P2(rx is x radius, ry = y radius, x =
x coordinate to plotted , y = y coordinate to be plotted, dx , dy , P1=
decision parameter for region 1, P2= decision parameter for region
2)
3. Initialize initial point for region 1 as x = 0, y = ry
4. Calculate P1 = ry2 + rx2 / 4 – ryrx2, dx = 2 ry2x, dy = 2 rx2y
5. Update values of dx and dy after every iteration.
6. Repeat while (dx <dy)
Plot (x, y)
If (P < 0)
x=x+1
P1 = P1 + ry2 (2*x + 3)
.in
Else
x=x+1
y=y–1
es
7. When dx ≥ dy, plot region 2.
8. Calculate P2 = ry2(x + 1 / 2)2 + rx2(y – 1)2 – rx2ry2
ot
9. Repeat till (y > 0)
If (P2 > 0)
un
y=y–1
P2 = P2 – 2*y*rx2 + rx2
Else
m
x=x+1
y=y–1
P2 = P2 + 2*ry2*(2*x) – 2*y*rx2 + rx2
10. End
Merits:
It is easy to implement.
Demerits:
It is a time consuming algorithm.
42
3.5 ALIASING AND PROBLEMS IN ALIASING
.in
raster display device.
3.6 SUMMARY
es
Scan conversion is essential method for plotting discrete pixels.
DDA line drawing algorithm uses floating-point values, which is
ot
converted to integer while plotting pixel. Therefore, it is time
consuming.
un
3.8 REFERENCES
3.9 BIBLIOGRAPHY
.in
P. Shirley and S. Marschner, “Fundamentals of Computer Graphics:
Ray Tracing,” CRC Press. p. 752, 2009.
es
*****
ot
un
m
44
4
SCAN CONVERSION – LINE AND
POLYGON CLIPPING
Unit Structure
4.0 Objectives
4.1 What is clipping?
4.2 Point Clipping
4.3 Line Clipping
4.3.1 Cyrus-Beck Line Clipping Algorithm
4.3.2 Cohen-Sutherland Line Clipping Algorithm
4.3.3 Liang-Barsky Line Clipping Algorithm
4.4 Polygon Clipping
.in
4.4.1 Sutherland-Hodgeman Polygon Clipping
4.5 Summary
4.6 Unit End Exercise
es
4.7 References
4.8 Bibliography
ot
4.0 OBJECTIVES
un
A procedure that identifies the portions of a picture that are either lying
inside or outside of a specified region of space is referred to as clipping
and can be done by using the clipping algorithms.
The region against which an object is to be clipped is called a clip
window as shown in Fig 1.
45
Fig 1. Clipping window
Applications of clipping includes extracting part of a defined scene for
viewing, identifying visible surface in three-dimensional views, object
boundary, displaying a multi-window environment and many more.
The clip window can be a general polygon or any curved boundary.
.in
For viewing transformation, we want to display only those picture parts
that are within the window area.es
Everything outside the window is discarded.
In Fig 2, lines and points within window should be kept (line (P5-P6)
and point P8) and the line lying outside the window should be clipped
(line (P1 to P2), line (P3 to P4) and point P7).
m
.in
es
ot
47
Fig 4. Example of Line Clipping
Examples
In Fig 4, line P1 to P2 lies completely inside the window, so it does not
requires clipping and is saved.
Line P3 to P4 lies completely outside the window, so it does not
requires clipping and is not saved.
Line P5 to P6 lies inside and outside partially, so it requires clipping
and is clipped as shown in After Clipping of Fig 4.
.in
4.3.1 Cyrus-Beck Line Clipping Algorithm:
Cyrus Beck Line clipping algorithm is a parametric line-clipping
algorithm. The term parametric means it is required to find the value of the
es
parameter ‘t’ in the parametric representation of the line segment for the
point at that the segment intersects the clipping edge.
In Fig 5, XY is the line segment, which is intersecting at the two edges
ot
A and B of the convex window.
Apply the parametric equation of the line segment XY as:
un
X + t (Y-X)
where, 0 ≤ t ≤ 1 and t is the linear parameter that continuously changes
the value
m
Therefore,
X + t (Y-X) = (x1, y1) + t ((x2 – x1), (y2 – y1))
= (x, y) be any point on line XY
i. While t = 0, point X is obtained.
ii. While t = 1, point Y is obtained.
iii. While 0 ≤ t ≤ 1, line in between point X and Y is traced.
iv. t = 0.5, finds the midpoint of line XY.
v. While t < 0, trace the line on left hand side of X.
vi. While t > 0, trace the line on right hand side of Y.
The variation in parameter ‘t’ generates line using pointwise method.
The range of parameter values will identify the portion to be clipped
through any convex polygonal region consisting of n-vertices or lattice
points to be identified through the user.
48
Fig 5. Interaction of line XY with convex polygon window
Merits:
It follows parametric approach.
It is fast and efficient.
.in
Demerits: es
The algorithm is can be applicable only for 2D line clipping.
It removes the portion of the lines from a given set of lines and
rectangle area of interest also known as view port, which belongs
outside the area of interest and clip those lines that are partially inside
the area of interest.
m
49
Fig 6 lipping regions
.in
It uses 4-bits to divide the entire region, and the centre region is the
clipping window.
es
These 4 bits represents the TOP, BOTTOM, RIGHT and LEFT of the
region.
ot
In the Fig 6, the TOP and LEFT bit is set to 1 as it is in the TOP-
LEFT corner.
There are three possibilities for the line:
un
o If the line is partially inside the window, find the intersection point
and only draw that portion of the line that is inside the region.
Algorithm:
1. Assign a region code for each endpoint.
2. If both endpoints have a region code 0000 then accept this line.
3. Else perform the logical AND operation for both region codes
3.1 If the result is not 0000, then reject the line.
3.2 Else clipping is required.
3.2.1 Choose an endpoint of the line that is outside the window.
3.2.2 Find the intersection point at the window boundary based on
the region code.
50
3.2.3 Replace the endpoint with the intersection point and update the
region code.
3.2.4 Repeat step 2 until we find a clipped line either trivially
accepted or trivially rejected.
4. Repeat step 1 for other lines.
Merits:
This algorithm follows encoding approach.
Easy to use
Demerits:
This algorithm is applicable to rectangular window only and not to the
other convex shaped window.
Less efficient.
.in
This algorithm is more efficient than Cohen-Sutherland line clipping
algorithm and can be extended to 3-Dimensional clipping.
es
It is a faster parametric line-clipping algorithm.
It is based upon two concepts during clipping:
o It is based upon the parametric equation of the line.
ot
o The intersections between the line and the clip window are
determined by the inequalities describing the range of the clipping
un
window.
The parametric equation is given by:
x = x1 + t * dx
m
y = y1 + t * dy
where, dx = x2 – x1, dy = y2 – y1 and 0 ≤ t ≤ 1
Liang-Barsky line-clipping algorithm uses four inequalities with two
parameters p and q, as defined in the algorithm below.
Algorithm:
1. Start
2. Read the two endpoints of the line as p1 (x1, y1) and p2 (x2, y2).
3. Read the two corners of the clipping window as xwmin, ywmin, xwmax,
ywmax.
4. Calculate the values of the parameters pi and qi for i = 1 to 4 such that:
p1 = -dx, q1 = x1 – xwmin
p2 = dx, q2 = xwmax – x1
51
p3 = -dy, q3 = y1 – ywmin
p4 = dy, q4 = ywmax – y1
5. If pi = 0, then the line is parallel to ith boundary.
If qi< 0, then:
The line is completely outside the boundary so discard the line.
Else:
Check whether line is horizontal or vertical and then check the
line endpoints with the corresponding boundaries.
If the line endpoints lie within the bounded area then:
Use them to draw the line,
Else :
Use boundary coordinates to draw the line.
6. Initialize t1 = 0 and t2 = 1
.in
7. Calculate qi / pi for i = 1 to 4
8. Select values of qi / pi where pi< 0 and assign maximum out of them
as t1.
9.
es
Select values of qi / pi where pi > 0 and assign minimum out of them
as t2.
10. If (t1 < t2)
ot
{
newx1 = x1 + t1 * dx
un
newx2 = x1 + t2 * dx
newy1 = y1 + t1 * dy
newy2 = y1 + t2 * dy
m
Merits:
It uses the parametric approach.
It is more efficient than any other line-clipping algorithms.
52
It clips the four edges in the boundary of the clip rectangle.
The clip boundary determines the visible and invisible regions of
polygon clipping and it is categorized in four ways:
o If visible region is fully inside the clip window, endpoints are saved.
o If visible region is fully outside the clip window, no endpoints are
saved.
o If visible exits the clip window, save the intersection.
o If the visible enters the clip window, save the endpoint and the
intersection.
Each edge of the polygon must be tested against each edge of the clip
rectangle, new edges must be added and existing edges must be
discarded, retained or divided.
There are two types of polygons: (i) Concave (ii) Convex.
(i) Concave polygon:
It does not have any part of its diagonal in its exterior and at least one
.in
angle should be greater than 180o.
(ii) Convex polygon: es
It has at least one part of diagonal in its exterior and all angles should be
less than 180o.
ot
un
m
53
It works in order and makes sure that all edges of clipping polygon are
taken sequentially.
At each step new sequence of vertices are generated and passed to next
window boundary for clipping.
To clip the vertices following cases are considered:
Case 1- Both vertices are inside:
Only the second vertex is added to the output list.
Case 2 - First vertex is outside while second one is inside:
Both the point of intersection of the edge with the clip boundary and
the second vertex are added to the output list.
Case 3 - First vertex is inside while second one is outside:
Only the point of intersection of the edge with the clip boundary is
added to the output list.
Case 4 - Both vertices are outside:
No vertices are added to the output list.
.in
es
ot
Example:
Fig. 9 depicts the following cases:
a. Clipping against the left side of the clip window.
b. Clipping against the top side of the clip window.
c. Clipping against the right side of the clip window.
d. Clipping against the bottom side of the clip window.
54
Sutherland-Hodgeman comprises of two key processes in the algorithm:
o Perform inside-outside test to determine the visibility of a point or
vertex.
o Determine the intersection of the polygon edge and the clipping plane.
Method to determine the visibility of a vertex or a point.
Let V be the vertex and AB the window boundary.
Three points A, B and V define Vector AB and AV line in the plane.
If this plane is considered in the xy plane, then the vector cross product
AV x AB has a z component given by:
(xv-xA)(yB-yA)-(yv-yA)(xB-xA)
The sign of the z-component decides the position of point V with
respect to window boundary.
It can be as follows:
o z>0: point is on the right side of window boundary
.in
o z=0: point lies on the window edge
o z<0: point is on the left side of window boundary
es
Algorithm:
4. Perform steps 2 and 3 for the remaining edges of the clipping polygon
each time, the resulting list of polygon vertices are successively passed
to process the next edge of the clipping polygon.
5. Finish.
Merits:
Demerits:
55
4.5 SUMMARY
.in
3. Write the algorithm for Sutherland-Hodgeman polygon clipping.
4. Explain the process for Cyrus-Beck line-clipping algorithm.
es
5. Write the algorithm for Liang-Barsky line-clipping algorithm.
4.7 REFERENCES
ot
4.8 BIBLIOGRAPHY
m
*****
56
UNIT II
5
TWO DIMENSIONAL
TRANSFORMATIONS
Unit Structure
5.0 Objective
5.1 Introduction
5.2 Transformations and Matrices
5.2.1 Transformation
5.2.2 Matrices
5.3 Transformation conventions
.in
5.3.1 2D coordinate system
5.3.2 3D coordinate system
5.4 2D transformations
5.4.1 Translation
es
5.4.2 Rotation
5.4.3 Scaling
ot
5.4.4 Shearing
5.4.5 Reflection
un
5.0 OBJECTIVE
5.1 INTRODUCTION
To convert the real world object into computer we need to understand the
coordinate system. The real world objects are represented in computer
with the different angles and different perspective with the help of
different coordinate system. The concept of transformation is used to
implement this process. Transformation takes place in 2 ways that are 2D
transformation and 3D transformation.
In this chapter we will see the 2D coordinate system of converting real life
object to computer.
.in
5.2.1 Transformation:
Creation of graphs and images in computer are not sufficient in computer
es
graphics. In real world object are moved from one position to another or
its changing its shape or orientation and it can be seen from different
angles and different perspective.
ot
The process of changing size, shape, position and orientation of object is
called transformation.
un
Fig. 5.2.1
2. Coordinate transformation: y
In this type of transformation the
object is y’ appeared with
the modified points on the screen
after performing some non-singular
x’ operation like translation,
rotation, scaling etc.
x
fig. 5.2.2
58
5.2.2 Matrices:
1 0 0
Homogeneous Matrix representation of 3 × 3 matrix 0 1 0
0 0 1
.in
5.3 TRANSFORMATION CONVENTIONS
To draw an object onto screen, computer need the system that is called as
conventions of transformation. This can be done with 2 types such as 2D
es
coordinate system and 3D coordinate system.
For 2D image we use 2D coordinate system as convention for
transformation whereas for 3D image we use 3D coordinate system as
ot
5.3.1 2D COORDINATESYSTEM:
This 2D coordinate system consists of two coordinates x and y i.e. x plane
and y plane. Its direction is along with the x and y axis with reference to
an origin. With the help of this system the real word object can be draw on
m
Y
Z
Fig 5.3.1
59
5.3.2 3D coordinate system:
This 3D coordinate system consists of three coordinates x, y and z .i.e. x
plane, y plane and z plane.
Its direction is along with the x, y and z axis with reference to an origin.
With the help of this system the real word object can be drawn on screen
with lines, circle, polygon etc.
.in
Fig 5.3.2
origin(0, 0, 0)
Y
Z
m
Fig 5.3.3
Left hand coordinate system:
60
In Right hand coordinate system x and y coordinates are positive and
z coordinate is negative so the object will transform in both the
direction.
5.4 2D TRANSFORMATIONS
1. Translation Denoted by T
2. Rotation Denoted by R
Basic 2D 3. Scaling Denoted by S
transformation 4. Shearing Denoted by Sh
5. Reflection Denoted by RE
5.4.1 Translation:
Changing the position of an object or shifting of an object is called 2D
translation.
.in
To achieve translation an object should shift in x and y direction.
We can translate a two dimensional figure by adding translation
es
factor tx and ty to the original points x and y
The following matrix shows translation, P=P+T
𝑥 𝑥 tx
ot
𝑃 = 𝑃 𝑦 + 𝑇 ty
𝑦
un
C 5 1 1 2 2 1
𝐴 3 5 0 3 5
𝑃 𝐵 = 𝑃 2 2 0 = 2 2
C 7 3 2 7 3
61
Fig 5.4.1 Translation
5.4.2 Rotation:
Changing the position of an object with rotation angle along with xy
plane is called 2D rotation.
To achieve rotation an object should move in x and y direction with
.in
the specified angle .
We can rotate a two dimensional figure by multiplying rotation
factor rx and ry to the original points x and y
es
The following matrix shows rotation, P=P+R
𝑥 𝑥 cos −𝑠𝑖𝑛
Clockwise rotation 𝑃 =𝑃 𝑦 . 𝑅
ot
𝑦 sin 𝑐𝑜𝑠
𝑥 𝑥 cos 𝑠𝑖𝑛
un
62
Fig 5.4.2 Rotation
5.4.3 Scaling:
Changing the size of an object is called 2D scaling.
To achieve scaling an object should change the size of object in x and
y direction.
.in
We can scale a two dimensional figure by multiplying scaling factor
sx and sy to the original points x and y
The following matrix shows scaling, P=P+S
es
𝑥 𝑥 𝐬𝐱 𝟎
Scaling in x and y direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆
0 𝐬𝐲
Scaling in x direction
ot
𝑥 𝑥 𝐬𝐱 𝟎
𝑃 𝑦 = 𝑃 𝑦 . 𝑆
un
0 𝟏
𝑥 𝑥 𝟏 𝟎
Scaling in y direction 𝑃 = 𝑃 𝑦 .𝑆
𝑦 0 𝐬𝐲
m
𝐴 2 5 0 2 0 0 4 10 0
𝑃 𝐵 = 𝑃 2 1 0 . 𝑅 0 2 0 = 4 2 0 by substituting original
C 5 1 1 0 0 1 10 2 1
value of point A,B,C and scaling factor x=2, y=2
A=(4, 10) B=(-4, 12) C=(-10, 2)
63
Fig 5.4.3 Scaling
5.4.4 Shearing:
A shear is something that pushes the object sideway and make a thing
little bit tilled.
To achieve shearing an object should tilled(slant) with respect to x and
.in
y direction.
We can shear a two dimensional figure by multiplying shearing factor
shx and shy to the original points x and y
es
The following matrix shows shearing, P=P+Sh
𝑥 𝑥 𝟎 𝐬𝐡𝐲
𝑃 = 𝑃 𝑦 .𝑆
𝑦 𝐬𝐡𝐱 0
ot
𝑥 𝑥 𝟏 𝟎
un
𝑥 𝑥 𝟏 𝐬𝐡𝐲
m
𝑥 𝑥 𝟏 𝟎
Solution: Shearing in x direction 𝑃 = 𝑃 𝑦 .𝑆
𝑦 Shx 𝟏
𝐴 2 5 0 1 0 0 12 5 0
𝑃 𝐵 = 𝑃 2 1 0 . 𝑅 2 1 0 = 4 1 0 by substituting
C 5 1 1 0 0 1 6 1 1
64
Fig 5.4.4.1 Shearing with X axis
𝑥 𝑥 𝟏 𝐬𝐡𝐲
Shearing in y direction 𝑃 = 𝑃 𝑦 .𝑆
𝑦 𝟎 1
.in
𝐴 2 5 0 1 2 0 2 9 0
𝑃 𝐵 = 𝑃 2 1 0 . 𝑅 0 1 0 = 2 5 0 by substituting original
C 5 1 1 0 0 1 5 11 1
es
value of point A,B,C and shearing factor y=2
ot
un
m
5.4.5 Reflection:
65
The following matrix shows reflection, P=P+RExy
𝑥 𝑥 −𝟏 𝟎
Reflection 𝑤𝑖𝑡h 𝑥𝑦 𝑎𝑥𝑖𝑠 𝑃 = 𝑃 𝑦 . 𝑅𝐸x
𝑦 𝟎 −𝟏
𝑥 𝑥 𝟏 𝟎
Reflection 𝑤𝑖𝑡h 𝑥 𝑎𝑥𝑖𝑠 𝑃 = 𝑃 𝑦 . 𝑅𝐸x
𝑦 𝟎 −𝟏
𝑥 𝑥 −𝟏 𝟎
𝑅𝑒𝑓𝑙𝑒𝑐𝑡𝑖𝑜𝑛 𝑤𝑖𝑡h 𝑦 𝑎𝑥𝑖𝑠 𝑃 = 𝑃 𝑦 . 𝑅𝐸y
𝑦 𝟎 𝟏
.in
substituting original value of point A,B,C and scaling matrix
es
ot
un
m
Some time an object may require more than one transformation to get
desired output, we need to transform an object at several times with
different transformation like rotation, scaling, translation, shearing,
reflection such a group of transformation is called combined
transformation.
.in
The reflection through x axis matrix
1 0
[REx]=
0−1
es
The combined transformation matrix is
𝟎 𝟏 1 0 0 −1
ot
[R].[REx]= . =.
−𝟏 0 0−1 −1 0
un
𝐴 −2 − 5
[P]= 𝐵 = −2 − 1
𝐶 −5 − 1
𝑋 𝑛𝑒𝑤 1 0 𝑇𝑥 𝑋 𝑜𝑙𝑑
Translation : 𝑦 𝑛𝑒𝑤 = 0 1 𝑇𝑦 . 𝑌 𝑜𝑙𝑑
1 0 0 1 1
𝑋 𝑛𝑒𝑤 1 0 0 𝑋 𝑜𝑙𝑑
Shearing in x direction: 𝑦 𝑛𝑒𝑤 = 𝑆𝐻𝑥 1 0 . 𝑌 𝑜𝑙𝑑
1 0 0 1 1
𝑋 𝑛𝑒𝑤 1 0 0 𝑋 𝑜𝑙𝑑
Reflection in x direction : 𝑦 𝑛𝑒𝑤 = 0 − 1 0 . 𝑌 𝑜𝑙𝑑
1 0 0 1 1
𝑋 𝑛𝑒𝑤 −1 0 0 𝑋 𝑜𝑙𝑑
.in
Reflection in y direction : 𝑦 𝑛𝑒𝑤 = 0 1 0 . 𝑌 𝑜𝑙𝑑
1 0 0 1
es 1
transformation on points.
m
68
.in
es
ot
un
m
69
are same but the rest of the coordinates are changes according to the unit
vector , hence the transformation is applied on all point except origin
point.
The general form of transformation matrix is [p]= [p] [T]
𝑎 𝑏
[x y]= [x y] .
𝑐 𝑑
.in
Fig 5.8.1 Unit square transformation
es
5.9 SOLID BODY TRANSFORMATIONS
Dot Product of vector: they can be multiplied using dot product of matrix
is written using central dot present between these two vector.
70
Cross Product of vector: the cross product of two vector is an another
vector which is right angled to both the vector like a x b
1 0 0
Homogeneous matrix for translation about an origin 0 1 0
−𝑚 −𝑛 1
.in
Steps to achieve Rotation about arbitrary points
1. The points of translation about the origin m= -m and n= -n
es
2. Perform specified rotation.
3. Translate result back to original points (center of origin)
ot
4.
1 0 0 𝑐𝑜𝑠 𝑠𝑖𝑛 0 1 0 0
[𝑥, 𝑦, 𝑧] = 0 1 0 −𝑠𝑖𝑛 𝑐𝑜𝑠 0 0 1 0
un
−𝑚 −𝑛 1 0 0 1 𝑚 𝑛 1
about 90 counter clockwise about its origin using the matrix of rotation.
1 0 0
−1 0 0
0 0 1
71
1 0 0 0 1 0 1 0 0
[𝑥, 𝑦, 𝑧] = 0 1 0 −1 0 0 0 1 0
−5 −6 1 0 0 1 5 6 1
0 1 0 1 0 0
[𝑥, 𝑦, 𝑧] = −1 0 0 0 1 0
6 −5 1 5 6 1
1 0 0
[𝑥, 𝑦, 𝑧] = 0 1 0
11 6 1
.in
We know that when x and y both the coordinates are changed, the line is
reflected and passes through the origin. But sometimes reflection of an
object through a line which does not pass through an origin id required.
es
Step 1: Translation: translate the line and the object so that the line
passes through origin.[T]
ot
Step 2: Rotation: Rotate the line and the object the origin until the line is
coinciding with one of the coordinate axis. [R]
un
Step 4: Inverse rotation: apply inverse rotation about the origin. [R]-1
m
.in
Window to viewport mapping:
A point at position (xw, yw) in the window is mapped into new position
(xv , yv) in associated view port.
es
ot
un
m
5.13 SUMMARY
.in
7. Explain in brief solid body transformation.
8. Write a short note on unit square transformation.
es
9. Explain reflection through an arbitrary line.
10. Explain the concept of transformation of points.
ot
5.15 REFERENCES
un
*****
74
UNIT II
6
THREE DIMENSIONAL
TRANSFORMATIONS
Unit Structure
6.0 Objective
6.1 Introduction
6.2 Transformations and Matrices
6.2.1 Transformation
6.2.2 Matrices
.in
6.3 Transformation conventions
6.3.1 3D coordinate system
6.4 3D transformations es
6.4.1 Translation
6.4.2 Rotation
6.4.3 Scaling
ot
6.4.4 Shearing
6.4.5 Reflection
6.5 Multiple Transformations
un
6.5.1 Method
6.6 Homogeneous Coordinates and Matrix Representation of 3D
Transformations
m
75
6.0 OBJECTIVE
This chapter will able you to understand the following concept
3D Transformations and Matrices with its representation
Types of transformation such as scaling, reflection, translation,
shearing and rotation.
Ways of Transformation about an Arbitrary plane and arbitrary axis.
Types of projection such as Orthographic, Axonometric, Oblique
Projections.
Camera model and its perspective geometry
6.1 INTRODUCTION
When we want to convert the real life object into computer we
need to understand the coordinate system. The real life objects represent in
computer with the different angles and different perspective with the help
of different coordinate system and here the concept of transformation
.in
exist. Transformation takes place in x axis, y axis, z axis in 3D
transformation. In this chapter we will see the 3D coordinate system of
converting real life object to computer. The transformation which takes
place on 3D plane or 3D space is called as 3D transformations.
es
6.2 TRANSFORMATIONS AND MATRICES
ot
6.2.1 Transformation:
Creation of graphs and images in computer are not sufficient in
un
computer graphics. In real world objects are moved from one position to
another or its changing its shape or orientation and it can be seen from
different angles and different perspective.
m
76
1. Coordinate transformation:
In this type of transformation the object y’ appears with the
modified points on the screen after performing some non-singular x’
operation like translation, rotation, scaling etc.
6.2.2 Matrices:
.in
used.
It provides the technique to represent the real world object into
computer system.
es
It also provides a way to calculate different type of geometric function
on the real life object to show on the screen.
With help of matrices various operation like translation scaling etc
ot
can be done on the object
1 4 3
General Matrix representation of 3 × 3 matrix 5 9 8
un
8 2 4
1 0 0
Homogeneous Matrix representation of 3 × 3 matrix 0 1 0
m
0 0 1
fig 6.3.1
.in
In Right hand coordinate system all coordinates are positive so the
object will transform x in positive direction only.
es
ot
un
fig 6.3.2
m
Fig 6.3.3
In Right hand coordinate system x and y coordinates are positive and
z coordinate is negative so the object will transform in both the
direction.
78
6.4 3D TRANSFORMATIONS
1. Translation Denoted by T
2. Rotation Denoted by R
Basic 3D transformation 3. Scaling Denoted by S
4. Shearing Denoted by Sh
5. Reflection Denoted by RE`
6.4.1 Translation
Changing the position of an object or shifting of an object is called 3D
translation.
To achieve translation, an object should shift in the x, y, and z
direction.
We can translate a two dimensional figure by adding translation factor
.in
tx, ty and tz to the original points x, y and z.
The following matrix shows translation, P=P+T
es
𝑥 𝑥 tx
𝑃 𝑦 = 𝑃 𝑦 + 𝑇 ty
z 𝑧 tz
ot
𝑃 𝐵 = 𝑃 [𝑎, 𝑏, 𝑐, 1] + 𝑇
0 0 0 1
C
𝑙 𝑚 𝑛 1
m
79
.in
es
Fig 6.4.1 3D Translation
6.4.2 Rotation:
ot
Changing the position of an object with rotation angle along with xyz
plane is called 3D rotation.
To achieve rotation an object should move in x and y direction with
un
𝑥 𝑥 1 0 0
Rotation 𝑎𝑏𝑜𝑢𝑡 𝑥 𝑎𝑥𝑖𝑠 𝑃 𝑦 = 𝑃 𝑦 . 𝑅 0 𝑐𝑜𝑠 𝑠𝑖𝑛
z 𝑧 0 − 𝑠𝑖𝑛 𝑐𝑜𝑠
𝑥 𝑥 𝑐𝑜𝑠 0 – 𝑠𝑖𝑛
Rotation 𝑎𝑏𝑜𝑢𝑡 𝑦 𝑎𝑥𝑖𝑠 𝑃 𝑦 = 𝑃 𝑦 . 𝑅 0 1 0
z 𝑧 𝑠𝑖𝑛 0 𝑐𝑜𝑠
𝑥 𝑥 𝑐𝑜𝑠 𝑠𝑖𝑛 0
Rotation 𝑎𝑏𝑜𝑢𝑡 𝑧 𝑎𝑥𝑖𝑠 𝑃 𝑦 = 𝑃 𝑦 . 𝑅 −𝑠𝑖𝑛 𝑐𝑜𝑠 0
z 𝑧 0 0 1
80
Fig 6.4.2 3D Rotation
.in
6.4.3 Scaling:
Changing the size of an object is called 3D scaling.
es
To achieve scaling an object should change the size of object in x, y
and z direction.
We can scale a two dimensional figure by multiplying scaling factor
ot
sx , sy and sz to the original points x, y and z
There are two types of scaling
un
𝑥 𝑥 𝑆𝑥 0 0
Scaling x, y and z direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆 0 𝑆𝑦 0
z 𝑧 0 0 𝑆𝑧
𝑥 𝑥 1 0 0
Uniform Scaling x, y and z direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆 0 1 0
z 𝑧 0 0 1
𝑥 𝑥 1 0 0
Non-Uniform Scaling x, y and z direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆 0 2 0
z 𝑧 0 0 3
81
.in
Fig 6.4.3 3D Scaling
es
6.4.4 Shearing:
ot
A shear is something that pushes the object sideway and make a thing
little bit tilled.
To achieve shearing an object should tilled(slant) with respect to x, y
un
and z direction.
We can shear a two dimensional figure by multiplying shearing
factor shx , shy and shz to the original points x, y and z.
m
1 𝑎 𝑏 0
𝑥 𝑥
𝑐 1 𝑑 0
Shearing x, y and z direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆
𝑧 𝑒 𝑓 1 0
z
0 0 0 1
𝑥 1 0 00
𝑥
0 1 0 0
Shearing in xy direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆
𝑧 𝑎 𝑏 1 0
z
00 0 1
𝑥 1 𝑎 𝑏 0
𝑥
0 1 0 0
Shearing in yz direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆
𝑧 0 0 1 0
z
0 0 0 1
82
𝑥 1 0 0 0
𝑥
𝑎 1 𝑏 0
Shearing in xz direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆
𝑧 0 0 1 0
z
0 0 0 1
.in
Fig 6.4.4 3D Shearing
es
6.4.5 Reflection:
Creating mirror image of an object is called 3D reflection.
ot
To achieve reflection, an object should appear in the form of mirror
object in x, y and z direction.
We can reflect a two dimensional figure by multiplying reflection
un
𝑥 1 0 0 0
𝑥
0 1 0 0
Reflection xy direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆
𝑧 0 0 −1 0
z
0 0 0 1
𝑥 1 0 0 0
𝑥
0 −1 0 0
Reflection xz direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆
𝑧 0 0 1 0
z
0 0 0 1
𝑥 −1 0 0 0
𝑥
0 1 0 0
Reflection yz direction 𝑃 𝑦 = 𝑃 𝑦 . 𝑆
𝑧 0 0 1 0
z
0 0 0 1
83
−1 0 0 0
𝑥 𝑥
0 −1 0 0
Reflection about origin p 𝑦 = 𝑃 𝑦 . 𝑆
𝑧 0 0 −1 0
𝑧
0 0 0 1
.in
6.5 MULTIPLE TRANSFORMATION
84
The reflection through x axis matrix
1 0
[REx]=
0−1
The combined transformation matrix is
0 1 1 0 0 −1
[R].[REx]= . =.
−1 0 0 − 1 −1 0
𝐴 25
0 −1
[P]= 𝐵 . ([R]. [REx])= 2 1 .
−1 0
𝐶 51
𝐴 −2 − 5
[P]= 𝐵 = −2 − 1
𝐶 −5 − 1
.in
REPRESENTATION OF 3D TRANSFORMATIONS
0 0 1 0
𝑙 𝑚 𝑛 1
1 0 0
m
cos 0 −sin
Rotation: [Ry] = 0 1 0
sin 0 cos
cos sin 0
Rotation: [Rz] = −sin cos 0
0 0 1
𝑆𝑥 0 0
Scaling: [𝑆] = 0 𝑆𝑦 0
0 0 𝑆𝑧
85
1 0 0 0
0 1 0 0
Shearing: [𝑆h] =
0 0 1 0
0 0 0 1
−1 0 0 0
0 −1 0 0
Reflection: [𝑅𝐸. 𝑥] =
0 0 −1 0
0 0 0 1
.in
Steps to achieve Rotation about an arbitrary Axis in space
1. The origin point which is to be translate p=[ax, by, cz] trough all 3 axis
es
1 0 0 0
0 1 0 0
[T]=
ot
0 0 1 0
−ax − by − cz 1
un
cos 0 sin
[Ry] = 0 1 0
−sin 0 cos
cos sin 0
3. Rotation about an angle in z axis [Rz] = −sin cos 0
0 0 1
4. Apply Inverse rotation on step 2
We know that when x and y both the coordinates are changed; the line is
reflected and passes through the origin. But sometimes reflection of an
object through a line which does not pass through an origin id required.
Step 1: Translation: translate the point P which is lies on reflection plane.
[T]
Step 2: Rotation: Rotate the point about x and y axis. [R]
Step 3: Reflection: reflect an object through z axis or xy plane with z=0
[R]
Step 4: Inverse rotation: apply inverse rotation about 2 axes which state in
step 2. [R]-1
.in
Step 5: Inverse translation: perform inverse translation of step 1 to get
back to original location. [T]-1
87
A1 A2
B1 B2
C1 C2
When human eyes see far away things they are looking smaller as
they come closer they are looking bigger to eyes this type of viewing is
called perspective. This technique need to convert an object from one form
to another and that is known as projection. Perspective projection will
.in
convert 3D image into 2D as human eyes does. The projection transforms
shape of object into another form as they appear close to eyes. Perspective
transformation represented in homogeneous coordinate system is as
1 0 0 0
es
0 1 0 0
follows in 4 X 4 matrix [PT]= where r is any non zero
0 0 1 0
0 0 0 1
ot
value
There are three types of perspective transformation
un
88
Fig 6.10.1 Single point perspective transformation
.in
1. Two point perspective transformation: If two term (either x, y, z) in
fourth column of matrix transformation is non zero we will get single
es
point perspective transformation. In this type object can be seen in two
directions.
ot
un
m
89
.in
Fig 6.10.3 Three point perspective transformation
es
6.11 TECHNIQUES FOR GENERATING PERSPECTIVE
VIEWS
ot
2. Rotation
90
Types of axonometric projection are
1. Isometric projection
2. Dimetric projection
3. Trimetric Projection
.in
es
ot
other two. This projection says that the view created through principal
axis are represented the angle of object. Since two axis are same the line
which are drawn along axis are also same.
91
Fig 6.12.2 Dimetric Projection
.in
not equally distanced. All three axis are unequally distanced as well as the
angles created by these lines are also unequal.
es
ot
un
m
92
Fig 6.13.1 Oblique projection
.in
coordinates are positively project down and to the left on the view plane.
Z co-ordinate negatively projected up and right face. The angle of z axis
can be any of the direction but the distance of the points shifted in a z
es
direction must be equal to three dimensional view plane z distances that is
called as Cavalier projection.
ot
un
m
93
Fig 6.13.3 Cabinet Projection
.in
the projectors are parallel to each other and perpendicular to the plane of
projection. It represents 3 dimensional objects in 2 dimensions. A square
or rectangular viewing volume is formed for this projection by near, far,
right, left, top and bottom clipping planes. Single orthographic projection
es
does not provide sufficient information to reconstruct the shape of an
image, therefore, multiple orthographic projection displays a single face of
3D object i.e. viewer can only see the one side of an object at a time.
ot
are parallel to each other and originate from any point on object.
m
.in
es
ot
un
.in
es
Fig 6.15.3 Three point perspective vanishing point
convert the viewing plane coordinate into 2D coordinate system so that the
object will look like same as it seen in the real world. There are two types
of projection.
1. Parallel projection
m
2. Perspective projection
Parallel projection:
In this type of projection parallel line of object transforms in parallel lines
only. a parallel projection is also called as relative projection as it
preserves relative plane along with the parallel lines. Accurate view of
object from multiple sides is view in this projection. This projection will
not preserve realistic representation.
96
Fig 6.16.1 Parallel projection
Perspective projection:
Perspective projection transforms object positions to the view plane while
converging to center point of projection. Perspective projection produces
realistic views but does not preserve relative proportions. Projections of
distant objects are smaller than the projections of object of the same size
that are closer to the projection plane.
.in
es
ot
un
View Volume:
m
Only those objects are seen which are within the window volume.
The objects which are beyond the view volume it will be not seen. In view
volume the perspective effects depends on the positioning of the center
point of projection. If it is close to the view plane then the object look like
closer and larger but when it is longer to the view plane it is look like
smaller and far away from the view plane hence the size of the object
affected by the relative position of the object. View volume is bounded by
6 planes left, right, top, bottom, front and back side.
97
6.17 SUMMARY
.in
6.18 UNIT END EXERCISE
1.
es
What is 3D transformation? Explain its types.
2. Explain conventions 3D transformation in detail.
3. Explain homogeneous coordinate system in 3D detail.
ot
6.19 REFERENCES
*****
98
UNIT III
7
VIEWING IN 3D
Viewing in 3D:- Stages in 3D viewing, Canonical View Volume (CVV),
Specifying an Arbitrary 3D View, Examples of 3D Viewing, The
Mathematics of Planar Geometric Projections, Combined transformation
matrices for projections and viewing, Coordinate Systems and matrices,
camera model and viewing pyramid.
Unit Structure
7.0 Objectives
7.1 Stages in 3D viewing
7.2 Canonical View Volume
7.3 Specifying an Arbitrary 3D View
.in
7.4 Examples of 3D Viewing
7.5 The Mathematics of Planar Geometric Projections
7.6 Combined transformation matrices for projections and viewing
es
7.7 Coordinate Systems and matrices
7.8 Camera model and viewing pyramid
7.9 Summary
ot
7.0 OBJECTIVES
m
99
Modelling transformation
Viewing transformation
Projection transformation
Normalization transformation and Clipping
View Port transformation
.in
1. Modelling Transformation:
Modelling Transformation can be obtained with the help of 3D
transformations.
es
It transforms the object (Modelling) coordinates (MC) into 3D world
coordinate system, will generate output as 3D world coordinates
ot
(WC). (3D to 3D).
2. Viewing Transformation:
un
3. Projection Transformation:
Projection operation converts the viewing-coordinate description
(3D) to coordinate positions on the projection plane (2D).
It projects the coordinates onto projection plane as Projection
Coordinates (PC). (3D to 2D).
100
5. Viewport Transformation:
It maps the coordinate positions on the projection plane of the output
device.
It transforms Normalized Coordinates into viewport is 2D Device
coordinates (DC) or display.
Example of CVV:
.in
CVV is related to Projection transformation i.e. Orthographic (parallel)
projection and Perspective projection as shown in the below figure:
es
ot
un
m
Fig: 7.3
101
Note that n and f are typically given as distance which is always positive
and because we are looking towards the –z direction, the actual
coordinates become –n and –f.
Also note the changes in the z-direction. This makes objects further away
from the camera to have larger z values. In other words, CVV is a left-
handed coordinate system.
We need to map the box with corners at (l, b, -n) and (r, t, -f) to the (-1, -1,
-1) and (1, 1, 1) of CVV.
This is accomplished by the following matrix,
2 𝑟+𝑙
⎡ 0 0 − ⎤
⎢𝑟 − 𝑙 𝑟−𝑙⎥
⎢ 2 𝑡 + 𝑏⎥
=⎢ 0 0 −
𝑀 𝑡−𝑏 𝑡 − 𝑏⎥
⎢ 2 𝑓 + 𝑛⎥
0 0 − −
⎢ 𝑓−𝑛 𝑓 − 𝑛⎥
⎣ 0 1 ⎦
.in
0 0
plane.
The procedure to project from 3D to 2D given a finite view volume,
will be as follows:
Apply a normalizing transform to get to the canonical view
volume.
Clip against the canonical view volume
Project onto the view plane
Transform into viewport
To specify an arbitrary view, we should be able to place the view
plane anywhere in 3D. Specify the direction of the plane and its
position in the world reference coordinate system (WRC).
A common way to specify an arbitrary view is to specify the
following:
102
A View Reference Point (VRP) which is to point on the plane.
A View Plane Normal (VPN) which is the normal vector to the
plane.
A View Up Vector (VUP) which is a vector from which we
determine which way is up.
Window on View plane:
PRP: Projection Reference Point
CW: Center of Window
COP: Center of Projection (Perspective Projection)
DOP: Direction of Projection (Parallel Projection)
PRP and CW are used to determine COP and DOP
Perspective: COP = PRP
Parallel: DOP = PRP – CW
Coordinate Systems:
.in
WC: World Coordinates - normal, 3-space (x, y, z)
VRC: Viewing Reference Coordinates - defined by VRP, VPN
and VUP
es
ot
un
m
Figure 7.4: The view plane is defined by VPN and VRP, the v axis is
defined by the projection of VUP along VPN onto the view plane. The u
axis forms the right-handed VRC system with VPN and v.
.in
es
ot
un
m
Fig: 7.5 (a) The default viewing specification: VRP is at the origin, VUP is
the y axis, and VPN is the z-axis. This makes the VRC system of u, v and n
coincide with x, y, z world-coordinate system. The window extends from 0
to 1 along u and v, and PRP is at (0.5, 0.5, and 1.0). (b) Default parallel
projection view volume. (c) View volume if default projection were
perspective.
The corresponding values for default view volume is given by,
104
PRP(VRC) (0.5,0.5,1.0)
Window(VRC) (0,1,0,1)
Projection type parallel
.in
es
ot
Fig: 7.6 Stick models useful for understanding 3D Viewing. (a) House
and World-coordinate system. (b) House and VRC system
7.4.1 Perspective Projections
un
To obtain the front one-point perspective view of the house shown in Fig.
7.7 we position the center of projection (which can be thought of as the
position of the viewer) at x = 8, y = 6, and = 84. The x value is selected to
m
105
Although the image in Fig: 7.7 is indeed a perspective projection of the
house, it is very small and is not centered on the view surface. We would
prefer a more centered projection of the house that more nearly spans the
entire view surface, as in Fig: 7.8 we can produce this effect more easily if
the view plane and the front plane of the house coincide.
.in
Now, because the front of the house extends from 0 to 16 in both x and y, a
window extending from 1 to 17 in x and y produces reasonable results.
We place the view plane on the front face of the house by placing the VRP
es
anywhere in the: = 54 plane; (0, 0, 54), the lower-left front corner of the
house, is fine. For the center of projection to be the same as in Fig: 7.7, the
PRP, which is in the VRC system, needs to be at (8, 6, 30). Fig: 7.9 shows
ot
this new arrangement of the VRC, VRP and PRP,
un
m
Fig: 7.7 One-point perspective projection of the house & Fig: 7.8 Centered
perspective projection of a house
106
Fig: 7.9 The viewing situation for the figure 7.8
which corresponds to the following set of viewing parameters:
.in
es
ot
This same result can be obtained in many other ways. For instance, with the
un
VRP at (8. 6, 54), as in Fig. 7.10, the center of projection, given by the PRP,
becomes (0, 0, 30). The window must also be changed, because its definition
is based on the VRC system, the origin of which is the VRP. The appropriate
m
107
Fig: 7.10 An alternative viewing situation for fig. 7.8.
.in
es
ot
Now, if the corner of the house at (16, 0, 54) is chosen as the VRP, then
this center of projection is at (20, 25, 20) relative to it. With the view plane
coincident with the front of the house (the z = 54 plane), a window
ranging from -20 to 20 in u and from -5 to 35 in v is certainly large
108
enough to contain the projection. Hence, we can specify the view of Fig.
7.13 with the viewing parameters:
This view is similar to, but clearly is not the same as, that in Fig. 7.11
as is a two-point perspective projection, whereas Fig. 7.13 is a one-
point perspective. It is apparent that simply moving the center of
projection is not sufficient to produce Fig. 7.11. In fact, we need to
reorient the view plane such that it cuts both the x and z axes, by setting
VPN to (1, 0, 1).
.in
es
ot
Fig: 7.13 Perspective projection of a house from (36, 25, 74) with VPN
un
109
Thus, the viewing parameters for Fig. 7.11 are as follows:
Figure 7.11 shows the view plane established with this VPN. There are two
ways to choose a window that completely surrounds the projection, as does
the window in Fig. 7.11. One can estimate the size of the projection of the
house onto the view plane as shown in Fig. 7.15, to calculate the
intersections of projectors.
.in
es
ot
un
window size
110
with the view plane. A better alternative, however, is to allow the window
bounds to be variables in a program that are determined interactively via a
valuator or locator device. Figure 7.16 is obtained from the same projection
as is Fig. 7.11 but the window has a different orientation.
Fig 7.16 has exactly the same viewing parameters as does Fig. 7.11, except
that VUP has been rotated away from the y axis by about 10°.
Another way to specify viewing parameters for perspective projections is
suggested in Fig. 7.17. This figure is showed after the way a photographer
might reason about placing a camera.
Six parameters are needed: the center of projection, which is the camera
position; the center of attention, which is a point at which the camera is meant
(the VPN is the vector from the center of attention to the center of projection);
VUP, the up vector, D, the distance from the center of projection to the
projection plane; W, the width of the window on the projection plane, and H,
the height of the window on the projection plane.
The center of attention need not be on the view plane. In this model, the VPN
is always pointed directly at the center of projection, and the view volume is
.in
symmetrical about its center line.
es
ot
un
from the center of projection to the projection plane, and the height
and width of the window on the projection plane. VPN is parallel to
the direction from the center of attention to the camera position.
111
The viewing parameters are as follows:
To create the side view (Fig. 7.19), we require the viewing situation
of Fig. 7.20, with the (y, z) plane (or any plane parallel to it) as the
view plane. This situation corresponds to the following viewing
parameters:
.in
es
ot
un
m
112
Fig. 7.19 Viewing situation that creates Fig. 7.18, a front view of the
house. The PRP could be any point with x = 8 and y = 8.
.in
The center of the window is at (12, 8, 0) in VRC; hence, the PRP has
these same u and v coordinates.
We create a top view of the house by using the (x, z) plane as the view
plane and VPN as the y axis. The default view-up direction of +y must
es
be changed; we use the negative x axis. With VRP again stated as a
corner of the house, we have the viewing situation in Fig. 7.22, defined
by the following viewing parameters:
ot
un
m
Fig: 7.20 Parallel projection from the side of the house & Fig: 7.21 The
viewing situation for Fig: 7.20
113
Fig: 7.22 The viewing situation for a top view of the house.
.in
direction (-1,-1, -1), one of the eight possible directions for an isometric.
The following viewing parameters create such an isometric projection:
es
ot
un
The window is symmetrical about VRP, which implies that VRP, the origin
of the VRC system, is the window's center. Placing PRP as specified means
that the direction of projection, which is the vector from PRP to the
window center, is (0, 0, 0) - PRP= - PRP, or its negative PRP.
114
7.4.3 Finite View Volumes
In all the example, the view volume has been expected to be infinite.
The front and back clipping planes, help to determine a finite view
volume.
These planes, both of which are parallel to the view plane, are at
distances F and B respectively from the view reference point,
measured from VRP along VPN.
To avoid a negative view volume, we must ensure that F is
algebraically greater than B.
Fig: 7.23 Perspective projection of the house with back clipping plane
.in
at z = 31.
A front perspective view of the house with the rear wall clipped away
(Fig: 7.23) results from the following viewing specification, in which F
and B have been added.
es
If a distance is given, then clipping against the corresponding plane is
assumed; otherwise, it is not.
ot
If the front and back clipping planes are moved dynamically, the 3D
structure object being viewed can often be discerned more readily than
it can with a static view.
115
7.5 THE MATHEMATICS OF PLANAR GEOMETRIC
PROJECTIONS
.in
on the projection plane.
These transformations consist of various compositions of the five
transformations: orthographic, projection, rotation, shear,
translation and perspective.
es
For simplicity, we start by assuming that, in the perspective
projection, the projection plane is normal to the z-axis at z=d, and
ot
that, in the parallel projection, the projection plane is the z=0 plane.
Each of the projection can be defined by a 4 x 4 matrix. Because the
projection matrix can be composed with transformation matrices,
un
. .
𝑥 = = 𝑦 = = …………….. (7.2)
/ /
1 0 0 0
0 1 0 0
𝑀 =0 0 1 0 …………………………… (7.3)
0 0 0
.in
es
Fig: 7.24 Perspective Projection
ot
𝑋 1 0 0 0 𝑥
𝑌 0 1 0 0 𝑦
=𝑀 .𝑃 = . ------------ (7.4)
𝑍 0 0 1 0 𝑧
m
𝑊 0 0 1/𝑑 0 1
Or
[𝑋 𝑌 𝑍 𝑊 ] = 𝑥 𝑦 𝑧 ------------------ (7.5)
Now, dividing by W (which is z/d) and dropping the fourth
coordinate to come back to 3D we have
, , = 𝑥 ,𝑦 ,𝑧 = , , 𝑑 ; ------------------ (7.6)
/ /
These equations are the correct results of Eq. (7.1), plus the
transformed z coordinate of d, which is the position of the
projection plane along the z axis.
= , = -------------------------------------------- (7.7)
Multiplying by d, we get
. .
𝑥 = = ,𝑦 = = ------------------------- (7.8)
/ /
.in
Fig.7.25: Alternative Perspective Projection
es
The matrix is
1 0 0 0
0 1 0 0
𝑀′ = ------------------------------------------- (7.9)
0 0 0 0
ot
0 0 1/𝑑 1
to tend to infinity.
The orthographic projection onto a projection plane at 𝑧 = 0 is
straightforward. The direction of projection is the same as the
m
.in
Fig: 7.26 - The intersection of the line from COP to P=(x,y,z) with
the projection plane at z= 𝒛𝒑 is the projection of the point P. The
COP is distance Q from the point P. The COP is the distance Q
es
from the point (0, 0,𝒛𝒑 ) in direction (𝒅𝒙 , 𝒅𝒚 , 𝒅𝒛 )
𝑦 = 𝑄𝑑 + 𝑦 − 𝑄𝑑 𝑡, ------------------------- (7.14)
𝑧 = 𝑧 + 𝑄𝑑 + (𝑧 − (𝑧 + 𝑄𝑑 ))𝑡, ----------------------- (7.15)
( )
𝑡= ----------------------------------------- (7.16)
( )
Substituting this value of 𝑡 into Eq. (7.13) and Eq. (7.14) to find
𝑥 = 𝑥 𝑎𝑛𝑑 𝑦 = 𝑦 yields
𝑥 = ------------------------- (7.17)
𝑦 = ------------------------------ (7.18)
119
Multiplying the identity 𝑧 = 𝑧 on the right-hand side by fraction
whose numerator and denominator are both
+ 1 ---------------------------------------- (7.19)
𝑧 =𝑧 = ------------------------------ (7.20)
.in
⎡1 0 − 𝑧 ⎤
⎢ ⎥
⎢0 1 − 𝑧 ⎥
𝑀 =⎢
es
⎥ --------------------- (7.21)
⎢0 0 − +𝑧 ⎥
⎢ ⎥
⎣0 0 − +1⎦
ot
.in
FOR PROJECTIONS AND VIEWING
After having all required matrices of projection and viewing, we can now
es
combine all our transformation into one overall matrix, which will convert
a point from world coordinates to Normalized Device Coordinates (NDC)
while retaining a representation of the relative depth of the points.
ot
MTOT=Awv * Mp * N
Where,
un
121
Fig: 7.27 Basics Vectors
As we have seen in stages in 3D viewing, different stages generate and
work on different coordinate system, given as:
Co-ordinate System:
1. Screen coordinates
2. Local co-ordinate system or 3D modelling coordinate
3. Word coordinate
4. View reference coordinates
.in
5. Normalized projection coordinates
6. 2D device coordinate es
ot
un
m
Fig: 7.28 Coordinate systems and how they relate to one another.
The matrices underneath each stage effect the transformation applied
at that stage for the perspective and parallel projections.
.in
transformation convert from the world-coordinate system into the
eye-coordinate system. The eye coordinate system is sometimes left-
handed. es
From eye coordinates, we next go to the normalized-projection
coordinate system, or 3D screen coordinates, the coordinate system of
the parallel-projection canonical view volume (and of the perspective-
projection canonical view volume after the perspective
ot
transformation).
The Basic system calls this system 3D normalized device coordinates.
un
.in
es
ot
7.9 SUMMARY
.in
Two-point perspective projection of the house
Two-point perspective projection of the house
Default perspective projection view volume- pyramid-like
es
The Mathematics of Planar Geometric Projections: Planar projections
are the subset of 3D graphical projections constructed by linearly
mapping points in three-dimensional projection plane.
ot
dimensions.
Combined transformation matrices for projections and viewing:
MTOT=Awv * Mp * N
MTOT: - Represents Combined transformation matrices for
projection and viewing
Awv: - Represents Metrics of real-world coordinates
Mp: - Represents Metrics of perspective transformation
N: - Represents Normalization Matrix
Coordinate Systems and matrices: Different stages generate and
work on different coordinate system, given as:
Screen coordinates
Local co-ordinate system or 3D modelling coordinate
Word coordinate
125
View reference coordinates
Normalized projection coordinates
2D device coordinate
Camera model and viewing pyramid: the view frustum (also called
viewing frustum) is the region of space in the modeled world that may
appear on the screen; it is the field of view of the “notional camera”.
.in
generated.
Q.6 Briefly explain the mathematics of planar geometry.
Q.7 Explain combined transformation matrices for projections and
es
viewing.
Q.8 Explain different coordinate systems and matrices in detail.
ot
Q.9 Explain the concept of camera model and viewing pyramid with neat
labelled diagram.
un
*****
126
8
LIGHT: - LIGHT: RADIOMETRY,
TRANSPORT, EQUATION,
PHOTOMETRY
Unit Structure
8.0 Objectives
8.1 What is Light?
8.2 Radiometry
8.2.1 Radiant Energy
8.2.2 Spectral Radiant Energy
8.2.3 Radiant Flux (Radiant power)
.in
8.2.4 Spectral Radiant Flux
8.2.5 Radiant Flux Density (irradiance and radiant Exitance )
8.2.6 Spectral Radiant Flux Density
8.2.7 Radiance
es
8.2.8 Spectral Radiance
8.3 Transport
ot
8.3.1 Rasterization
8.3.2 Ray Casting
un
8.6 Summary
8.7 Unit End Exercise
8.8 List of References
8.0 OBJECTIVES
.in
Light is radiant energy. When light is absorbed by a physical object, its
energy is converted into some other form.
For example: - In microwave oven, when we heats a glass of water
es
then its microwave radiation is absorbed by the water molecules. The
radiant energy of the microwaves is converted into thermal energy
(heat).
ot
Similarly, visible light causes an electric current to flow in a
photographic light meter then its radiant energy is transferred to the
electrons as kinetic energy. Radiant energy (denoted as Q) is measured
un
in joules.
8.2 RADIOMETRY
m
Units of radiometry:
Radiometric quantities are expressed in radiant units (such as watt) in
128
general case or in visual units when we are only interested in the fraction
of light in the visible part of the spectrum. Visual units are useful in many
applications such as multimedia, lightning system etc.
.in
Biomedical: Optical instrumentation, Medical imaginary.
Industry: Photovoltaic, Lightning, Security, Non-destructive testing.
Spatial: Planetary or deep space observation, Satellite design.
es
Defense: Identification, Navigation.
other form. For example, Microwave oven heats a glass of water then
its microwave radiation is absorbed by the water molecules. The radiant
energy of the microwaves is converted into thermal energy (heat).
m
.in
wavelength λ.
Spectral radiant flux is denoted by 𝛌 , it is given by,
Spectral Radiant flux = radiant flux/ wavelength
es
It is measured in watts per nanometer.
ot
8.2.5 Radiant Flux Density (Irradiance And Radiant Exitance):
• Radiant flux density is the radiant flux per unit area at a point on a
surface, where the surface can be real or imaginary (i.e. an exact plane).
un
.in
dA is the differential area surrounding the point
• Radiant flux density can be measured anywhere in three dimensional is
the space between them (e.g. in air or a vacuum), and inside
es
transparent media such as water and glass.
• Radiant flux density is measured in watts per square meter.
ot
8.2.6 Spectral Radiant Flux Density :
• Spectral radiant flux density is radiant flux per unit wavelength
interval at wavelength λ.
un
• When the radiant flux is leaving the surface, it is called spectral radiant
exitance denoted by 𝑀λ , and is defined as:
𝑴𝛌 = 𝒅𝑴/𝒅𝛌 ……. (8.4)
• Spectral radiant flux density is measured in watts per square meter
per nanometer.
8.2.7 Radiance:
• Radiance is the radiant flux emitted, reflected, transmitted or received
by a given surface, per unit solid angle per unit projected area.
• Where, a solid angle is the 2D angle in 3D space that an object
subtends at a point. It is a measure of how large the object appears to
an observer looking from that point. In the international system of
units (SI), a solid angle is expressed in a dimensionless unit called a
steradian.
131
• A more formal definition of radiance requires that we think of a ray as
being an extremely small narrow (“elemental”) cone with its apex at a
point on a real or imaginary surface. This cone has a differential solid
angle d that is measured in steradian.
• We must also note that the ray is intersecting the surface at an angle. If
the area of intersection with the surface has a differential cross-
sectional area dA, the cross-sectional area of the ray is dAcos𝜃, where
𝜃 is the angle between the ray and the surface normal, as shown in
(fig: 8.3) where, the ray cross-sectional area dAcos𝜃, is called the
projected area of the ray-surface intersection area dA.
• With these preliminaries in mind, we can imagine an elemental cone
d containing a ray of light that is arriving at or leaving a surface (fig.
8.4 and 8.5). the definition of radiances is then:
𝑳 = 𝒅𝟐 /[dA(dcos𝜽)] ………(8.5)
.in
es
ot
132
Fig. 8.5 Radiance (leaving)
• Another way of looking a radiance is to note that the radiant flux
density at a point on a surface due to single ray of light arriving (or
leaving) at an angle to the surface normal is, d/(dAcos).
• The radiance at that point for the same angle is then
𝒅𝟐 /[dA(dcos𝜽)], or radiant flux density per unit solid angle.
• Radiance is measured inn watts per square meter per steradian.
.in
8.2.8 Spectral Radiance:
8.3 TRANSPORT
or luminous flux per unit area on the point of the surface at which it is
measured.
Light transport theory deals with the mathematics behind calculating
the energy transfers between media that affect visibility.
Rendering converts a model into an image either by simulating a
method such as light transport to get physically based photorealistic
images, or by applying some kind of style as non-photorealistic
rendering.
The two basic operations in light transport are transport (how much
light gets from one place to another) and scattering (how surfaces
interact with light).
Many rendering algorithms have been researched and software used
for rendering are employed by using a number of different techniques
to obtain a final image.
Tracing every particle of light in a scene is nearly always completely
133
impractical and takes more amount of time.
Even tracing a large enough portion produce an image that takes an
excessive amount of time if the sampling is not intelligently limited.
Therefore a few families of more-efficient light transport modeling
techniques have emerged and they are as follows:
8.3.1 Rasterization :
It assumes an image defined in a vector graphics format (shapes) and
converting it into a raster image (a series of pixels, dots or lines, which,
when displayed together, creates image which was represented via
shapes).
.in
Fig: 8.6 Rasterization
es
The rasterized image may then be displayed on a computer display,
video display or printer, or stored in a bitmap file format.
Rasterization may refer to either the conversion of models into raster
ot
geometry models.
.in
computational cost involved.
Ray tracing is mostly used for application where image can be
rendered slowly ahead of time such as in still image, film, T.V and
es
poorly used for application like computer games where speed is
critical.
ot
How does ray tracing works?
un
m
135
Fig. 8.8 Tracing ray from light sources to eye
a) A ray tracing is so named because it tries to stimulate the path that
light rays take as they bounce around within the world.
b) They are outlined through the scene.
c) The objective is to determine the color of each light ray that strikes
the view window before reaching the eye.
.in
d) In this method consider tracing one ray through a scene with one
object as mention in above figure: 8.8.
e) We start from light bulb source then we need to decide, how many
es
rays to shoot out from the bulb, then for each ray we have to decide in
what direction it is going.
f) There is infinity of directions in which it can travel, to choose one
ot
direction we are tracing a number of photons, some will reach the eye
directly, other will bounce around, some and other will reach the eye
and many more will never hit the eye at all.
un
g) For all the rays that will never reach the eye, effort for producing
tracing will be of no use.
h) In order to save our wasted effort, we need to trace only those rays
m
that are guaranteed to hit the view window and reach the eye.
i) Instead of tracing rays starting at light source we trace them backward
starting at the eye.
j) Consider any point on view window whose color we are trying to
determine. Its color depends on the color of light rays that pass
through that point in view window and reach the eye.
k) For solving this problem we develop two rays: Original ray and
backward ray.
i) If Original ray come directly from light source, then backward
ray will go directly to light source.
ii) If Original ray bounce off the table first, then the backward ray
will also bounce off the table.
iii) We can clearly see this looking at the above figure again by
reversing the directions of the arrow.
136
iv) So backward method does same thing as the original method but
it will not waste any kind of efforts for the rays that will never
reach the eye.
8.3.4 Radiosity:
The radiosity method of light interaction was developed by
researchers at Cornell University and Hiroshima University, as a
method for computing radiant heat exchange between surfaces.
This is a method which attempts to pretend the way in which
directly illuminated surfaces act as indirect light sources that
illuminate other surfaces. This produces more realistic shading and
seems to better capture the ‘ambience’ of an indoor scene. A
classic example is the way that shows ‘hug’ the corners of rooms.
It is a global illumination algorithm used in 3D computer graphics
rendering.
It is an application of the finite element method to solve the
rendering equation for scenes with diffused surface.
.in
es
ot
un
scene which have been exactly chosen and placed by the artist in an
attempt to create realistic lighting:
o Spot lighting with shadows (placed outside the window to
create the light shining on the floor)
o Ambient lighting (without which any part of the room not
struck directly by a light source would be totally dark)
o Omnidirectional lighting without shadows (to reduce the
flatness of the ambient lighting).
The image on the right was reduced using a radiosity algorithm.
There is only one source of light: an image of the sky placed outside
the window. The difference is marked. The room glows with light.
Soft shadows are visible on the floor, and indirect lighting effects are
visible around the room. Besides, the red color from the carpet has
drained onto the grey walls, giving them a somewhat warm advent.
None of these effects were exactly chosen or planned by the artist.
137
Because of this, radiosity is a prime component of leading real-time
rendering methods, and has been used from beginning-to-end to
create a large number of well-known recent feature-length animated
3D-cartoon films.
There are two types of radiosity:
Progressive radiosity: - It solves the system iteratively in such a
way that each iteration, we can get an intermediate radiosity value
for the patch.
Shooting radiosity: - It iteratively solves the radiosity equation by
shooting the light from the patch with most error at each step.
.in
Light at a pixel from a light = Ambient + Diffuse + Specular contributor
𝑰𝒍𝒊𝒈𝒉𝒕 = 𝑰𝒂𝒎𝒃𝒊𝒆𝒏𝒕 + 𝑰𝒅𝒊𝒇𝒇𝒖𝒔𝒆 + 𝑰𝒔𝒑𝒆𝒄𝒖𝒍𝒂𝒓
(As given in below diagram)
es
ot
un
8.5 PHOTOMETRY
.in
Photometry is a branch of science concerning light in terms of color
apparent by the viewer from the physical inspiration of imposing
photons into the eye and the combined response with the brain.
es
The purpose of photometry is to measure light in a way that takes the
sensitivity of human visual system into account. Photometry is essential
for evaluation of light sources and objects used for lighting, signaling,
ot
displays, and other applications where light is envisioned to be seen by
humans.
It is a quantitative science based on a statistical model of the human
un
visual responses to light that is, our perception of light under wisely
precise conditions.
The human visual system is an amazingly complex and highly
m
139
Fig. 8.12: CIE photometric Curve
.in
shows the photonic luminous effectiveness of the human visual
system as a function of wavelength. It provides a weighting function
that can be used to convert radiometric into photometric
measurements.
es
Photometric theory does not address how we notice colors. The light
being measured can be monochromatic or a combination or
continuum of wavelengths; the eye’s response is determined by the
ot
CIE weighting function. This emphasizes a vital point: The only
difference between radiometric and photometric theory is in their
units of measurement.
un
8.6 SUMMARY
m
.in
visible spectrum: 650 nm is red, 540 nm is green, and 450 nm is blue,
and so on. es
8.7 UNIT END EXERCISES
ot
Q.1 Explain Radiometry in brief.
Q.2 Explain the following terms:
un
a) Radiant energy
b) Spectral Radiant energy
c) Radiant Flux or Radiant power
m
141
Q.8 Write a short note on radiosity.
Q.9 Write a short note on Transport equation.
Q.10 Explain the concept of photometry in detail.
.in
*****
es
ot
un
m
142
9
COLOR: - COLORIMETRY, COLOR
SPACES, CHROMATIC ADAPTATION,
COLOR APPEARANCE
Unit Structure
9.0 Objectives
9.1 What is Color?
9.2 Colorimetry
9.2.1 Colorimetry Concepts in Display Test and Measurement
9.3 Color spaces
9.3.1 RGB Color Model
9.3.2 CMYK Color Model
.in
9.3.3 HSV Color Model
9.3.4 HSL Color Model
9.4 Chromatic Adaptation
es
9.5 Color Appearance
9.6 Summary
9.7 Unit End Exercises
ot
9.8 List of References
un
9.0 OBJECTIVES
143
It is also defined as an quality of visual insight consisting of any
arrangement of chromatic and achromatic content this attribute can be
described by chromatic color names such as yellow, orange, brown,
red, pink, green, blue, purple, etc., or by achromatic color names such
as white, gray, black, etc., and qualified by bright dim, light, dark,
etc., or by combination of such names.
Light is a mixture of radiations having different wavelength where
different wavelength implies different colors.
Light maybe decomposed into a spectrum that is the separation of
photos (light quanta) with respects to the different wavelength i.e.
different colors. Illustrated in fig: 9.1
Spectrum is measured as Watt per square meter per nanometer. The
spectrum is condition that has infinite numbers of independent
elementary colors present in it.
.in
es
ot
144
9.2.1 COLORIMETRY CONCEPTS IN DISPLAY TEST AND
MEASUREMENT:
Color: Color perception is naturally independent. The objective
capacities of the color of a source object is alleged by a standard human
observer that also can be measured. Various standard human observers
are defined in the disciple of Colorimetry. According to standard
model, the perceived color of a given spot can be reduced to a three-
dimensional value. The three dimensions of color can be described as
color of brightness, hue and purity or saturation.
Chromaticity: A two-dimensional explanation of color has the mixture
of hue and purity, neglecting the third dimension of brightness. The
luminance (brightness) and chromaticity of a spot on a display, taken
together, provide a complete depiction of its color.
Gamut mapping (RGB plotting): All colors that are produced by a
display device are created by combination of Red, Green and Blue
colors. Each display color can be described in terms of the amount of
R, G and B primaries present. If the chromaticity directs the three
.in
primaries are plotted in a chromaticity diagram, the triangle enclosed
by these points represents the full range of colors reproducible by the
display. This range is the displays of color gamut.
es
Correlated Color Temperature (CCT): This is a metric used to
define the color of a white light by comparing its chromaticity to that of
an idealized radiant source, known as a black body. The color of a
bright source (which glows due to heat) depends upon its temperature;
ot
lower temperature sources are bluer. The CCT of a white light is the
high temperature of the black body which almost closely matches its
chromaticity.
un
145
9.3 COLOR SPACES
.in
The primary colors are arranged around a circle at equal (120 degree)
intervals. Color Wheels often depict “Painter’s Colors” primary colors,
which leads to a different set of hues.
es
ot
un
m
146
9.3.1 RGB Color model:
The RGB color model is an additive color model in which red, green,
and blue light are added together in various ways to reproduce a broad
array of colors. The name of the model comes from the initials of the
three additive primary colors, red, green, and blue.
The main purpose of the RGB color model is for the sensing,
representation, and display of images in electronic systems, such as
televisions and computers, though it has also been used in a
conventional photography. Before the electronic age, the RGB color
model already had a solid theory behind it, based on the human
perception of colors.
.in
es
ot
un
m
In the RGB color model, we use red, green, and blue as the three
primary colors. We do not actually specify what wavelengths these
primary colors correspond to, so this will be different for the different
types of output media, for example, different monitors, films,
videotapes, and slides.
This is an additive model since the phosphors are emitting light. A
subtractive model would be the one in which the color is the reflected
light. We can represent the RGB model by using a unit cube. Each
point in the cube (or the vector where the other point is the origin)
represents a specific color. This model is the best for setting the
electron guns for a CRT (refer Figure: 9.3)
147
9.3.2 CMY Color model:
CRTs produce color by the emission and use of the RGB model.
Printers produce color by the reflective light, so it is a subtractive
process and uses a model based on the colors i.e. cyan, magenta, and
yellow (CMY).
CMYK (short for cyan, magenta, yellow and key or black), or the
process color (the four-color model) is a subtractive color model used
in the color printing, also used to describe the printing process itself.
The CMYK model works by partially or entirely masking, certain
colors on the typically white background (that is absorbing particular
wavelengths of light). Such a model is called subtractive because the
inks subtract the brightness from white (see Figure 9.4)
.in
es
Fig 9.4: CMY color model
ot
Remember that cyan-green+ blue, go the light reflected from a cyan
pigment has no red component, that is, red is absorbed by cyan.
Similarly, magenta subtracts green, and yellow subtracts blue.
un
Printers usually use four colors: cyan, yellow, magenta, and black. This
is because cyan, yellow, and magenta together produce a dark grey
rather than a true black. The conversion between the RGB and CMY is
m
easily computed as
Cyan 1-Red
Magenta-1-Green
Yellow 1-Blue
The reverse mapping is similarly, obvious.
Red-1-Cyan
Green-1-Magenta
Blue-1-Yellow
9.3.3 HSL Color model:
An HSL model is based on the parameters hue, saturation, and
lightness.
The HSL is another way to describe a color with the three parameters.
The RGB model is the way computer screens a work, but not very
intuitive.
148
The nicest application of this color model is that you can easily create
the rainbow gradients or change the color, lightness or saturation of an
image with this color model.
.in
The hue indicates the color sensation of light. In other words, if the
color is red, yellow, green, cyan, blue, and magenta, this representation
looks almost the same as the visible spectrum of light, except on the
es
right is now the color magenta (the combination of red and blue),
instead of violet (light with a frequency higher than blue).
The hue works circular, so it can be represented on a circle instead. A
hue of 360° looks the same again as a hue of 0°. The saturation
ot
indicates the degree to which the hue differs from a neutral gray.
The values run from 0 percent (which is no color) to 100 percent
un
(a)
.in
es
ot
un
(b)
Fig 9.6: 3D presentation of an HSV model
m
150
object (refer to Figure 9.6(b)). When it is represented as a conical
object, a hue is represented by a circular part of a cone. The cone is
usually represented in a 3D form. A saturation is calculated using the
radius of the cone, and the value is the height of the cone. A hexagonal
cone can also be used to represent an HSV model. The advantage of the
conical model is that it is able to represent the HSV color space in a
single object. Due to the 2D nature of computer interfaces, the conical
model of HSV is best suited for selecting colors for computer graphics.
The colors used in HSV can be clearly defined by the human perception
that is not always the case with RGB or CMYK.
The HSV color space is widely used to generate high-quality computer
graphics. In simple terms, it is used to select different colors needed for
a particular picture. An HSV color wheel is used to select the desired
color.
A user can select a particular color needed for a picture from the color
wheel. It gives the color according to the human perception.
.in
9.4 CHROMATIC ADAPTATION
The surroundings in which viewer objects and images has a larger
effect on how we perceive those objects/ the range of viewing
es
environment (i.e., by mean of light) is very large, from sunlight too
moonlight or from candle light to luminous light. The lightning
condition is not only involving a very high range of light but also varies
ot
greatly in the range of color which emits light.
A human visual system accommodates these change in the environment
through a process called as adaptation.
un
- Chromatic adaptation
Light Adaptation:
1) It refers to the change occurs when we move from very dark to very
light environment i.e., dark -> light
2) When this happens we are dazzled at first by the light but soon we
adapt to the new situation and then we begin to distinguish objects in
our environment.
Dark Adaptation:
1) It refers to the change occurs when we move from very light to very
dark environment i.e., light -> dark
2) When this happens we see very little at first but after some time the
details of an objects starts appearing in front of us.
3) Time needed to adapt objects in dark adaptation is much longer than
151
that of light adaptation.
Chromatic Adaptation:
1) It refers to the human’s ability to adjust and largely ignore differences
in the color of the illumination. Although, we are able to largely ignore
the changes in the viewing environment but we are unable to do it
completely. For example, color appears much more colorful in a sunny
day as compare to a cloudy day.
2) Chromatic adaptation is the ability of the human visual system to
discount the color of a light source and to approximately preserve the
appearance of an object. For example, a white piece of paper appears to
be white when viewed under sky light and tungsten light (light under a
light bulb). However, the measured tri-stimulus values are quite
different for the two viewing conditions for e.g., sky light is bluer and
contains shorter wavelength energy than tungsten light which is
illustrated in fig: 9.7.
.in
es
ot
un
light
3) Chromatic adaptation is the biological equivalent of a white balancing
operation that is available on most of the modern cameras. It allows
white objects to appear white for a large number of lightning
conditions.
4) Digital imaging systems, such as digital cameras and scanners, do not
have the ability to adapt to the light source. Scanner usually use
fluorescent light sources. For digital cameras the light source varies
with the scene, and sometimes within a scene. Therefore, to achieve the
same appearance of the original or original scene under different
display conditions (such as a computer monitor or a light booth), the
captured image tri-stimulus values have to be transformed to take into
account the light source of the display viewing conditions such
transformation are called chromatic adaptation transforms (CATs)
5) The adapting illumination can be measured off a white surface of a
152
scene. In a digital image, the adapting illumination came be
approximated as the maximum tri-stimulus values of the scene.
.in
es
ot
un
153
There are different parameters used for color appearance which are
given as follows:
- HUE
- Brightness
- Lightness
- Colorfulness
- Chroma
- Saturation
HUE: It is an Attribute of a visual sensation according to which an area
appears to be similar to one of the perceived colors i.e. pure color: red,
yellow, green, and blue, or to a combination of two of them. Hue is a
more technical definition of our color perception which can be used to
communicate color ideas.
Brightness: It is an Attribute of a visual sensation according to which
an area appears to emit more or less light. It is referred to as the
absolute level of the perception.
.in
Lightness: It is a representation of variation in the perception of a color
or color space's brightness. It is referred to as relative brightness
normalized for changes in the illumination and viewing conditions.
es
Lightness defines a range from dark (0%) to fully illuminate (100%).
Any original hue has the average lightness level of 50%. Lightness is
the range from fully shaded to fully tinted. We can lighten or darken a
color by changing its lightness value
ot
154
Few color appearance models are listed below:
1. CIELAB Model- first color appearance model to focus on overall
color improvement of an object
2. Nayatani et al Model- focuses on illumination engineering and the
color rendering properties of light sources.
3. Hunt Model-focuses on color image reproduction
4. RLAB Model-focuses on color image reproduction
5. LLAB Model-focuses on color image reproduction
6. CIECAM97A Model-focuses on color image reproduction
7. Model-focuses on hue color formulation and suited for gamut
mapping
8. ICtCp Model-improves the original IPT by exploring higher dynamic
range and larger color gamut.
9.6 SUMMARY
.in
A color model is an abstract mathematical model that describes the
way colors can be represented. It can be represented as tuples of
es
numbers, typically as the three or four values of the color components.
A CIE chromaticity diagram is an international standard for the
primary colors established in 1931.
ot
Colorimetry is a science of color measurement and color appearance.
Colorimetry applications:
un
Display Manufacturing
Broadcasting
Graphic Design and Computer Animation
m
Color space, also known as the color model (or color system), is an
abstract mathematical model which simply describes the range of
colors as tuples of numbers, typically as 3 or 4 values or color
components (e.g. RGB).
Chromatic adaptation is the ability of the human visual system to
discount the color of a light source and to approximately preserve the
appearance of an object. There are three types of adaptation:
Light adaptation
Dark adaptation
Chromatic adaptation
A Color wheel is a tool that provides a visual representation of the
relationships between all possible hues.
A Color appearance Model provides mathematical formulae to
transform Physical measurements of the stimulus and viewing
155
environment into Correlates of perceptual attributes of color (eg.
lightness, Chroma, hue, etc.)
.in
Q.7 Explain Color appearance in brief.
*****
156
UNIT IV
10
VISIBLE-SURFACE DETERMINATION
AND PLANE CURVES AND SURFACES
Unit Structure
10.0 Objectives
10.1 Techniques for efficient Visible-Surface Algorithms,
10.2 Categories of algorithms
10.2.1 Back face removal
10.2.2 Scan-line method
10.2.3 The z-Buffer Algorithm
.in
10.2.4 Area sub-division method (Warnock’s Algorithm)
10.2.5 BSP trees
10.2.6 Painter’s algorithms (depth sorting)
es
10.2.7 Visible-Surface Ray Tracing
10.3 Comparison of the methods
10.4 Summary
ot
10.5 Questions
10.6 References
un
References
10.0 OBJECTIVES
m
157
10.1 VISIBLE-SURFACE DETERMINATION
.in
ii. Face coherence: Usually surface properties vary smoothly across a
face. This allows the computations for one part of face to be used with
incremental changes to the other parts of the face.
es
iii. Edge coherence: The visibility of edge may change only when it
crosses a visible edge or penetrates a visible face.
iv. Implied edge coherence: If one planar face penetrates another their
ot
line of intersection can be determined from two points of intersection.
v. Area coherence: A group of adjacent pixels is often belonging to the
same visible face.
un
one scan line of an image typically changes very little from the set on
the previous line.
viii. Depth coherence: Adjacent parts of the same surface are typically
same or very close depth. Therefore, once the depth at one point of the
surface is determined, the depth of the points on the rest of the surface
can be determined by at the simplest incremental calculation.
ix. Frame coherence: Pictures of the same scene at two successive
points in time are likely to be quite similar, except small changes in
object and view ports. Therefore, the calculations made for one
picture can be reused for the next picture in as sequence.
2. Perspective Transformation:
Visible-surface determination is done in a 3D space prior to the projection
into 2d that destroys the depth information needed for depth comparisons,
and depth comparisons are typically done after the normalizing
transformation.
158
Due to this projector are parallel to the Z axis in parallel projections or
emanate from the origin in perspective projections.
In parallel projection, when x1=x2 and y1=y2 we can say that points are
on the same projector.
However, in perspective projection we must perform four divisions:
x1/z1=x2/z2 and y1/z1=y2/z2 to determine whether the points are on the
same projector.
These divisions can be avoided by first transforming a 3D object into the
3D screen-coordinate systems, so that the parallel projection of the
transformed object is the same as the perspective projection of the
untransformed object.
3. Extents and bounding Volumes:
a. Two objects with their projections and the rectangular screen extents
surrounding the projections.
b. It is easier to check the overlapping of extents than the projections,
and we can say that when the extents are not overlapping then
.in
projections are also not overlapping. Therefore, extents must be
compared first and then the projections must be compared only if the
extents are overlapped. This avoids unnecessary comparisons in
checking the overlapping of projections.
es
c. Extents used to surround the object themselves rather than their
projections; in this case, the extent become solid and are commonly
known as bounding volumes. In this case extent can be used to check
ot
whether two objects are overlapped or not.
d. Extent and bounding volumes are used to determine whether projector
un
5. Spatial Partitioning:
a. In this technique, subdivision rule is applied to break down a large
problem into a number of smaller ones. This object and their
projections are assigned to spatially coherent groups as a pre-
processing step. This partitioning speed up the process of determining
159
which object intersect with a projector. Because now it is necessary to
test only the objects lying within the partitions which intersect with
projector.
b. When objects are unequally distributed in space the adaptive
partitioning is more suitable. Because it allows variable size of each
partition.
6. Hierarchy
a. In hierarchical structure different levels are assigned to the object and
there is a parent-child relationship between the objects.
b. In this structure, each child is considered as a part of its parent. This
allows to restrict the number of object comparison needed by a
visible-surface algorithm.
c. If the parent level object is fail to intersect, the lower level objects
belongs to the parent do not need to be tested for intersection.
10.1.2. Object Space Method and Image Space Method:
Object Space method Image Space method
.in
1. It deals with object definition 1. It is a pixel-based method.
directly It is concerned with the
final image, what is visible
es within each raster pixel.
2. Here surface visibility is 2. Here line visibility or point
determined. visibility is determined.
3. It is performed at the precision 3. It is performed using the
ot
with which each object is resolution of the display
defined, No resolution is device.
considered.
un
adjusted.
5. These were developed for vector 5. These are developed for
graphics system. raster devices.
6. Object-based algorithms operate 6. These operate on object
on continuous object data. data.
7. Vector display used for object 7. Raster systems used for
method has large address space. image space methods have
limited address space.
8. Object precision is used for 8. There are suitable for
application where speed is application where accuracy
required. is required.
9. It requires a lot of calculations if 9. Image can be enlarged
the image is to enlarge. without losing accuracy.
10. If the number of objects in the 10. In this method complexity
scene increases computation time increase with the
also increases. complexity of visible parts.
160
10.2 CATEGORIES OF ALGORITHMS
10.2.1 Back- face removal :
1. A polygon has two surfaces, a front and a back just as a piece of
paper does. We might picture our polygons with one side painted
light and the other painted dark. But the question is “how to find
which surface is light or dark”.
2. When we are looking at the light surface, the polygon will appear to
be drawn with counter clockwise pen motions, and when we are
looking at the dark surface the polygon will appear to be drawn with
clockwise pen motions.
3. Let us assume that all solid objects are to be constructed out of
polygons in such a way that only the light surfaces are open to the
air; the dark faces meet the material inside the object. This means
that when we look at an object face from the outside, it will appear
to be drawn counter clockwise.
4. If a polygon is visible, the light surface should face towards us and
.in
the dark surface should face away from us. Therefore, if the
direction of the light face is pointing towards the viewer, the face is
visible, otherwise the face is hidden and should be removed.
5. The direction of the light face can be identified by examining the
es
result
N.V > 0
ot
Where N: Normal vector to the polygon surface with cartesian
components(A,B,C).
1V: A vector in the viewing direction from the eye position.
un
6. We know that, the dot product of two vector gives the product of the
length of the two vectors times the cosine of the angle between
them.
m
161
10.2.2 Scan Line Algorithm:
A scan line method of hidden surface removal is another approach of
image space method. It is an extension of the scan line algorithm for
filling polygon interiors. Here, the algorithm deals with more than one
surfaces. As each scan line is processed, it examines all polygon surfaces
intersecting that line to determine which are visible. It does the depth
calculation and finds which polygon is nearest to the view plane. Finally,
it enters the intensity value of the nearest value of the nearest polygon at
that position into the frame buffer.
1. We know that scan line algorithm maintains the active edge list. This
active edge list contains only edges that cross the current scan line,
sorted in order of increasing x. The scan to indicate whether a position
along a scan line is inside or outside of the surface. Scan lines are
processed from left to right. At the leftmost boundary of a surface, the
surface flag is turned ON, and at the rightmost boundary, it is turned
OFF.
.in
es
ot
surface removal. The active edge list for scan line 1 contains the
information for edges AD, BC, EH an FG. For the positions along this
scan line between edges AD and BC, only the flag for surface S1 is
ON. Therefore, no depth calculations are necessary, and intensity
m
162
processes one line at a time rather than processing one pixel(a point
on raster display) at a time.
5. Edge list table: This list maintains the record of all the edges by
storing their endpoint coordinates. The x-coordinate that we choose,
whose Y-coordinate = Ymin.
.in
of x).
7. Polygon table(list): This list consists of:
a. Polygon Id.
b. Plane equation.
es
c. Color Information of the surface.
d. Flag of surface(on/off)].
ot
163
color-intensities of the corresponding surfaces into the frame
buffer(refresh buffer).
2. Then, process the scanline(S2), whose, Active edge table (Aet)
contains[AD,BC,RS,PQ], and the flag is set to “on” for surface
(ABCD) and surface(PQRS). Both of the polygons surfaces are
overlapping each other. So for this overlapped region that which of
the surface intensity should be taken into account? calculate the depth
(Zmin) of both surface(S1) and surface(S2) of the overlapped portion, of
surface intensity . Next,
If depth(S1)>depth(S2), then the Flag of surface S1=” on” and intensity
of surface S1 will be considered else S2, now
Drop the color-intensities of the corresponding surfaces whose flag is
set to on into the frame buffer(refresh buffer).
3. As Scanline(S3) is passing through the same portion from where
Scanline(S2) is passing, S3 also has the same Active edge table(Aet)
components as S2 has and no need to calculate the depth(S1) and
depth(S2) again so S3 can take the advantage of the concept of
.in
Coherence.
2. The surface depth is measured from the view plane along the z axis of
a viewing system. When object description is converted to projection
un
coordinates (x, y, z), each pixel position on the view plane is specified
by x and y coordinate, and z values gives the depth information. Thus,
object depths can be compared by comparing the z- values.
m
164
6. For example, among three surfaces, surface S1 has the smallest depth
at view position (x, y) and the highest z value. So, it is visible at that
position.
.in
Algorithm:
1. Initialize the Z-buffer and frame buffer so that for all buffer positions
z-buffer(x,y)=0 and Frame-buffer(x,y)=Ibackground
es
2. During scan conversion process, for each position on each polygon
surface, compare depth values to previously stored values in the depth
buffer to determine visibility.
ot
z-buffer(x,y)=z,
Frame-buffer(x,y)= Isurface(x,y).
m
4. Stop.
(After processing of all surfaces, the z-buffer contains depth values
for the
visible surfaces and the frame buffer contain the corresponding
intensity
values for those surfaces.)
Advantages:
1. It is easy to implement
2. It can be implemented in hardware to overcome the speed problem.
3. Since the algorithm processes objects one at a time, the total number
of polygons in a picture can be arbitrarily large.
165
Disadvantages:
1. It requires an additional buffer and hence the large memory.
2. It is time consuming process as it requires comparison for each pixel
instead of for the entire polygon.
.in
3. Inside or Contained Polygon – One that is completely inside the area.
4. Outside or Disjoint Polygon- One that is completely outside the area.
es
ot
un
1. If all the polygons are disjoint from the area, then the background
colour is displayed in the area.
2. If there is only one intersecting or only one contained polygon, then
the area is first filled with background colour, and then the part of the
polygon contained in the area is filled with colour of polygon.
3. If there is a single surrounding polygon, but no intersecting or
contained polygons, then the area is filled with the colour of the
surrounding polygon.
4. If there are more than one polygon intersecting, contained in, or
surrounding the area then we must do some more processing.
Fig a) The four intersections of surrounding polygon are all closer to the
viewpoint than any of the other intersections. Therefore, the entire area is
filled with the colour of the surrounding polygon.
166
b) That surrounding polygon is not completely in front of the intersecting
polygon.
The Warnock’s algorithm stops subdivision of area only when the problem
is simplified or even area is only a single pixel.
Algorithm:
1. Initialize the area to be the whole screen.
2. Create the list of polygons by sorting them with their z-values of
vertices. Don’t include disjoint polygons in the list because they are
not visible.
3. Find the relationship of each polygon.
4. Perform the visibility decision test
a. If all the polygons are disjoint from the area, then fill area with
background colour.
b. If there is only one intersecting or only one contained polygon
then first fill entire area with background colour and then fill the
.in
part of the polygon contained in the area with the colour of
polygon.
c. If there is a single surrounding polygon, but no intersecting or
es
contained polygons, then fill the area with the colour of the
surrounding polygon.
d. If the surrounding polygon is closer to the viewpoint than all
ot
other polygons, so that all other polygons are hidden by it, fill the
area with the colour of the surrounding polygon.
un
5. If none of the above tests are true, then subdivide the area and go to
step 2.
Advantages:
1. It follows the divide-and-conquer strategy; therefore, parallel
computers can be used to speed up the process.
2. Extra memory buffer is not required.
.in
Process all the front nodes first and then the nodes at the back.
As shown in figure (c), we will first process the node B. As there is
nothing in front of the node B, we have put NIL. However, we have
es
node C at back of node B, so node C will go to the right side of
node B.
Repeat the same process for the node D.
ot
168
The algorithm begins by sorting by depth. For example, the initial
“depth” estimate of a polygon may be taken to be the closest z value
of any vertex of the polygon.
Let us take the polygon P at the end of the list. Consider all polygons
Q whose z-extents overlap P’s. Before drawing P, we make the
following tests. If any of the following tests is positive, then we can
assume P can be drawn before Q.
Do the x-extents not overlap?
Do the y-extents not overlap?
Is P entirely on the opposite side of Q’s plane from the viewpoint?
Is Q entirely on the same side of P’s plane as the viewpoint?
Do the projections of the polygons not overlap?
If all the tests fail, then we split either P or Q using the plane of the
other. The new cut polygons are inserting into the depth order and the
process continues. Theoretically, this partitioning could generate
O(n2) individual polygons, but in practice, the number of polygons is
much smaller.
.in
10.2.7 Visible-Surface Ray Tracing:
Ray tracing is an image-based algorithm. For every pixel in the image,
es
a ray is cast from the center of projection through that pixel and into
the scene. The colour of the pixel is set to the colour of the object that
is first encountered.
ot
un
m
169
10.4 SUMMARY
10.5 QUESTIONS
.in
Q7. Explain Painters algorithm.
Q8. Differentiate between Ray Casting and Ray Tracing.
Q9. Describe the methods used for determination of visible surfaces in
rendering.
es
Q10. Explain techniques for efficient Visible-Surface Algorithms.
ot
Q11. Explain Image Space Method.
Q12. Write a Short Note on Object Space Method.
un
10.6 REFERENCES
m
*****
170
11
PLANE CURVES AND SURFACES
Unit Structure
11.0 Objectives
11.1 Curve Representation
11.1.1 Nonparametric Curves, Parametric Curves
11.2 Parametric Representation of a Circle
11.3 Parametric Representation of an Ellipse
11.4 Parametric Representation of a Parabola
11.5 Parametric Representation of a Hyperbola
11.6 Representation of Space Curves
11.6.1 Bezier Curves
11.6.2 B-spline Curves
.in
11.6.3 B-spline Curve Subdivision
11.6.4 Parametric Cubic Curves
11.6.5 Quadric Surfaces
es
11.6.6 Bezier Surfaces.
11.7 Summary
11.8 Questions
ot
11.9 References
11.10 Multiple Choice Questions
un
11.0 OBJECTIVES
m
171
Implicit Curves:
Implicit curve representations define the set of points on a curve by
employing a procedure that can test to see if a point in on the curve.
Usually, an implicit curve is defined by an implicit function of the form –
f(x, y) = 0
It can represent multivalued curves (multiple y values for an x value). A
common example is the circle, whose implicit representation is
x2 + y2 - R2 = 0
Explicit Curves:
A mathematical function y = f(x) can be plotted as a curve. Such a
function is the explicit representation of the curve. The explicit
representation is not general, since it cannot represent vertical lines and is
also single-valued. For each value of x, only a single value of y is
normally computed by the function.
Parametric Curves:
Curves having parametric form are called parametric curves. The explicit
.in
and implicit curve representations can be used only when the function is
known. In practice the parametric curves are used. A two-dimensional
parametric curve has the following form −
es
P(t) = f(t), g(t) or P(t) = x(t), y(t)
The functions f and g become the (x, y) coordinates of any point on the
curve, and the points are obtained when the parameter t is varied over a
ot
certain interval [a, b], normally [0, 1].
un
An ellipse can be defined as the locus of all the points that satisfy the
equations:
X= acos t y = bsin t
172
Where x, y are the coordinates of any point on the ellipse, a, b are the
radius on the x and y axes respectively, t is the parameter which ranges
from 0 to 2𝜋 radians.
describe the ellipse as (x/rx)2 +(y/ry)2 =1
Parametrically we describe an ellipse like this:
x(t’) = rx . cos(t’)
y(t’) = ry . sin(t’)
0 ≤ t ≤ 2π
.in
Where, 0 ≤ 𝑡 < 2𝑥
173
The parametric equations of a translated ellipse with center at (𝑥0𝑦0)
The parametric equations of a translated ellipse with center (𝑥0𝑦0) and
semi-axes a and b,
𝑥 = 𝑥0 + 𝑎 cos 𝑡
𝑦 = 𝑦0 + 𝑏 sin 𝑡
Where, 0 ≤ 𝑡 < 2𝜋
To convert the above parametric equations into Cartesian co-ordinates, we
write them as
𝑥 − 𝑥0 = 𝑎 𝑐𝑜𝑠 𝑡
𝑦 − 𝑦0 = 𝑏 sin 𝑡
And divide the first equation by a and second by b, then square and add
both equations, so we get
( ) ( )
+ =1
.in
es
ot
un
174
Since every parabola is congruent to x2 = 4ay, for some choice of a> o, we
can study the geometry of every parabola by confining ourselves to this
one. This shows the power of both coordinate geometry and
transformations. Imagine a particle moving in the plane along the curve C
as shown.
The x- and y- coordinate of the particle can be thought of as functions of a
new variable t, and so we can write x=f(t) , y=g(t), where f, g are functions
of t. t is time.
The equations x= f(t), y = g(t) are called the parametric equations of the
point P(x,y) and the variable t is called a parameter.
It is often very useful to take a Cartesian equation y= F(x) and introduce a
parameter t so that the x and y – coordinates of any point on the curve can
be expressed In terms of this parameter.
.in
A hyperbola centred at the origin with a left-right opening has the
equation:
(x2/a2) - (y2/b2) =1
es
In this case, we can use the equations x= a sec t, y= b tan t. This is because
if you plug these expressions in to the above equation, then the equation
reduces to the trigonometric identity sec2 t – tan2 t =1
ot
Hyperbola centred at the origin with an up-down opening has the equation:
(y2/a2) - (x2/b2) =1
un
In this case, switch the expressions for x and y, using the equations
X= b tan t, y= a sec t.
m
If the center of the hyperbola is at (h, k), then the equation is:
((x-h)2/a2) - ((y-k)2/b2) =1 or ((y-k)2/a2) - ((x-h)2/b2) =1
In the first case, the parametric equation x- h _a sec t, y= K + b tan t will
work, and in the second case it will be x-h + b tan t, y=k +a sec t.
.in
Figure 1: Bezier Curves
The degree of the polynomial defining the curve segment is one less
that the number of defining polygon point. Therefore, for 4 control
points, the degree of the polynomial is 3, i.e. cubic polynomial.
A Bezier curve generally follows the shape of the defining polygon.
m
The direction of the tangent vector at the end points is same as that of
the vector determined by first and last segments.
The convex hull property for a Bezier curve ensures that the
polynomial smoothly follows the control points.
No straight line intersects a Bezier curve more times than it intersects
its control polygon.
They are invariant under an affine transformation.
Bezier curves exhibit global control means moving a control point
alters the shape of the whole curve.
A given Bezier curve can be subdivided at a point t=t0 into two Bezier
segments which join at the point corresponding to the parameter value
t=t0.
176
11.6.3. Applications of Bezier Curves:
Bezier curves have their applications in the following fields-
1. Computer Graphics:
Bezier curves are widely used in computer graphics to model smooth
curves.
The curve is completely contained in the convex hull of its control
points.
So, the points can be graphically displayed & used to manipulate the
curve intuitively.
2. Animation:
Bezier curves are used to outline movement in animation applications
such as Adobe Flash and synfig.
Users outline the wanted path in bezier curves.
The application creates the needed frames for the object to move
along the path.
.in
For 3D animation, bezier curves are often used to define 3D paths as
well as 2D curves. es
3. Fonts:
True type fonts use composite bezier curves composed of quadratic bezier
curves.
ot
Modern imaging systems like postscript, asymptote etc use composite
bezier curves composed of cubic bezier curves for drawing curved
shapes.
un
Solution: We have-
The given curve is defined by 4 control points.
So, the given curve is a cubic bezier curve.
The parametric equation for a cubic bezier curve is-
P(t) = B0(1-t)3 + B13t(1-t)2 + B23t2(1-t) + B3t3
Substituting the control points B0, B1, B2 and B3, we get-
P(t) = [1 0](1-t)3 + [3 3]3t(1-t)2 + [6 3]3t2(1-t) + [8 1]t3 ……..(1)
Now,
To get 5 points lying on the curve, assume any 5 values of t lying in the
range 0 <= t <= 1.
Let 5 values of t are 0, 0.2, 0.5, 0.7, 1
For t = 0:
Substituting t=0 in (1), we get-
P(0) = [1 0](1-0)3 + [3 3]3(0)(1-t)2 + [6 3]3(0)2(1-0) + [8 1](0)3
177
P(0) = [1 0] + 0 + 0 + 0
P(0) = [1 0]
For t = 0.2:
.in
P(0.5) = [1 0](1-0.5)3 + [3 3]3(0.5)(1-0.5)2 + [6 3]3(0.5)2(1-0.5) + [8
1](0.5)3
P(0.5) = [1 0](0.5)3 + [3 3]3(0.5)(0.5)2 + [6 3]3(0.5)2(0.5) + [8 1](0.5)3
es
P(0.5) = [1 0] x 0.125 + [3 3] x 3 x 0.5 x 0.25 + [6 3] x 3 x 0.25 x 0.5 + [8
1] x 0.125
P(0.5) = [1 0] x 0.125 + [3 3] x 0.375 + [6 3] x 0.375 + [8 1] x 0.125
ot
P(0.5) = [0.125 0] + [1.125 1.125] + [2.25 1.125] + [1 0.125]
P(0.5) = [4.5 2.375]
un
For t = 0.7:
.in
First, the number of specified polygon vertices fixes the order of the
resulting polynomial which defines the curve.
The second limiting characteristic is that the value of the blending
es
function is nonzero for all parameter values over the entire curve.
The B-spline basis contains the Bernstein basis as the special case. The B-
spline basis is non-global.
ot
.in
The curve exhibits the variation diminishing property.
The curve generally follows the shape of defining polygon.
Any affine transformation can be applied to the curve by applying it
es
to the vertices of defining polygon.
The curve line within the convex hull of its defining polygon
ot
11.6.3 B-Spline Curve Subdivision :
Subdivision “Subdivision defines a smooth curve or surface as the limit of
a sequence of successive refinements”
un
spline forms.
180
.in
es
ot
181
Examples of quadratic surfaces include the cone, cylinder, ellipsoid,
elliptic cone, elliptic cylinder, hyperbolic cylinder, hyperbolic paraboloid,
paraboloid, sphere and spheroid.
.in
graphics, computer-aided design, and finite element modeling.
Bezier surface are an extension of the idea of Bezier curves and share
many of their properties.
es
Bezier surface is defined by a set of control points.
Properties are-
ot
o the surface does not in general pass through the control points (except
for the corner points)
o the surface is contained within the convex hull of the control points.
un
is the binomial
coefficient.
Some properties of Bézier surfaces:
A Bézier surface will transform in the same way as its control points
under all linear transformations and translations.
182
All u = constant and v = constant lines in the (u, v) space, and all four
edges of the deformed (u, v) unit square are Bézier curves.
A Bézier surface will lie completely within the convex hull of its
control points, and therefore also completely within the bounding
box of its control points in any given Cartesian coordinate system.
The points in the patch corresponding to the corners of the deformed
unit square coincide with four of the control points.
However, a Bézier surface does not generally pass through its other
control points.
.in
Figure 6: Bézier surface
Sample Bézier surface; red - control points, blue - control grid, black -
surface approximation
es
11.7 SUMMARY
ot
When we view a picture containing non-transparent objects and surfaces,
then we cannot see those objects from view which are behind from objects
closer to eye. We must remove these hidden surfaces to get a realistic
un
11.8 QUESTIONS
183
11.9 REFERENCES
1. Computer Graphics Hearn, Baker Pearson Education Second
2. Steve Marschner, Peter Shirley Fundamentals of Computer Graphics
CRC press Fourth Edition 2016.
3. A P Godse, Computer Graphics.
.in
a. Frame buffer removal
b. Hidden line removal
c. Rendering
d. Animation
es
3. ______________ is fast and effective as an initial screening to
eliminate many polygons from further visibility tests.
ot
a. Back-face detection
b. Painter’s algorithm
un
c. Z-buffer algorithm
d. Area Sub-division algorithm
4. The _________ is particularly useful when the view reference point
changes, but the objects in a scene are at fixed positions.
m
a. BSP Tree
b. Back-face
c. Painter’s algorithm
d. Z-buffer algorithm
5. ______ method successively divides the total viewing area into
smaller and smaller rectangles until each small area is the projection
of part of a single visible surface or no surface at all.
a. Area-subdivision method
b. Back-face
c. Painter’s algorithm
d. Z-buffer algorithm
6. Which o the following method is not a image space method?
a. Back-face Detection
b. Z Buffer Algorithm
184
c. Scan line algorithm
d. Ray Tracing
7. Most visible-surface detection algorithms use sorting and __________
methods to improve performance.
a. Coherence
b. Object-Space
c. Polygon Clipping
d. Dept information
8. Visible Surface Detection Method is also called as _____________.
a. Hidden-Surface elimination method
b. Hidden- Surface Identification Method
c. Hidden-Surface Detection Method
d. VSD
9. Z-buffer algorithm uses 2 buffer, depth buffer for storing depth values
and _________ buffer stores intensity values at each pixel position.
a. Refresh
.in
b. Intensity
c. Color
d. Depth
es
10. ________ curves must precisely have n control points.
a. Bezier
b. B-Spline
ot
c. Curved
d. Parametric
un
*****
m
185
UNIT V
12
COMPUTER ANIMATION
Unit Structure
12.0 Objectives
12.1 Introduction
12.2 Definition
12.3 Principles of Animation
12.3.1 Squash and Stretch
12.3.2 Anticipation
12.3.3 Staging
.in
12.3.4 Straight Ahead Action and Pose to Pose
12.3.5 Follow Through and Overlapping Action
12.3.6 Ease In and Ease Out
12.3.7 Arc
es
12.3.8 Secondary Action
12.3.9 Timing
ot
12.3.10 Exaggeration
12.3.11 Solid drawing
un
12.3.12 Appeal
12.4 Key Frame Animation
12.5 Deformation
m
12.0 OBJECTIVES
12.1 INTRODUCTION
12.2 DEFINITION
.in
Computer animation may be defined as a technique in which the
illusion of a movement is created by displaying on a screen or
es
recording on device individual states of a dynamic scene.
Any computer animation sequence may be defined as a set of objects.
It is characterized by state variables evolving over time or it is a time
ot
187
12.3 PRINCIPLES OF ANIMATION
.in
If the length of a ball is stretched vertically, its width (in three
dimensions and also its depth) needs to contract correspondingly
horizontally.
es
ot
un
12.3.2 ANTICIPATION :
Anticipation is used to prepare the audience for an action.
m
188
12.3.3 STAGING :
Its purpose is to direct the audience's attention.
This makes it clear that what is of greatest importance in a scene.
Johnston and Thomas defined it as "the presentation of any idea so that
it is completely and unmistakably clear", whether that idea is an action,
a personality, an expression or a mood.
This can be done by various means such as the placement of a character
in the frame, the use of light and shadow or the angle and position of
the camera.
The essence of this principle is keeping focus on what is relevant.
.in
es
12.3.4 STRAIGHT AHEAD ACTION AND POSE TO POSE :
ot
These are two different approaches to the actual drawing process.
"Straight ahead action" scenes are animated frame by frame from
beginning to end.
un
189
12.3.5 FOLLOW THROUGH AND OVERLAPPING ACTION :
.in
character stopped only to be subsequently "pulled back towards
the center of mass or exhibiting various degrees of oscillation damping.
"Overlapping action" is the tendency for parts of the body to move at
es
different rates example an arm will move on different timing of the
head and so on.
A third related technique is "drag" where a character starts to move and
ot
parts of him take a few frames to catch up.
These parts can be inanimate objects like clothing or the antenna on a
car or parts of the body, such as arms or hair.
un
m
The movement of the human body and most other objects needs time to
accelerate and slow down.
For this reason, animation looks more realistic.
It has more drawings near the beginning and end of an action,
emphasizing the extreme poses and fewer in the middle.
190
This principle goes for characters moving between two extreme poses
for example sitting down and standing up but also for inanimate
moving objects like the bouncing ball.
12.3.7 ARC:
.in
moving ahead and broaden in turns.
An object in motion that moves out of its natural arc for no apparent
reason will appear erratic rather than fluid.
es
For example, when animating a pointing finger, the animator should be
certain that in all drawings in between the two extreme poses the
fingertip follows a logical arc from one extreme to the next.
ot
un
m
Adding secondary actions to the main action gives a scene more life.
It can help to support the main action.
A person walking can simultaneously swing their arms or keep them in
their pockets, speak or whistle or express emotions through facial
expressions.
The important thing about secondary actions is that they emphasize
rather than take attention away from the main action.
191
For example during a dramatic movement, facial expressions will often
go unnoticed.
In these cases it is better to include them at the beginning and the end
of the movement rather than during.
12.3.9 TIMING:
.in
Correct timing makes objects appear to obey the laws of physics.
Example an object's weight determines how it reacts to an impetus like
a push.
es
Timing is critical for establishing a character's mood, emotion and
reaction.
ot
It can also be a device to communicate aspects of a character's
personality.
un
m
12.3.10 EXAGGERATION:
192
The classical definition of exaggeration employed by Disney was to
remain true to reality just presenting it in a wilder and in more extreme
form.
If a scene contains several elements, there should be a balance in how
those elements are exaggerated in relation to each other.
This is to avoid confusing or overawing the viewer.
.in
The principle of solid drawing means taking into account forms in
three-dimensional space or giving them volume and weight.
The animator needs to be a skilled artist.
es
He has to understand the basics of three-dimensional shapes, anatomy,
weight, balance, light and shadow etc.
ot
un
12.3.12 APPEAL:
m
193
12.4 KEY-FRAME ANIMATION
.in
behavior of a model manually by using an intuitive the “put that there”
methodology.
The animator has full and direct control over the positions, shapes and
es
motions of models during the animation.
There are two fundamental approaches to a key-frame:
1. In-betweens are obtained by shape interpolation.
ot
12.5 DEFORMATION
194
It guarantees high quality deformations by minimizing physically
inspired energies subject to user controlled constraints.
Physically-plausible deformations are achieved by a constrained
minimization of stretching (center) or bending (right) energies.
In deformations on a very large model user deforms the shape using
reduced model.
.in
es
ot
un
195
12.7 PHYSICS BASED ANIMATION
.in
Here the animator states are in terms of constraints and the properties
the model is supposed to have without needing to adjust parameters.
es
12.8 PROCEDURAL TECHNIQUES
In computer and video games it is often used for simple things like
turning a character's head when a player looks around.
The procedural techniques correspond to the creation of a motion by a
procedure by describing the motion.
Rules are established for a system and an initial state is defined for
objects in the system.
The procedural technique can be very useful for generating much life-
like motion from relatively little input.
Such an animation should be used when the motion can be described by
an algorithm or a formula.
The generation of a motion using a procedure is not really a method but
more a framework.
196
There are so many possibilities of expressing a motion using a
procedure or a law.
The number of all possible algorithms is unlimited.
Procedural approaches can suffer from a lack of explicit control over
the look of individual frames.
.in
behave like one object.
If you want to ungroup the objects, click on ungroup option.
es
There is also another way of grouping the objects called as drawing a
marquee.
Example in PowerPoint you can animate the group of objects such as
ot
clip arts, shapes and pictures.
This helps to draw audience attention to specific content or to make it
easier to read.
un
12.10 SUMMARY
m
197
12.11 EXERCISE
12.12 REFERENCES
12.13 BIBLIOGRAPHY
.in
1. D. Hearn and M. P. Baker, Computer Graphics, 2nd Edition, 1997.
2. J. Hughes, A. Van Dam, M. MCGuire, D. Sklar, J. Foley, and K.
es
Akeley, Computer Graphics, Principles and Practice, 3rd Edition,
Pearson, 2014.
3. P. Shirley and S. Marschner, “Fundamentals of Computer Graphics:
ot
Ray Tracing,” CRC Press. p. 752, 2009.
un
m
*****
198
UNIT V
13
IMAGE MANIPULATION AND STORAGE
Unit Structure
13.0 Objectives
13.1 Introduction
13.2 What is an Image?
13.2.1 Image Types
13.3 Digital Image File Formats
13.4 Image Compression
13.4.1 Image Compression Standard-JPEG
13.5 Image processing
.in
13.5.1 Digital Image Enhancement
13.5.2 Contrast Stretching
13.5.3 Histogram
es
13.5.3.1 Histogram Equalization
13.5.4 Filtering
13.5.4.1 Smoothing
ot
13.5.4.1.1 Low Pass Averaging Filter
13.5.4.1.2 Low Pass Median Filter
13.6 Summary
un
13.7 References
13.8 Bibliography
13.9 Exercise
m
13.0 OBJECTIVES
199
13.1 INTRODUCTION
.in
Images obtained through a camera are 2-dimensional.
Hence image can be defined as a two-dimensional function, f(x, y)
where x and y are spatial coordinates and the amplitude of f at any pair
es
of coordinates (x, y) is called the intensity or grey level of the image at
that point.
When x, y and the intensity values of f are all finite discrete quantities
ot
we say the image is a digital image.
A digital image is composed of a finite number of elements, each of
which has a particular location and value.
un
Pixel is the term used most widely to denote the elements of a digital
image.
As we discuss earlier vision is the most advanced of our senses,
therefore images play the single most important role in human
perception system.
Fig.13.2.1
200
In 2-dimension image we lose one dimension.
Depth information is lost in this moving process from 3-dimension
object to 2-dimension image as shown in Fig.13.2.1.
Photographs on identity card, all family pictures etc. are example of 2-
dimensional image.
FIG 13.2.2
.in
es
ot
FIG 13.2.3 FIG 13.2.4
In Fig.13.2.2, to locate the pixel we need to know its position in the two
directions x and y.
un
Here (x, y) are spatial coordinates and f is grey level (colour in case of
colour images) at that point.
Therefore all the images we see are 2–dimensional function.
m
201
Fig. 13.2.1.1 Fig. 13.2.1.2
(1) Monochrome Image:
In this type of image, each pixel is stored as a single bit 0 or 1.
These images are also called as bit mapped image or binary image.
Here 0 represent black and 1 represent white.
It is also called as black and white image.
In this image we have black and white pixels and no shades of grey
.in
as shown in Fig. 13.2.1.1 and Fig. 13.2.1.2.
202
Hence each pixel is represented by 24-bits[R (8 bits), G (8
bits),B(8 bits)].
Colour images can be easily converted to grey scale image using
the equation,
X = 0.30R+0.59G+0.13B … (13.2.1.1)
Easier formula to achieve same result as follows,
X = R+G+B/3 … (13.2.1.2)
.in
1. BMP (Bit Mapped Graphic Image)
1. BMP:
m
2. JPEG:
Joint Photographic Expert Group is the name of committee that
developed this JPEG image format which is used in compression
algorithms.
JPEG images are compressed images which occupy very little space.
203
It is based on the Discrete Cosine Transform-DCT.
JPEG images use lossy compression algorithms which result in some
loss of original data.
The quality of JPEG images is not as good as BMP images.
3. TIFF:
Most well-known formats were developed in 1986.
A TIFF format is also a data compression technique for monochrome as
well as colour images.
Images seen on the Internet sites are normally TIFF/GIF images simply
because they occupy less space.
4. EPS:
It is file format of the post script page description language and is
device in dependent.
.in
This means that images can readily be transferred from one application
to another.
However EPS image scan only be printed in script compatible printers.
es
5. GIF:
ot
Uses a form of Huffman coding.
Used in Internet images
un
6. PICT:
It is a general purpose format supported by Macintosh and used for
storing bit-mapped images.
7. PNG:
It is lossless image format.
To improve and replace the GIF format, PNG image format was
designed.
The image file shows organisation of information encoded that consists
of two parts:
1. Header 2. Image data.
204
Fig.13.3.1
Header: The header file gives us the information about the kind of
.in
image.
Format: The header file identifies the format as binary code or ASCII
string.
es
Width and Height: The width and height of the image are given in
number of pixels.
Common image types: binary images, 8-bit greyscale images, 8-bit
ot
colour and 24-bit colour images.
Image data format: It specifies the order in which pixel values are
un
stored in the image data section. Order used is left to right and top to
bottom.
Image data format also specifies if the RGB values in the image are
m
205
1. PGM (Portable Grey Map): Represent grey level image.
2. PBM (Portable Bit Map): Represent binary images.
3. PPM (Portable Pixel Map):Represent colour images.
.in
1. Coding redundancy. 2. Interpixel redundancy. 3.Pyschovisual
redundancy.
Data compression is achieved when one or more of these redundancies
es
are eliminated.
In image compression based on methodologies, there are two types of
ot
compression as follows:
Lossy compression: Part of original data is discarded permanently to
reduce file size. After decompression original data cannot be retrieved
un
back.
Advantage: No degradation of quality.
Lossless compression: Original data is not changed permanently
m
.in
Fig.13.4.1.1
13.5 IMAGE PROCESSING
es
Image Processing is a subject which basically studies the images and
manipulation of images by computer.
ot
It involves processing the images that are obtained by camera.
With the beginning of computers, image processing grew rapidly as a
subject.
un
Fig.13.5.1
Therefore we start processing the images the day we are born and
continue till we die.
Hence image processing is integral part of us.
.in
An another important trait that is common to all human being is to
store the information, analyse it, discuss it with others and try to make
it better.
es
13.5.1 DIGITAL IMAGE ENHANCEMENT:
Image enhancement is the next step after image acquisition in
ot
fundamental image processing.
There are many improvisation methods to manipulate an images
and the result is more suitable than the original image.
un
208
Fig: 13.5.1.1
1. Spatial Domain:
Spatial domain means working in the given space.
It implies working with the pixels values of an image.
.in
Assume f(x, y) is original image. Here f is grey value and (x, y) are
image coordinate.
For 1 byte image f values range from 0-255, where 0 represent black,
es
255 represent white and all intermediate values represent shades of
grey.
The modified image can be expressed as,
ot
g (x, y) = T [f(x, y)]
Where g (x, y) is modified image.
un
2. Frequency Domain:
Frequency domain means working with the frequencies value of
an image.
Frequency domain techniques are the study of working in the
Fourier domain.
Example: 1D-Fourier transforms, 2D-Fourier transform, 1D-DFT
and 2D-DFT etc.
.in
es
Fig. 13.5.2.1
In figure dotted line indicate identity transformation and solid
line indicate contrast stretching transformation.
ot
Here the dark grey levels are made darker by assigning slope
value less than one and bright grey levels are made brighter by
assigning slope value greater than one.
un
210
Fig. 13.5.2.2 Fig. 13.5.2.3
13.5.3 HISTOGRAM:
Histogram of images provides a global description of the
appearance of an image.
The information obtained from histograms is enormous.
Histogram of an image represents the relative frequency of
occurrence of the various grey levels in an image.
.in
Histogram of an image can be plotted in two ways.
In the first method, the x-axis has the grey levels and the y-axis has the
number of pixels in each grey level.
es
In the second method, the x-axis represents the grey levels, while the y-
axis represents the probability of the occurrence of that grey level.
ot
un
m
Method 1
Method 2
211
In method 2,
P (rk) = nk / n
rkkth grey level
nk Number of pixel in the k th grey level
n Total number of pixel in an image
.in
The transformation we are looking for must satisfy the following two
conditions:
1. T( r ) must be single valued and monotonically increasing in the
interval 0 <= r <= 1.
es
2. 0 <= T( r ) <= 1 for 0 <= r <= 1 i.e. 0 <= s <= 1 for 0 <= r <= 1 .
Here range of r is [0, 1].This is called normalized range.
ot
un
m
.in
Fig.13.5.4.2 shown is called filter, mask, window or a
template. es
Mask can be 3 x 3, 5 x 5, 7 x 7 and so on.
To process image we place mask on image, multiply each
component of mask with corresponding value of image, add
ot
them up and place the calculated value at center.
Consider f(x, y) is the original image and g(x, y) is modified
un
image then,
g(x,y)=w1*f(x-1,y-1)+w2*f(x-1,y)+w3*f(x-1,y+1)+w4*f(x,y-1)
m
+w5*f(x, y)+w6*f(x,y+1)+w7*f(x+1,y-1)+w8*f(x+1,y)
+w9*f(x+1,y+1)
Once g(x, y) is calculated we shift the mask by one step
towards the right to the next pixel.
One of the important operations of neighbourhood
processing is image filtering.
In filtering we remove the noise from the image.
In most images, the background is considered to be low
frequency regions and edges are considered to be high
frequency region.
13.5.4.1 SMOOTHING:
Smoothing is also called as low pass filtering.
Smoothing implies removing or blurring the edges.
213
Smoothing is used to remove noise present in the image.
Noise is normally high frequency component and low pass
filtering removes these high frequency components.
Here we are going to study smoothing in two ways: Low Pass
Averaging Filter and Median Filter.
.in
es
ot
.
Fig.13.5.4.1.1.1
Let us take the 3 x 3 average masks shown in Fig.13.5.4.1.1.1 on
un
g(x, y)=1*10+1*10+1*10+1*10+1*10+1*10+1*10+1*10+1*10/9
=10+10+10+10+10+10+10+10+10/9
=90/9
=10
Next shift the mask toward right till we reach end of line, perform
214
same step of calculation as explain above and then move it
downwards.
Some of calculation of mask position is shown below.
.in
es
ot
un
m
215
Once we get final result you can observe that the low frequency
region has remained unchanged. Hence we can conclude that
sharp edge has become blur.
The sharp edge between 10 and 50 has become blurred.
We can see from grey level 10 it changes to 23.3(after rounding
off its 23), from 23 it changes to 36.6(after rounding off its 36)
.in
and finally from 36 it changes to 50.
will blur noise but at same time it will also ruin the edges.
Therefore we need to work with non-linear filter.
Such non-linear filter is called as Median filter.
m
Low pass median filter removes the salt and pepper noise from
the image
They are also called as order statistic filters because their
response is based on ranking of the pixels contained within the
mask.
Consider using the mask similar to averaging filter except that
the mask will contain no values.
The step to perform median filtering is as follows:
1. Assume 3 x 3 empty mask.
2. Place the empty mask at top left hand corner of given pseudo
image.
3. Arrange all nine pixels inside mask in ascending or
216
descending order.
4. Choose the median value from these nine pixels and place at
center.
5. Move the mask in similar fashion as done in averaging filter.
Consider the 8 x 8 pseudo image with salt and pepper noise given
below.
We need to remove noise without disturbing the edges.
Place the empty mask at top left hand corner.
Arrange the nine pixels of image inside mask either in ascending
or descending order as given below.
10 10 10 10 10 10 10 10 250
The median is value placed at fifth position. Therefore this value
is placed at the center.
Continue this procedure until all salt and pepper noise get
.in
replaced by median value.
es
ot
un
m
Hence we get the final result as salt and pepper noise got eliminated
without distortion of edges.
217
13.6 SUMMARY
13.7 REFERENCES
.in
• Digital Image Processing (Using Matlab Codes) by Dhananjay K.
Theckedath.
es
13.8 BIBLIOGRAPHY
ot
13.9 EXERCISE
m
*****
218