Beruflich Dokumente
Kultur Dokumente
Unit I
Veena Khandelwal
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 1 / 60
Outline
1 Computer Graphics Hardware
Video Display Devices
Refresh Cathode-Ray Tubes
Raster Scan Displays
Random Scan Displays
Raster Scan Display Processor
2 Output Primitives
Line Drawing Algorithms
Slope Intercept Line Drawing
DDA Algorithm
Bresenhams Line Algorithm
Circle Drawing Algorithm
Bresenhams Circle Algorithm
Midpoint Circle Algorithm
3 Region Filling
Boundary-Fill Algorithm
Flood-fill Algorithm
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 2 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 3 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 4 / 60
Computer Graphics Hardware Video Display Devices
5 In the vacuum inside the CRT envelope, the free, negatively charged
electrons are then accelerated toward the phosphor coating by a high
positive voltage generated with an accelerating anode.
6 Intensity of the electron beam is controlled by the voltage at the
control grid.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 5 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 6 / 60
Computer Graphics Hardware Video Display Devices
10 Spots of light are produced on the screen by the transfer of the CRT
beam energy to the phosphor. After a short time, the excited
phosphor electrons begin dropping back to their stable ground state,
giving up their extra energy.
11 Fluoresence: It refers to the light given off by a phosphor while it is
being exposed to an electron beam.
12 Phosphoresence: The term used to describe the light given off by a
phosphor after it has been exposed to an electron beam.
13 Different kinds of phosphors are available for use in CRTs. Besides
color, a major difference between phosphors is their persistence: how
long they continue to emit light (that is, how long it is before all
excited electrons have returned to the ground state) after the CRT
beam is removed.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 7 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 8 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 9 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 10 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 12 / 60
Computer Graphics Hardware Video Display Devices
11 On a black and white system with one bit per pixel, the frame buffer
is commonly called a bitmap.
12 For systems with multiple bits per pixel, the frame buffer is often
referred to as a pixmap.
13 Refreshing on raster-scan displays is carried out at the rate of 60 to
80 frames per second or cycles per second.
14 At the end of each scan line, the electron beam returns to the left
side of the screen to begin displaying the next scan line.
15 The return to the left of the screen, after refreshing each scan line is
called the horizontal retrace of the electon beam.
16 At the end of each frame the electrom beam returns (vertical retrace)
to the top left corner of the screen to begin the next frame.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 13 / 60
Computer Graphics Hardware Video Display Devices
17 A frame buffer has a size 1024x1024 with 12 bits per pixel. Compute
the time required to load it if transfer rate is 12 bits per second.
1024 × 1024 × 12
seconds.
12
Figure: Color Lookup table and Frame buffer
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 14 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 15 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 16 / 60
Computer Graphics Hardware Video Display Devices
23 Then after the vertical retrace, the beam sweeps out the remaining
scan lines.
24 Interlacing of scan lines in this way allows us to see the entire screen
displayed in one-half the time it would have taken to sweep across all
the lines at once from top to bottom.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 18 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 19 / 60
Computer Graphics Hardware Video Display Devices
Total time spent for retrace = 5120 + 500 = 5620 usec = 5.62 msec
The fraction of the total refresh time frame spent in retrace = 5.62
16.7 =
0.337
29 Suppose an RGB raster system is to be designed using an 8-inch by
10-inch screen with a resolution of 100 pixels per inch in each
direction. If we want to store 6 bits per pixel in the frame buffer, how
much storage (in bytes) do we need for the frame buffer?
The size of frame buffer is (8 x 100 x 10x 100 x 6)/ 8= 600000 bytes
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 21 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 22 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 23 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 24 / 60
Computer Graphics Hardware Video Display Devices
11 Also, vector displays produce smooth line drawings because the CRT
beam directly follows the line path. A raster system, by contrast,
produces jagged lines that are plotted as discrete point sets.
12 However, the greater flexibility and improved line-drawing capabilities
of raster systems have resulted in the abandonment of vector
technology.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 25 / 60
Computer Graphics Hardware Video Display Devices
1 The purpose of the display processor is to free the CPU from the
graphics chores. In addition to the system memory, a separate
display-processor memory area can be provided.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 26 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 27 / 60
Computer Graphics Hardware Video Display Devices
4 For instance, a line is defined by 2 end points and its line equation,
where as a circle is defined by its radius center position and the circle
equation. It is the responsibility of the graphics system or the
application program to convert each primitive from its geometric
definition into a set of pixels that make up the primitive in image
space. This conversion task is generally referred to as Scan
Conversion / Rasterization
5 Display processors are also designed to perform a number of
additional operations.These functions include generating various line
styles (dashed, dotted, or solid), displaying color areas, and applying
transformations to the objects in a scene. Also, display processors are
typically designed to interface with interactive input devices, such as
a mouse.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 28 / 60
Computer Graphics Hardware Video Display Devices
Character Generation I
Character Generation II
4 Outline Font: Describe character shapes using straight lines and curve
sections.(Post Script fonts). Require less storage since each variation
does not require a distinct font cache. We can produce boldface,
italic or different sizes by manipulating the curve definitions for the
character outlines. But it does take more time to process the outline
fonts, because they must be scan converted into the frame buffer.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 30 / 60
Computer Graphics Hardware Video Display Devices
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 31 / 60
Computer Graphics Hardware Video Display Devices
Coordinate Representation I
1 dx = x2 − x1
2 dy = y2 − y1
dy
3 m= dx
4 b = y1 − m × x1
5 Set x = x1, y = y 1
6 Set xend = x2
7 If x > xend stop
8 Plot a point at current (x, y ) coordinate.
9 Increment x = x + 1
10 Compute the next value of y from the equation y = mx + b
11 Goto step 6
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 33 / 60
Output Primitives Line Drawing Algorithms
DDA Algorithm I
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 34 / 60
Output Primitives Line Drawing Algorithms
DDA Algorithm II
5 For lines with a positive slope greater than 1.0, we reverse the roles of
x and y .That is,we sample at unit y intervals (δy = 1) and calculate
consecutive x values as xk+1 = xk + m1 . In this case, each computed
x value is rounded to the nearest pixel position along the current y
scan line.
6 If the starting endpoint is at the right, then either we have δx = −1
and yk+1 = yk − m or (when the slope is greater than 1) we have
δy = −1 with xk+1 = xk − m1
7 The DDA algorithm is a faster method for calculating pixel positions
than one that directly implements line equation y = mx + b.
8 It eliminates the multiplication in line equation by using raster
characteristics, so that appropriate increments are applied in the x or
y directions to step from one pixel position to another along the line
path.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 35 / 60
Output Primitives Line Drawing Algorithms
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 36 / 60
Output Primitives Line Drawing Algorithms
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 37 / 60
Output Primitives Line Drawing Algorithms
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 38 / 60
Output Primitives Line Drawing Algorithms
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 39 / 60
Output Primitives Line Drawing Algorithms
1 Once a pixel is chosen at any step, the next pixel is either the one to
its right (which constitutes a lower bound for the line) or the one to
its right and up (which constitutes an upper bound for the line) due
to the limit on m.
2 The line is best approximated by those pixels that fall the least
distance from its true path between P1‘ and P2‘ .
3 The coordinates of the last chosen pixel upon entering step i are
(xi , yi ). Our task is to choose the next one between the bottom pixel
S and the top pixel T. If S is chosen, we have xi+1 = xi + 1 and
yi+1 = yi . If T is chosen, we have xi+1 = xi + 1 and yi+1 = yi + 1 .
4 When s<t the closest pixel is S and when s>=t the closest pixel is T.
This difference is s − t = (y − yi ) − [(yi + 1) − y ]=2y − 2yi − 1.
5 The y coordinate on the mathematical line at pixel column position
xi + 1 is calculated as y = m(xi + 1) + b
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 40 / 60
Output Primitives Line Drawing Algorithms
1 x = x1, y = y 1
2 int dx = x2 − x1, dy = y 2 − y 1
3 dT = 2(dy − dx), dS = 2dy
4 int d = 2dy − dx
5 setpixel(x, y )
6 while(x < x2)
7 x ++
8 if (d < 0) d = d + dS
9 else y + + , d = d + dT
10 setpixel(x, y )
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 42 / 60
Output Primitives Line Drawing Algorithms
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 43 / 60
Output Primitives Circle Drawing Algorithm
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 44 / 60
Output Primitives Circle Drawing Algorithm
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 45 / 60
Output Primitives Circle Drawing Algorithm
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 46 / 60
Output Primitives Circle Drawing Algorithm
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 47 / 60
Output Primitives Circle Drawing Algorithm
1 int x = 0, y = r , d = 3 − 2r
2 while(x <= y )
3 setpixel(x, y )
4 x ++
5 if (d < 0) d = d + 4x + 6, y = y
6 else y − − , d = d + 4(x − y ) + 10
7 end while
8 (x=0, r=8), Values(x,y,d)=(0,8,-13), (1,8,-3), (2,8,11),
(3,7,5),(4,6,7), (5,5,17)
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 48 / 60
Output Primitives Circle Drawing Algorithm
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 49 / 60
Output Primitives Circle Drawing Algorithm
1 int x = 0, y = r , d = 1 − r
2 while(x <= y )
3 setpixel(x, y )
4 x ++
5 if (d < 0), d = d + 2x + 1, y = y
6 else y − − , d = d + 2x + 1 − 2y
7 end while
8 (x=0, r=8), Values(x,y,d)=(0,8,-7), (1,8,-4), (2,8,1), (3,7,-6),(4,7,3),
(5,6,2),(6,5,5)
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 50 / 60
Region Filling
Region Filling I
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 51 / 60
Region Filling
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 52 / 60
Region Filling
5 The 4-connected pixel technique failed to fill the area as marked in the
following figure which won’t happen with the 8-connected technique.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 53 / 60
Region Filling
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 54 / 60
Region Filling
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 55 / 60
Region Filling Boundary-Fill Algorithm
Boundary-Fill Algorithm I
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 56 / 60
Region Filling Boundary-Fill Algorithm
Boundary-Fill Algorithm II
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 57 / 60
Region Filling Boundary-Fill Algorithm
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 58 / 60
Region Filling Flood-fill Algorithm
Flood-fill Algorithm I
1 Flood fill algorithm is useful in cases where there are no single color
coundary for the polygon, i.e., the boundary has multiple colors.
2 In flood fill algorithm instead of filling color till you encounter a
specific boundary color you just fill the pixels with default color.
3 It is used in the ”bucket” fill tool of paint programs to fill connected,
similarly colored areas with a different color.
4 This algorithm also begins with a seed (starting pixel) inside the
region. It checks to see if the pixel has the regions original color. If
the answer is yes, it fills the pixel with a new color and uses each of
the pixels neighbors as a new seed in a recursive call. If the answer is
no, it returns to the caller.
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 59 / 60
Region Filling Flood-fill Algorithm
Veena Khandelwal (Dept of CSE IIST Indore) Computer Graphics & Multimedia August 28, 2018 60 / 60