Unit 1
Unit 1
Unit 1
(UNIT 1)
UNIT- II
Clipping Algorithms, Sutherland-Cohen line Clipping Algorithm
Bezier Curves, B-Spline Curves. Parallel Projection, Perspective
Projection, Illumination Model for diffused Reflection, Ambient light,
Specular Reflection Model, Reflection Vector.
2
Computer Graphics & Multimedia (ETCS-211)
UNIT- III
Shading Models, Flat shading, Gourard Shading, Phong Model.
Visible surface detection, Back Face Detection, Depth Buffer (Z-
Buffer, A-Buffer) Method. Overview of multimedia: Classification,
basic concepts of sound/audio MIDI: devices, messages, software,
Authoring tools, Video and Animation: controlling animation, display
and transmission of animation
UNIT -IV
Data Compression: storage space, coding requirements, Basic
compression techniques: run length code, Huffman code, Lempel-Ziv
JPEG: Image preparation, Lossy sequential DCT, expanded lossy
DCT, Lossless mode, Hierarchical mode. MPEG, Media
synchronization, Media Integration, Production Standards.
3
Computer Graphics & Multimedia (ETCS-211)
Text Books:
[T1] Donald Hearn and M.Pauline Baker, “Computer Graphics C version”,
Second Edition, Pearson Education.
[T2] Ralf Steinmetz & Klara Nahrstedt, “Multimedia Computing Communication &
Applications”, Pearson Education.
Reference Books:
[R1] C, Foley, VanDam, Feiner and Hughes, “Computer Graphics Principles &
practice”, 2nd Edition
[R2] R. Plastock and G. Kalley, Schaum’s Series, “Theory and Problems of
Computer Graphics”, McGraw Hill, 2nd edition.
[R3] Fred Halsall, “Multimedia Communications Applications, Networks, Protocols
& Standards”, Pearson Education.
[R4] David F. Rogers, “Procedural elements for computer graphics”, McGraw- Hill.
4
Learning objectives of Lecture-1
5
What is Computer graphics ?
Images that are generated by a computer are called computer
graphics. Examples are photographs, drawings, line art, graphs,
diagrams. Graphics often combine text, illustration, and colour. In other
words we can say that
It is the creation and manipulation of graphic images by means of a
computer.
Computer graphics started as a technique to enhance the display of
information generated by a computer.
This ability to interpret and represent numerical data in pictures has
significantly increased the computer’s ability to present information
to the user in a clear and understandable form.
Large amount of data are rapidly converted into bar charts, pie
charts, and graphs.
6
Typical graphics system comprises of a host
computer with support of graphical devices and fast
processor, large memory, frame buffer, display
devices (color monitors), input devices (mouse,
keyboard, joystick, touch screen, trackball etc.),
output devices (LCD panels, laser printers, color
printers. Plotters etc.) and other interfacing devices
such as, video I/O, TV interface etc.
7
Four major areas of Computer Graphics are:
(i) Display of information,
(ii) Design/Modeling,
(iii) Simulation and
(iv) User Interface.
8
Types of Computer Graphics
Two Types of Computer Graphics:
1. Interactive Graphics
2. Non-Interactive/ Passive Graphics
Interactive Computer Graphics
-It involves two way communication between computer and
user.
-User is given control over the image by providing an input
device that takes the user request to the computer.
-Example: Flight simulator used to train pilots.
Advantages: Fuel saving, safety.
Another example is video game controller.
9
2. Non-Interactive Graphics / Passive Graphics
-In this type of computer graphics, user has no
control over the images.
-Images are displayed with the help of a static stored
program and according to the instructions that are
written in the program. Example: screensavers.
10
Why is computer graphics important?
• The importance of computer graphics lies in its applications.
11
Applications of Computer Graphics
✔ Computer Aided Design (CAD)
✔Entertainment (animation, games, etc.)
✔ Computer Art
✔ Presentation Graphics
✔ Education and Training
✔ Geographic Information Systems (GIS)
✔ Visualization (Scientific Vis., Inform. Vis.)
✔ Medical Visualization
✔ Image Processing
✔ Graphical User Interfaces
12
Typical applications areas:
• GUI’s,
• Plotting in business,
• Plotting in science and technology,
• Scientific Visualization
• Office automation
• Desktop publishing,
• Web/business/commercial publishing and advertisements,
• Simulation studies,
• Simulators
• Multimedia,
• Entertainment (movie, TV, Advt. Etc. )
• Virtual reality
13
Contd.....
• Medical imaging is another application where computer
graphics has proven valuable. Recent advances in imaging
technology such as magnetic resonance imaging allow
physicians to take 3D X-rays of the human body.
Interactive computer graphics allows the physician to
interpret this large volume of data in new and useful ways.
14
Certain compilers, such as, Visual C/C++, Visual Basic,
Borland C/C++, Borland Pascal, Turbo C, Turbo
Pascal, Gnu C/C++, Java provide their own graphical
libraries, API, support and help for programming 2-
D/3-D graphics.
15
What are Graphics Primitives?
• In graphics, primitives are basic elements, such as lines,
circle, curves, and polygons, which can be combined to
create more complex graphical images.
16
Differences between 2D Shapes and 3D Shapes:
Mathematical
X-axes, Y-axes. X-axes, Y-axes and Z-axes.
Axes used
2D shapes are used to give simple 3D shapes are used to give
View
view of an object. architectural view of an object.
In 2D shapes, all the edges are In 3D shapes, some of the edges are
Edges visible
clearly visible. hidden.
2D shapes are easy to explain due to In 3D shapes, only outer dimensions
Explanation
the visibility of all its edges. can be explained.
It is easy to draw details in 2D Detailing becomes difficult in 3d
Detailing
shapes. shapes.
Circle, Square, Rectangle or any
Examples Cylinder, Prism, tube, Cuboid, etc.
other polygon, etc.
17
Pixel (picture element)
A pixel is the smallest piece of information in an
image.
▪ Pixels are normally arranged in a regular 2D grid, and
are often represented using dots or squares.
18
Pixel (picture element)
▪ Each pixel is a sample of an original image, where
more samples typically provide a more accurate
representation of the original.
▪ The intensity of each pixel is variable; in color
systems, each pixel has typically three or four
components such as red, green, and blue, or cyan,
magenta, yellow, and black.
19
Five elements for Computer Graphics System
20
Components of Interactive Computer Graphics System
21
Graphics Devices
• Input Devices
• Display devices
The Input Devices are the hardware that is used to transfer
input to the computer. The data can be in the form of text,
graphics, sound, and text. Output device display data from the
memory of the computer. Output can be text, numeric data,
line, polygon, and other objects.
22
These I/P Devices include:
• Keyboard
• Mouse
• Trackball
• Spaceball
• Joystick
• Light Pen
• Digitizer
• Touch Panels
• Voice Recognition
• Image Scanner
23
24
25
26
27
Display Devices
29
CRT- Cathode Ray Tube & How IT Works In Computer Graphics
30
31
Refresh CRT
Vertical
Focusing
deflecting
system Phosphor
plates
Base coated
screen
Electron
Electron beam
gun Horizontal
Connector
deflecting
Pins
plates
• In Raster scan display the electron beam is swept across the screen one row
at a time from top to bottom.
•Raster: A rectangular array of points or dots
•Pixel: One dot or picture element of the raster. Its intensity range for pixels
depends on capability of the system
•Scan line: A row of pixels
•Picture elements are stored in a memory called frame buffer
•A special memory is used to store the image with scan-out synchronous to
the raster. We call this the frame buffer
Disadvantage
Raster system produces jagged lines that are plotted as discrete points
46
Random scan systems
Random scan systems
In these systems, the refresh buffer does not store
the intensity values of the picture, but a set of line
drawing commands.
Refresh buffer is also called display file.
The system cycles through the set of commands in
the display file to display a picture.
Refresh rate in random scan systems is 30 to 40 times
per second.
Important Properties of
Display Devices
1. Resolution
Resolution of a display device is defined as the number of
pixels on the entire screen of the device.
For example, 1024 X 768 resolution means,
The screen has 1024 pixels in each line and
The screen has 768 horizontal lines.
2. Persistence
It is the property of phosphor that is how long they continue to
emit light.
Persistence is defined as the time it takes the emitted light to
decay to one-tenth of its original intensity.
Computer monitors have persistence of 10-60 microseconds.
Lower persistence phosphor requires higher refresh rates to
maintain a picture on the screen without flicker.
Color CRT Monitors
2 Basic
Techniques
for Color
Display
Beam
Shadow Mask
Penetration
Method
Method
51
Beam-Penetration Method
•Used with random scan monitors
•The screen has two layers of phosphor: usually red and
green
•The displayed color depends on how far the electron beam
penetrates through the two layers.
•A beam of slow electrons excites only the outer of the
red layer, a beam of fast electrons penetrates through
the red layer and excites the inner green layer, and at
intermediate beam speeds, combinations of the two
colors are emitted to show other colors (yellow &
orange)
52
Beam-Penetration Method
53
Beam-Penetration Method
54
Shadow-Mask Method cont..
•The Shadow mask is known as the delta-delta shadow-mask.
•The 3 electron beams are deflected and focused as a group onto
the shadow mask, which contains a series of holes aligned with
the phosphor-dot patterns.
•The 3 beams pass through a hole in the shadow mask and
activate a dot triangle, which appears as a small color spot on the
screen.
55
Shadow-Mask Method
– Used with raster scan monitors
– Three electron guns
– A metal shadow mask to differentiate the beams
56
Shadow-Mask Method cont..
57
58
Controlling Colors in Shadow mask
•Different colors can be obtained by varying the intensity levels
of the three electron beams.
•Example: Simply turning off the red and green guns, we get
only the color coming from the blue phosphor.
61
DDA LINE DRAWING ALGORITHMS
62
DDA LINE DRAWING ALGORITHMS
63
DDA LINE DRAWING ALGORITHMS
64
DDA LINE DRAWING ALGORITHMS
65
Example:-
Calculate the points between the starting point (5, 6) and ending point (8,
12).
Solution-
Given-
Starting coordinates = (X0, Y0) = (5, 6)
Ending coordinates = (Xn, Yn) = (8, 12)
Step-01:
Calculate ΔX, ΔY and M from the given input.
ΔX = Xn – X0 = 8 – 5 = 3
ΔY =Yn – Y0 = 12 – 6 = 6
M = ΔY / ΔX = 6 / 3 = 2
Step-02:
Calculate the number of steps.
As |ΔX| < |ΔY| = 3 < 6, so number of steps = ΔY = 6
CGM Lab : Experiment 2 DDA 66
Step-03:
As M > 1, so case-03 is satisfied.
Now, Step-03 is executed until Step-04 is satisfied.
5 6 5.5 7 (6, 7)
6 8 (6, 8)
6.5 9 (7, 9)
7 10 (7, 10)
8 12 (8, 12)
69
DDA LINE DRAWING ALGORITHMS
70
MAIT, CSE, CGM, UNIT 1 DDA LINE DRAWING ALGORITHMS 71
Experiment – 3
Digital Differential Analyzer Algorithm
Digital differential analyzer (DDA) is used for linear interpolation of variables over an interval between given start, end points and
for rasterization of lines, triangles and polygons. Using DDA Algorithm, Write a C-Program to draw a line segment between two
given points?
Aim: To implement DDA Algorithm for drawing a line segment between two given end points A (x1, y1) and B(x2, y2).
Algorithm:
1. Start.
2. Declare variables x,y,x1,y1,x2,y2,k,dx,dy,s,xi,yi and also declare gdriver=DETECT, mode.
3. Initialize the graphic mode with the path location in TurboC3 folder.
4. Input the two line end-points and store the left end-points in (x1,y1).
5. Load (x1, y1) into the frame buffer; that is, plot the first point. put x=x1,y=y1.
6. Calculate dx=x2-x1 and dy=y2-y1.
7. If abs (dx) > abs (dy), do s=abs(dx).
8. Otherwise s= abs(dy).
9. Then xi=dx/s and yi=dy/s.
10. Start from k=0 and continuing till k<s,the points will be
i. x=x+xi.
ii.Y=y+yi.
11. Plot pixels using putpixel at points (x,y) in specified colour.
12. Close Graph and stop.
Step-01:
Calculate ΔX, ΔY and M from the given input.
These parameters are calculated as-
ΔX = Xn – X0
ΔY =Yn – Y0
M = ΔY / ΔX
76
Bresemhan's line algorithm
77
Bresemhan's line algorithm
78
Bresemhan's line algorithm
79
Bresemhan's line algorithm
80
Bresemhan's line algorithm
81
82
83
84
Scan Conversion
Output Primitives
• Basic geometric structures used to describe scenes.
• Can be grouped into more complex structures
• Example : Point, straight line segments, circles and other conic
sections, polygon color areas and character strings
• Construct the vector picture
Rasterization
The process of determining the appropriate pixels for representing
picture or graphic object
Scan conversion
It is the final step of rasterization . It converts picture definition into a
set of pixel-intensity values for storage in the frame buffer.
x1 x2
x x
1 2
– Slope > 1 y
• Unit y interval = 1 2
y
1
x x
1 2
– Slope > 1 y
• Unit y interval = 1 1
y
2
– -1 <= Slope < 0
• Unit x interval = -1 x x
1 2
– Slope > 1 y
• Unit y interval = 1 1
1. START
2. Get the values of the starting and ending co-ordinates i.e. ,(xa,ya)
and (xb,yb).
3. Find the value of slope m
m=dy/dx=((yb-ya)/(xb-xa))
4. If ImI ≤ 1 then Δx=1,Δy=mΔx
xk+1=xk+1,yk+1=yk+m
5. If ImI ≥ 1 then Δy=1,Δx=Δy/m
xk+1=xk+1/m,yk+1=yk+1
6. STOP
Desired line
(xi+1,round(yi+m))
(xi,yi) (xi+1,yi+m)
(xi,round(yi))
Y_inc
X_inc
Solution:
P(1,1) => x1 = 1, y1= 1
Q(5,9) => x2 = 5, y2 = 9
Now, lets discuss why we go for a max here, because we want to draw line
as accurate as possible and accuracy can be given by more no of points.
114
Q-4Raster images are more commonly called
a. Pix map
b. bitmap
c. both a & b
d. none of these
Q-5. Pixel can be arranged in a regular
a. One dimensional grid
b. Two dimensional grid
c. Three dimensional grid
d. None of these
Q-6. The brightness of each pixel is
a. Compatible
b. Incompatible
c. Both a & b
d. None of these
Q-7. Each pixel has ________basic color components
a. Two or three
b. One or two
c. Three or four
d. None of these
115
Architecture of a Graphics System
The components of a raster system contains display
processor, display-processor memory, frame buffer, video
controller, and input/output devices.
116
Display Processor
Purpose: frees the CPU from the graphics routine
task.
Major task: digitizes a picture definition given in an
application program into a set of pixel values for
storage in the frame buffer.
This digitization process is called scan conversion.
Straight lines and other geometric objects are scan
converted into a set of discrete points, corresponding
to screen pixel locations.
117
Display Processor
Characters can be defined with rectangular pixel grids,or
they can be defined with outline shapes. The array size
for character grids can vary from about 5x7 to 9x12 or
more for higher quality displays.
118
Display Processor
A character grid is displayed by superimposing the
rectangular grid pattern into the frame buffer at a
specified coordinate position.
119
Frame Buffer
Each screen pixel corresponds to a particular entry in a 2D
array residing in memory. This memory is called a frame
buffer or a bit map.
The number of rows in the frame buffer equals to the
number of raster lines on the display screen.
The number of columns in this array equals to the number
of pixels on each raster line.
The term pixel is also used to describe the row and
the column location in the frame buffer array that
corresponds to the screen location. A 512x512 display
screen requires 262144 pixel memory locations.
120
Frame Buffer
Whenever we wish to display a pixel on the screen,
a specific value is placed into the corresponding
memory location in the frame buffer array.
Each screen pixel’s location and corresponding
memory’s location in the frame buffer is accessed by
nonnegative integer coordinate pair (x, y).
The x value refers to the column, the y value to
the row position.
121
Frame Buffer
The origin of this coordinate system is positioned
at the bottom-left corner of the screen or it is
positioned at the upper-left corner of the screen.
122
Video controller
Video controller is used to control the operation of the
display device (Monitor/Screen). Video controller
accesses the frame buffer to refresh the screen. In figure,
the basic refresh operations of the video-controller are
shown.
123
Video controller
Two registers are used to store the coordinates of
the screen pixels.
Initially, the x register is set to 0 and the y
register is set to the value for the top scan line.
The contents of the frame buffer at this pixel
position are then retrieved and used to set the
intensity of the CRT beam.
Then the x register is incremented by 1, and the
process is repeated for the next pixel on the top
scan line.
124
Video controller
This procedure is continued for each pixel along the
top scan line.
After the last pixel on the top scan line has been
processed, the x register is reset to 0 and the y
register is set to the value for the next scan line
down from the top of the screen.
Pixels along this scan line are then processed in
turn, and the procedure is repeated for each
successive scan line.
125
Video controller
After cycling through all pixels along the bottom
scan line (y=0), the video controller resets the
registers to the first pixels position on the top scan
line and the refresh process starts over.
The screen must be refreshed at a rate of at least
60 frames per second.
126
Input and Output Devices
The user of an interactive graphics system
communicates with the graphics program by means
of input devices such as keyboard, mouse,
joystick, light pen, graphics tablet (digitizer),
touch panels, voice systems, and scanners.
Typically, the primary output device in a graphics
system is a video monitor such as Cathode Ray
Tube (CRT) and Liquid Crystal Display (LCD). We
can obtain hard-copy output for our images in
several formats for presentations or archiving. Hard
copy devices include slides film, printers, and
plotters.
127
Computer display standard
Various computer display standards or display
modes have been used in the history of the
personal computer.
They are often a combination of
Display resolution: specified as the width and
height in pixels,
Color depth: measured in bits, and
Refresh rate: expressed in hertz.
128
Computer display standard
A computer image is usually represented as a
discrete grid of pixels.
The number of pixels determines the resolution of
the image. Typical resolutions range from
320x200 to 2000x1500
The color depth: is the number of distinct colors
that can be represented by a pixel depends on the
number of bits per pixel (bpp).
A 1 bpp image uses 1 bit for each pixel, so each
pixel can be either on or off.
129
Computer display standard
Each additional bit doubles the number of colors available,
so a 2 bpp image can have 4 colors, and a 3 bpp image can
have 8 colors:
▪ 1 bpp, 21 = 2 colors (monochrome) black and white
▪ 2 bpp, 22 = 4 colors
▪ 3 bpp, 23 = 8 colors
▪...
▪ 8 bpp, 28 = 256 colors
▪ 16 bpp, 216 = 65,536 colors (Highcolor )
▪ 24 bpp, 224 ≈ 16.7 million colors (Truecolor)
130
Computer display standard
For color depths of 15 or more bits per pixel, the
depth is normally the sum of the bits allocated to
each of the red, green, and blue components(RGB).
Highcolor, usually meaning 16 bpp, normally has
five bits for red and blue, and six bits for green,
as the human eye is more sensitive to errors in
green than in the other two primary colors.
131
Computer display standard
For applications involving transparency, the 16
bits may be divided into five bits each of red,
green, and blue, with one bit left for transparency.
A 24-bit depth allows 8 bits per component.
On some systems, 32-bit depth is available: this
means that each 24-bit pixel has an extra 8 bits to
describe its opacity (for purposes of combining
with another image).
132
Q-1. Raster Graphics Are Composed Of
a) Paths
b) Palette
c) Pixels
d) None Of These
Ans-pixels
133
Q-4. The Brightness Of Each Pixel Is
a) Compatible
b) Incompatible
c) Both A & B
d) None Of These
Ans- Incompatible
134