CG Chapter1
CG Chapter1
Graphics Primitives 1 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Introduction
Graphics Primitives 2 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
(Loading)
Graphics Primitives 3 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Graphics Primitives 4 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Frame Buffer
A block of memory dedicated to graphics output, that holds the
contents of what will be displayed on the raster display.
Raster-is a Rectangular array of points or dots or pixels.
It acts as a temporary store of the image
It also acts as a decoupler to allow the graphics processor and the
display controller to operate at different speeds
Display Controller
Reads the buffer contents row by row and display them on the
display device.
It is responsible for generating the timing of video signals such as
the horizontal & vertical synchronization signals and the
blanking interval signal.
Graphics Primitives 5 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Display Devices
Graphics Primitives 6 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Display Device
Graphics Primitives 7 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Graphics Primitives 8 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
A single bit plane (1bit/pixel) Black & White frame buffer raster
Graphics Primitives 9 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Graphics Primitives 10 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Graphics Primitives 11 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Primary Colors
Graphics Primitives 12 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
1.How much memory is needed for a 1024 x 1024 raster display using
true color frame buffer?
2.If each pixel has different color how many colors will be on the
screen?
Graphics Primitives 13 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Solution
1 True color frame buffer(24 bit per pixel)
⇒ 1 pixel = 24 bit of memory and also
⇒ Resolution= 1024 x 1024
Resolution: The maximum number of points that can be displayed
without overlap on a CRT.
Then, the size of frame buffer = Resolution x bits per pixel
= (1024 x 1024) x 24 bits
= 3MB (∵ 1M=1024 x 1024 bits and 3B=24 bits)
2 If each pixel has different color:
∴ #colors on the screen = #pixels of the screen
(i.e. 1024x1024 ≈ 1 million colors).
Graphics Primitives 14 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Graphics Primitives 15 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
CLUT
As shown in the above figure each 256 entries contains a 24 bit RGB
color value.
Using lookup table would allow a user to select any 256 colors for
simultaneous display from a palette of nearly 17 million colors.
For most applications, 256 or 512 different colors are sufficient for a
single picture.
- This scheme reduces the number of simultaneous colors that can
be displayed.
But table entries can be changed at any time.
+ It reduces the frame buffer storage requirements from 3MB to
1MB + 768 Bytes.
Graphics Primitives 16 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Display Monitor
Graphics Primitives 17 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
CRT
Electron gun: heated to send out electron’s.
Electron beam strikes each and every pixel position in a scan line
fashion.
Control grid: control intensity value of electron beams by setting
voltage levels.
Focusing electrod: force electron beam to (narrow) converge
inorder to strike the phosphorus coating at small spot.
Horizontal deflection plates: control the beams to scan from left
to right and retrace from right to left.
Vertical deflection plate: control the beams to go vertically.
The control circuits shut off the electron beam during the
horizontal and vertical retraces.
Graphics Primitives 19 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Graphics Primitives 18 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Retracing
Horizontal Retrace: The return to the left of the screen, after
refreshing each scan line.
Vertical Retrace: The return to the top left corner of the screen to
begin the next frame.
Graphics Primitives 20 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Refresh rate
Refresh rate: is the frequancy at which the content of frame buffer
is sent to the display monitor, w/c is normally 60 to 80 frames/sec.
Flicker is a visible fading between cycles displayed on video displays,
especially in the refresh interval on cathode ray tube (CRT)
To avoid flickering some monitors use interlacing technique (double
their refresh rate).
In this case, First the odd numbered lines(pass 1), then the even
numbered lines(pass 2) are refreshed.
This works best when the adjacent scan lines contain similar display
information.
Ex. What is the fraction of the total refresh time per frame spent in
retrace of the electron beam for a noninterlaced raster system with a
resolution of 1280 by 1024, a refresh rate of 60 Hz, a horizontal retrace
time of 5µsec, and a vertical retrace time of 500µsec?
Graphics Primitives 21 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Color Display
Graphics Primitives 22 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Color Display
Graphics Primitives 23 / 44
OverView of Graphics Systems Output Primitivies Introduction Applications Video Display Devices
Graphics Primitives 24 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Point Plotting
Point: is the unit of a graphical picture.
Picture in raster scan): is the set of intensities of the pixel
positions in display.
How the electron beam is positioned depends on the display
technology.
Point Plotting: with a CRT monitor electron beam turned on to
illuminate the screen phosphorus at the selected point or position.
A Random scan system stores point-plotting instructions in the
display list, and coordinate values in these instructions are converted
to deflection voltages that position the electron beam at the screen
locations to be plotted.
Graphics Primitives 25 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Graphics Primitives 26 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Graphics Primitives 27 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Equation Method
Equation of a straight line: y=m.x+b
Algorithm:
1 Read (x1,y1) , (x2,y2)
2 Find the slope: m= yx22−−xy11
3 Fine y-intercept: b=y1 - m.x1
4 x ← x1
5 while ( x ≤ x2 )
y=m.x + b
setPixel(x,y)
x++
end while
The equation method involves floating point multiplication, which
doesn’t make it fact.
Graphics Primitives 28 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Graphics Primitives 29 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
DDA Algorithm:
DDA( xa , ya , xb , yb )
step 1. Δx ← xb - xa , Δy ← yb - ya
step 2. if (abs(Δx) > abs(Δy) )
steps ← Δx
else steps ← Δy
step 3. xinc ← steps
Δx
yinc ← steps
Δy
step 4. x ← xa and y ← ya
setPixel(x , y)
step 5. for k = 0 to steps
x ← x + xinc
y ← y + yinc
setPixel( Round(x) , Round(y) )
eg. Using DDA algorithm determine the intermidiate points of the line
which has end points at (2,5) and (10,9) .
Graphics Primitives 30 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Graphics Primitives 31 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Graphics Primitives 32 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
∴ If P k is -ve, choose the lower pixel, otherwise choose the upper pixel.
Graphics Primitives 33 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Evaluate Pk as follows:
P k = Δ x (dlower - dupper ) ⇒ Δx( 2 ΔΔ yx xk + 2 ΔΔ yx - 2yk + 2b - 1 )
⇒ 2Δy*xk + 2Δy - 2Δx*yk + 2Δx*b - Δx
Rearrange the terms to get:
P k = 2Δy*xk - 2Δx*yk + C where C = 2Δy + Δx(2b - 1)
This C remains constant regardless of choice of x and y.
Here, It still requires a complete evaluation of P(k) for each point
along the line. so, P k+1 = 2Δy*xk+1 - 2Δx*yk+1 + C
By evaluating an incremental change in pk :
P k+1 - P k = 2Δy(xk+1 - xk ) - 2Δx(yk+1 - yk ), but xk+1 = xk +1
So, P k+1 = P k + 2Δy - 2Δx(yk+1 - yk )
where yk+1 - yk is either 0 or 1 depending on the sign of pk
pk + 2 Δ y, if P k < 0
pk +1 =
pk + 2 Δ y − 2 Δ x, otherwise
Graphics Primitives 34 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Graphics Primitives 35 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Graphics Primitives 36 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Δx = 0 , Δy = 0 and Δ x = Δy
Assignment 1
Graphics Primitives 37 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Properties of Circle
Circle: is set of points @a given distance from central position
( xc = a , yc = b)
(x - xc )2 + (y - yc )2 = r2
Graphics Primitives 38 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Equation method
Calculate position of points on a circle by stepping along the x-axis
in unit steps from xc - r to xc + r and
Calculate the corresponding y value @each position as
q
y = yc ± r 2 − (x − xc )2
Problems:
It involves considerable computation at each step.
Moreover, the spacing between plotted pixel positions is not uniform.
To adjust the spacing, interchange the roles of x and y whenever the
absolute value of the slope of the circle is greater than 1.
But this increases the computation required by the algorithm.
Graphics Primitives 39 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Trignometric Method
Another way to eliminate the unequal spacing by calculate points
along the circular boundary using polar coordinates r and θ.
Graphics Primitives 40 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Graphics Primitives 41 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Decision Parameters pk
pk = fcircle (xk + 1 , yk - 12 ) ⇒ (xk + 1)2 + (yk - 12 )2 - r 2
Graphics Primitives 42 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
pk + 2x k +1 + 1, if pk < 0
pk +1 =
pk + 2xk +1 − 2yk +1 + 1, otherwise
Graphics Primitives 43 / 44
OverView of Graphics Systems Output Primitivies Points Lines Circle
Graphics Primitives 44 / 44