0 ratings0% found this document useful (0 votes) 830 views135 pagesInsight On Computer Graphics
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
mao eci th TU, PU, PoU, KU
Insights on
COMPUTER
GRAPHICSInsights on
COMPUTER GRAPHICS
cr la
Published by
writen by
Edited by
Copyright ©:
First edition
SYSTEM INCEPTION
Er. Shree Krishna Sulu
Er Swian Shrestha
Publisher
All rights reserved. This book, is sold subject to the
condition that it shall not, by way of trade or otherwise,
be lent, resold, hired out, or otherwise circulated
without the authors prior written consent in any form of
binding or cover other than that in which i is published
‘nd without a similar condition including this condition
‘being imposed on the subsequent purchaser and without
limiting the rights under copyright reserved above, no
‘part ofthis publication may be reproduced, stored in or
fntroduced into a retrieval system, or transmitted in any
form or by aay means (electronic, “mechanical
photocopying, recording or otherwise), without the prior
‘written permission ofthe copyright ovmer ofthe book:
£2019. AD
‘Second edition : 2020 AD
Computer
ae
Creation Graphies
* Baghazar, Kathmandu
PREFACE TO THE SEC N
“Insights on Computer Graphics" is 2 textbook of
computer graphics for the students of Bachelor level in
Electronics and Communication, and Computer|
Engineering. Computer graphics is widely used in almost all
aspects of the life; entertainment to medical treatment, ar
and commerce to office automation, business visualization
to scientific research, computer aided design to virtual
reality. And, the daily use of smart mobile, ta, laptop,
digital display, smart TV, ete. is tremendously increasing.
So, the study and field of computer graphics is widening day
by day. The concept and principle of computer graphics
systems have been explained step by step in this book in
‘order to make easier to understand.
‘A large number of numerical of previous IOE exam
‘questions have been solved to develop an efficient
‘understanding ofthe related topics. The Code in C of some
‘algorithms is also depicted to make clear about the
programming in Computer Graphics.
| would like to thank those teachers and students (especially
Shyam Dabal and Shiva Ram Sulu) whose inspiration
assisted mein bringing this book.
With the hope, students and concemed person will be
benefited, I pray for @ prosperous and peaceful Nepal
Er. Shree Krishna Sulu
Feb, 2020TT a ™
CONTENTS 46 Two-Dimensional Viewing. a
3.7 Coordinate Representation, 94
om 3.8 The Viewing Pipeline. ss
se GaeINTRODUCTION AND APPLICATION —___ SE ee eee ec eee
ransformation 8
4 rose | 3.10 Clipping Operations os
13 Vestor Graphics E
14 Computer Graphics and Image Processing. ; "THREE-DIMENSIONAL TRANSFORMATIONS
15 History of Computer Graphics 5 “i Three-Dimensional Transformations as
1.6 Uses of Computer Graphics. rs :
1.7. Genera Tem and Terminologies A a PaRu SEIT
1.8 Hardware Concepts G
niga Feap a Cokes may Teen “ Sa Spline Representations. 161
1.10. Raster and Random (Vector) Sean Display = oo Secon nd
Fils cits cerhisiens, 2 53. Besier Cures : m
54 Bespline Curve Le
1.12 Raster Sean Display System/ Architecture! Technology 29
1.13 Random Sean Syteny/Architecture/Technology. 2 om
1.14 Flat Panel Displays. 3 ‘SURFACE MODELING
‘1 Three Dimensional Object Representations. 186
ome 62 Polygon Suress . 1
SCANCONVERSION, 63 Polygon Table sl
21 Outpt Prive nn 38 64 Plane Equations 189
22 Line-Dawing Algorithm... 38
23 Cite on . s4 oma
cae eo ‘VISIBLE SURFACE DETERMINATION
23 Filled Are Primitive. . 6s 7A Yi Sure Dcminton en Sree =
72 Back-Face Detection 194
‘TWO-DIMENSIONAL TRANSFORMATIONS 73, Depth-Buffer Method (Z-Buffer). 196
UGE MES ce 14 Autor Method 199
32 9 15. Scan-Line Meth. 200
a3 8
a4 7
33 88
i aSRE ion AND SURFACE RENDERING METHOD
om
4:1 lamination Models and Surface Rendering Teshnigoe.....209
82 Light Source 205
43. Bas mination Modes... 207
84 Surfs Rendering Mths. z 215
INTRODUCTION TO OPENGL
91 Tarodction. ma
92. OpenGL Libraries. ns
93° OpenGL Progam Stcture 6
94 OpenGL Geometc Primitives 26
95 Color Command 40
96 OpexGL Viewing... 2a
97 Lighting in Open. 207
Introduction and Application
Introduction
Graphics is an image or a visual representation of an object
and the visual representation or image displayed on a computer
sereen is known as computer graphics. More precisely, computer
_gaphics isthe field or branch of science and technology related to
{generation (creation), storage and manipulation of graphics
(images or pictures) of objects using computer ie. using hardware
and software. Objects may be the concrete real world objects or the
abstract and synthetic objects such as mathematical surface,
engineering structure, architectural design, survey results, etc. In
cotter word, graphics means to plot some points on graph to make
an image. Computer graphics means to plot some pixels (points) on
‘computer screen to make an image. Pixel or picture element is
the elementary part of the computer screen. We see every day the
‘mages created by using computer in books, magazines, movies,
TV.et.
Computer graphics is the rendering (servicing or making)
tools for the generation and manipulation of images. These tools
‘include both hardware and software
Hardware comprises monitor, printer, plotter (that display
eraphics) and input devices includes mouse, light pen, keyboard,
scanner, ete. Software tools refer to the collection of graphics
routine
Compuier graphics Data structure + Graphics algorithm
+ Language
Data stracture means those data structure tht are suitable for
computer graphics. Graphics algorithm refers to algorithm for
picture geeraton and transformation. Language means high level
language for generation of grapies or pctres of objects
Computer sraphics canbe either two-dimensional o three-
dimensional. Digital graphic files are divided into two categories:
Introduction and Application |i. Raster graphics
fi, Veetr graphics
1.2 Raster Graphics
‘Araster graphic or image is made up of pixels (screen
point), Raster graphics are composed of a simple grid of pixel
‘The pixel can be of different color. Raster graphics are rendered
mages on a pixel-by-pixel basis and they are well fit when
bundling shading and gradients. A raster graphic, such as a pif or
jpeg isan array of pixels of various colors, which together form an
image. Raster graphics are the most common and are used for
digital photos, web graphics, icons, and other types of images.
‘When a raster image is scaled up, it usually loses quality. A
raster image can be enlarged by cither adding more pixels or
enlarging the size ofthe pixel. In either way original data is spread
‘vera larger area atthe risk to losing elarty
Raster graphics based file format:
4ipg Joint Photographic Experts Group (JPEG)
‘pag Portable Network Graphies (PNG)
if Graphics Interchange Format (GIF)
{iff Tagged Image File Format (TIFF)
psd Adobe Photoshop File
pat Corel Paint File
pdf Portable Document Format (PDF)
e
raster vector b
mmmene “Raster Vector
@ o
Figure L.1: Raster and vector graphics
7 nsihts on Computer Graphics
Advantages of raster graphics
Every pixel in a raster image can be of different color
therefore we can create a complex image with any kind of color
changes and variations. Rasergraphies are useful for crating rich
and detailed images.
‘Almost any program can work with a simple raster fil. The
ost recognized application that handles raster graphics is Adobe
Photoshop however there are also several other image editing
software options out thereto choose from.
Disadvantages of raster graphics
Tt looks grainy, distorted, and blurted when raster images are
scaled up. This is because raster images are created with a finite
‘numberof pixels. When we increase the size ofa raster image, the
{mage will increase in size. However, because there are no longer
‘enough pixels to fill n this larger space, gaps are created between
the pixels in the image
Raster images hold more data and may be slower fo edit
Raster files are often quite large. Raster files contain all the
information for every single pixel of the image. Each of these
pixels has an X and Y coordinates as well as color information
ssociated with it Therefore, raster graphics files tend to be very
large.
Raster graphics are not great for embroidery. Because raster
images are based on square pixels, the embroidery may ook lke it
has jagged edges. If we want to embroider an image with smoother
cidges, it is best to use vector graphics instead of raster graphics.
3 Vector Graphics
‘Vector graphics (also ealled geometric modeling or object
oriented graphics) is made up of geometrical primitives such as
points, lines, curves, and polygons which are all based upon
Thathematical equations to represent images in computer graphics
‘A vector graphie can be sealed to any size without losing quality
‘Vector graphics are composed of paths which may be lines,
shapes, levers, or other sealable objects. vector graphic, such as
Introduction and Application 13
ee—
an eps le or Adobe stator il, is composed of paths or tne,
anh either straight or curved. The datafile fora vector image
sprains the points where the pats start and end, how much the
paths curve, and the colors that either border of fill the paths.
Vector graphics are not made of pixels, the images can be scaled to
tbe very large without losing quality. They are often used for
creating logos, signs, and other types of drawings. Unlike raster
‘graphics, vector graphics can be scaled to a larger size without
josing quality. Raster image's dimensions are measured in pixels
(pixel per inch-ppi). Vector graphics ae resolution independent.
‘The most recognized applications which handle vector based
‘graphics are Adobe illustrator, Macro media freehand and Corel
‘draw, Vector graphics are generally used for line art, illustrations,
and embroidery.
|All modem current computer video displays translate vector
representation of an image to a raster format. The raster image,
containing a value for every pixel on the screen, is stored in memory.
Probably the most common example of vector-based files
that we use daily without even realizing is font files.
‘Vector graphics based file format:
eps Encapsulated PostScript File (EPS)
‘svg_ Scalable Vector Graphics (SVG)
ai Adobe Illustrator File
cede Corel Draw File
ipdf Portable Document Format (PDF)
‘Advantages of vector graphics:
‘Vector files are small because they contain a fot less data
than raster files. Vector graphics are more flexible than raster
graphics because they can be easily scaled up and down without
‘any loss to the quality ofthe image. Vector graphics have smoother
lines in comparison to raster graphics.
Disadvantages of vector graphics:
If there are small errors or faults in a vector graphic, these
will be seen when the vector image is enlarged significantly.
‘Vector graphics can’t display the abundant color depth of a raster
graphic.
14 Computer Graphics and Image Processing.
‘The difference between computer graphics and image
essing can be studied with the help of following table.
‘Computer graphics Image processing
Hit is the field related to the. It applies technique to
‘generation of pictures using) modify or interpret existing
‘computers. pictures.
Ia. It synthesizes pictures from|2. It analyzes picture to derive}
mathematical or geometrical] description in mathematical
models. or geometrical forms.
(5, It includes the creation|3. It is the part of compute,
storage, and manipulation off graphics that handles image|
images of objects ‘manipulation of
interpretation
[g, Eg, drawing apicture [4 Eg, making blurred image
visible
Pictures | Computer Graphics | Mathematical
Drawing | * ‘or Geometrical
a Image Processing, | Movs
‘igure 1.2: Computer graphies and image processing
15. History of Computer Graphics
7a 1950s outputs. were via teletype, line printer and
‘Cathode Ray Tube (CRT). Using dark and light character,
pictures were reproduced
© An 1950, Been Laposky created the first graphic images on
‘oscilloscope generated by an electronic (analog) machine.
‘The image was produced by manipulating cleetronics beams
In 1951, UNIVACA, the first general purpose commercial
computer, cride hardcopy devices, and line printer were
‘invented. MIT-whirlwind computer, the first to display real
time video and capable of displaying real time text and
lraphic ona large oscilloscope sereen was developed.
“FT nsights on Computer Graphics
Tntroduction and Application |Sauc optics wes ng. Cups
a ers ad ere BAPDCS, Bi te
ee ot nt cob Of chine.
middle 1950s SAGE (Semi-Automatic Ground
tees rion was Svcd.
es comand wd cool CRT Gal costes on
which operator identifies target, with light pen (hand —held
Tang ds tat sees ih nied by bjs on
screen)
<0, Wil Fetes ined he comps gps
describe new design methods.
+96, Soe Ruel made ses wa, fe vidGomputr
=
+I, Dogs Eng dvlped fiat mouse an
{Set mde sch pd nteeive CG Spc a
Sucoggohecoomuncaton stem, ere
fepap enh conti tse ving, eel
dig ln pon inenton
+ te decom he dogging, rbter antag and
‘wansforming algorithms, He introduced data structures for
‘toring. He is considered data founded of computer graphics.
+ A186 on eed econ nae! oF
eloped lite drawing algorithm.
cial CRT, the direct view
‘mouse, a simple computer
‘graphics affordable,
eloped area subdivision
pioneering effons that showed the utility of graphical
interaction in the interactive design cycles common in
engineering
‘A numberof commercial producs using these systems were
appeared. But hardware was expensive
© In the early 1970, Output stat using raster displays,
‘raphics capability was stil arly chunky
1n 1972, Nolan kay Bushnell Pong made video arcade game.
In 1973, John whitiney Jr. and Gary Demos made
“Westworld, rst film with computer graphics
‘© In 1974, Edwin catmT developed texture mapping and 2-
buffer hidden surface algorithm. James Blim developed
curved surfaces, refinement of texture mapping.
‘181971, Rendering model Gouraud shading was developed.
* In 1974 — 77, Phong shading (rendering model) was
developed.
‘+ _In 1977, Steve Wozmak made Apple I, color graphics
personal computer
‘+ In the 19805, outputs were builtin raster graphic, bitmap
image and pixel, personal computers cost. decrease
drastically, rack ball and mouse became the standard
erative devices. .
1980s, Anists and graphic designers prefered to use
Macintosh and PCs.
‘+ Inlate 1980's, Artists and graphic designers prefered to use
Macintosh and PC.
+ 11982, Ray tracing (Ilumination based rendering method)
was developed. In 1982, Steven Lisbergsr made “Tron ist
Disney movie which made extensive use of 3-D computer
‘graphics. John Walkner and Dan Drake developed Auto
cAD
* In 1983, Jaron Lanier made ‘Data Glove", a virtual reality
film features a glove installed with switches and sensors of
‘detection hand motion
ane EE Se
Introduction and Application |7«In 1984, Wave from tech developed Polhemus,
graphics software
4+ In 1987, IBM introduced VGA( Video Graphics Array)
‘sIn 1989, Video Electonics Standard Association (VESA)
fommed SVGA (Super VGA)
‘+ In 1990%, since the introduction of VGA and SVGA
personal computer could easily display photo realistic
images and movies 3D image rendering were become the
sain advances and it stimulated cinematic graphics
aplication.
‘+ In 19905, since the intoduetion of VGA and SVGA,
personal computer could casily display photo realistic
images and movies. 3D image rendering were become the
main advances and it stimulated cinematic graphics
applications.
* An 1950, Render man system that provides fast accumulate
and high quality digital computer effects was developed
‘* In 1992, Silicon graphic developed open GL specification.
In 1993, Mossi first graphic web browser and Jurassic
par, a sucessful CG fiction film was made
Jn 1995, "Toy story, first full length computer generated
{feature film was made
ist 3D.
Computer
vided design and drafting
‘Scientific and business visualization
Entertainment
. Art and commerce
Civil Engineering applications
10. Medical applications
.Imtemet
User Interfaces
4,
s.
6. Simulation and virtual reality
1
8
9.
‘The interface between the human and the computer has been
radically changed by the use of computer graphics. Most
applications have a Graphical User Interface (GUI) for user
friendly and interactive operation, Today's software has user
interfaces that rely on the desktop window systems to
‘manage multiple simultaneous activities and on point and
click facilities to select items menu, icon, and objects on the
Plotting or visualization of measurement data
Graphics is extensively used in plotting 2D and 3D graphs
Such as the histograms, bar and pie charts, the task
‘scheduling charts of mathematical, physical, and economic
functions. These plotting or visualization of measurement
data are useful to analyze meaningfully and concisely the
‘end and pattern of complex data
Office automation and electronic publishing
Nowadays, the necessary document that contains text, tables,
Bsraphs, drawings, pictures can be easily printed or saved az
lectronic (softcopy) document. ‘The office automation and
lectronic publishing became possible by the development of
‘computer graphics,
systems (including building
architectural systems, mechani