CG CST304
CG CST304
CST 304
Prepared By
Liya Prakash
“ A picture is worth a thousand words”
• The term computer graphics is an art of drawing
pictures, lines, charts, etc using computers with the help
of programming.
• It involves creation , storage and manipulation.
• Computer Graphics express data in pictorial form.
• It displays information in the form of graphics objects such
as pictures, charts ,graphs etc instead of simply text.
Applications of computer graphics
• Entertainment
• Medical Imaging and Scientific Visualization
• Computer Aided Design
• Education & training
• Computer Art
• Presentation graphics
• Image processing
• GUI
• A display area is represented as a collection of discrete
picture elements called pixels.
• Pixel is the smallest addressable unit on the screen.
Each pixel has got some information like its intensity and
color.
• Basically there are two types of computer graphics
namely Interactive Computer Graphics and Passive
Computer Graphics.
Interactive Computer Graphics
• It involves a two way communication between computer and
user.
• The observer is given some control over the image by providing
him with an input device .
• For example: Observer send his request to the computer
through video game controller. Computer on receiving signals
can modify the displayed picture appropriately.
Non Interactive Computer Graphics
• It is also known as passive computer graphics.
• The user does not have any kind of control over the image.
• It involves only a one way communication.
• The image is merely the product of static stored program and
will work according to the instructions given in the program
linearly.
• The image is totally under the control of program instructions,
not under the user. Example: images shown on television.
Video Display Devices: CRT
• Picture element
• Intensity value
• Resolution
• Aspect Ratio
Raster scan display
• It is the most common type of CRT monitor.
• In this system, the electron beam is swept across the screen
one row at a time from top to bottom.
• Beam intensity is turned on and off to create a pattern of
illuminated spots as the electron moves across each row.
• In a raster scan system entire screen is considered as a
matrix of pixels.
• Each screen point is referred to as a pixel or pel (shortened
form of picture element).
• Frame buffer or refresh buffer is a memory where picture
definition is stored .i.e. set of all intensity values for all pixels
is stored in refresh buffer.
• Horizontal Retrace: 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.
• Vertical retrace: At the end of each frame the
electron beam returns to the top left corner of the
screen to begin the next frame.
• Interlacing: In this method, each frame is
displayed in two passes using an interlaced
refresh procedure. First all the points on the
even numbered scanlines are displayed ,and
then all the odd numbered lines are displayed.
Entire screen is displayed in half time , providing
that adjacent scanlines contain similar
information.
• In a simple black and white system, each screen point is
either on or off, so only one bit per pixel is needed to
control the intensity of screen positions.
• Bit value of 1 indicates that the electron beam is to be
turned on that position, and a value of 0 indicates that the
beam intensity is to be turned off.
• Additional bits are needed when color and intensity
variations are to be displayed.
• On a black-and-white system with one bit per pixeI, the
frame buffer is commonly called a bitmap.
• For systems with multiple bits per pixel, the frame buffer is
referred to as a pixmap.
• Refreshing on raster scan displays is carried out at the rate
of 60 to 80 frames per second.
• Home television sets and printers are examples of other
systems using raster-scan methods.
RASTER-SCAN SYSTEMS
• In Interactive raster graphics systems, in addition
to the CPU ,a special-purpose processor, called
the video controller or display controller, is used
to control the operation of the display device.
• A fixed area of the system memory is reserved for the frame
buffer, and the video controller is given direct access to the
frame-buffer memory.
• Frame-buffer locations, and the corresponding screen
positions, are referenced in Cartesian coordinates.
• For many graphics monitors, the coordinate origin is defined at
the lower left screen corner.
• The screen surface is represented as the first quadrant of a
two-dimensional system, with positive x values increasing to
the right and positive y values increasing from bottom to top.
• Scan lines are then labeled from ymax at the top of the screen
to 0 at the bottom.
• Along each scan line, screen pixel positions are labeled from 0
to xmax.
• On some personal computers, the coordinate origin is
referenced at the upper left comer of the screen, so the y
values are inverted.
• Two registers are used to store the coordinates of the screen
pixels: x register and y register.
• Initially, x register is set to 0 and the y register is set to y max.
• The value stored in the frame buffer for this pixel position is
then retrieved and used to set the intensity of the CRT beam.
• Then the x register is incremented by 1, and the process
repeated for the next pixel on the top scan line.
• This procedure is repeated for each pixel along the 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 decremented by 1.
• Pixels along this scan line are then processed in turn, and the
procedure is repeated for each successive scan line.
• After cycling through all pixels along the bottom scan line (y =
0), the video controller resets the registers to the first pixel
position on the top scan line and the refresh process starts over.
• To speed up pixel processing, video controllers can
retrieve multiple pixel values from the refresh buffer on
each pass.
• The multiple pixel intensities are then stored in a separate
register called pixel register and used to control the CRT
beam intensity for a group of adjacent pixels.
• In addition to the system memory, a separate display
processor memory area can also be provided. Main
purpose is digitizing a picture definition given in an
application program into a set of pixel-intensity values for
storage in the frame buffer. This digitization process is
caIled scan conversion.
Random scan display
• It is also called as calligraphic displays, vector displays, stroke
displays.
• The electron beam is 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.
• A pen plotter operates in a similar way and is an example of a
random-scan, hard-copy device.
• Picture definition is stored as a set of line drawing commands in an
area of memory referred to as refresh display file/refresh buffer.
• To display a specified picture ,the system cycles through a set of
commands in the display file , drawing each component line.
• After all line drawing commands have been processed, the system
cycles back to the first line command in the list.
• Random-scan displays are scan displays are designed to draw all the
component lines of a picture 30 to 60 times
RANDOM-SCAN SYSTEMS
• An application program is input and stored in the system memory
along with a graphics package.
• Graphics commands in the application program are translated by
the graphics package into a display file stored in the system
memory.
• This display file is then accessed by the display processor to
refresh the screen.
• The display processor cycles through each command in the display
file program once during every refresh cycle.
• Sometimes the display processor in a random-scan system is
referred to as a display processing unit or a graphics controller.
• Graphics patterns are drawn on a random-scan system by directing
the electron beam along the component lines of the picture.
• Lines are defined by the values for their coordinate endpoints, and
these input coordinate values are converted to x and y deflection
voltages.
• A scene is then drawn one line at a time by positioning the beam
Color CRT
Disadvantages:
(1)• The rounding operation & floating point arithmetic are time
consuming procedures.
Perform integer arithmetic by storing float as integers in numerator and
denominator and performing integer arithmetic
(2) Round-off error can cause the calculated pixel position to drift away
from the true line path for long line segment. Hence end point
accuracy is poor.
20
Bresenham’s line drawing algorithm
ADVANTAGE
S
• Bresenham’s algorithm generally faster than DDA
• Reduces complexity
• More accurate than DDA
CIRCLE DRAWING ALGORITHMS
0 (0, 8)
1 -13 -3 (1, 8)
2 -3 11 (2, 8)
3 11 5 (3, 7)
4 5 7 (4, 6)
5 7 (5, 5)