Unit I Basics of Computer Graphics
Unit I Basics of Computer Graphics
• Output devices (LCD panels, laser printers, color printers. Plotters etc.)
Presentation Graphics
• To produce illustrations which summarize various kinds of data. Except 2D, 3D graphics
are good tools for reporting more complex data.
Computer Art
• Painting packages are available. With cordless, pressure-sensitive stylus, artists can
produce electronic paintings which simulate different brush strokes, brush widths, and
colors. Photorealistic techniques, morphing and animations are very useful in commercial
art. For films, 24 frames per second are required. For video monitor, 30 frames per
second are required.
Entertainment
Visualization
• For analyzing scientific, engineering, medical and business data or behavior. Converting
data to visual form can help to understand mass volume of data very efficiently.
Image Processing
• Multiple window, icons, menus allow a computer setup to be utilized more efficiently.
• Intensity of the electron beam is controlled by setting voltage levels on the control grid.
• The electron beam passes through focusing and deflection systems that direct it towards
specified positions on the phosphor-coated screen. The focusing system is needed to
force he electron beam to converge into a small spot as it strikes the phosphor screen,
else the bam would spread out as it approaches the screen.
• When the beam hits the screen, the phosphor emits a small spot of light at each position
contacted by the electron beam.
• It redraws the picture by directing the electron beam back over the same screen points
quickly. This is called refreshing, hence the CRT is called as Refresh CRT.
• The difference between the kinds of phosphors is their persistence- how long they
continue to emit light after the CRT beam is removed.
There are two ways (Random scan and Raster scan) by which we can display an object on the
screen.
Raster Scan
In a raster scan system, the electron beam is swept across the screen, one row at a time from top
to bottom. As the electron beam moves across each row, the beam intensity is turned on and off
to create a pattern of illuminated spots.
Picture definition is stored in memory area called the Refresh Buffer or Frame Buffer. This
memory area holds the set of intensity values for all the screen points. Stored intensity values
are then retrieved from the refresh buffer and “painted” on the screen one row (scan line) at a
time as shown in the following illustration.
Each screen point is referred to as a pixel (picture element) or pel. 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.
In this technique, the electron beam is directed only to the part of the screen where the picture is
to be drawn rather than scanning from left to right and top to bottom as in raster scan. It is also
called vector display, stroke-writing display, or calligraphic display.
Random-scan displays are designed to draw all the component lines of a picture 30 to 60 times
each second.
Random Scans
Beam-penetration method
The beam-penetration method for displaying color pictures has been used with random-scan
monitors. Two layers of phosphor, usually red and green, are coated onto the inside of the CRT
screen, and the displayed color depends on how far the electron beam penetrates into the
phosphor layers. A beam of slow electrons excites only the outer red layer. A beam of very fast
electron penetrates through the red layer and excites the inner green layer. At intermediate beam
speeds, combinations of red and green light are emitted to show two additional colors, orange
and yellow. The speed of the electrons, and hence the screen color at any point, is controlled by
the beam-acceleration voltage. Beam penetration has been aninexpensive way to produce color
in random-scan monitor, but only four colors are possible, and the quality of picture is not as
good as with other methods.
Shadow-mask methods are commonly used in raster-scan system (including color TV) because
they produce a much wider range of colors than the beam penetration method. A shadow-mask
CRT has three phosphor color dots at each pixel position. One phosphor dot emits a red light,
another emits a green light, and the third emits a blue light. This type ofCRT has three electron
guns, one for each color dot, and a shadow
shadow-mask
mask grid just behind the phosphor-coated
phosphor screen.
Figure illustrates the delta-delta
delta shadow
shadow-mask
mask method, commonly used in color CRT
CR system.
The three beams are deflected and focused as a group onto the shadow mask, which contains a
series of holes aligned with the phosphor
phosphor-dot
dot patterns. When the three beams pass through a hole
in the shadow mask, they activate a dot triangle, which aappears
ppears as a small color spot on the
screen. The phosphor dots in the triangles are arranged so that each electron beam can activate
only its corresponding color dot when it passes through the shadow mask. Another configuration
for the three electron guns iss an in
in-line
line arrangement in which the three electron guns, and the
corresponding redgreen-blue
blue color dots on the screen, are aligned along one scan line instead of
in a triangular pattern. This in-line
line arrangement of electron guns is easier to keep in alignment
alig
and is commonly used in high-resolution
resolution color CRTs.
The primary gun stores the picture pattern and the flood gun maintains the picture display.
The primary gun produces high speed electrons which strike on the storage grid to draw the
picture pattern. As electron beam strikes on the storage grid with high speed, it knocks out
electrons
ectrons from the storage grid keeping the net positive charge. The knocked out electrons are
attracted
acted towards the collector. The net positive charge on the storage grid is nothing but the
picture pattern. The continuous low speed electrons from flood gun pass through the control grid
and are attracted to the positive charged areas of the storage grid. The low speed electrons then
penetrate the storage grid and strike the phosphor coating without affecting the positive charge
pattern on the storage grid. During this process the collector just behind the storage grid
smooth’s out the flow of flood electrons.
Advantages:
Disadvantages:
• They do not display colors and are available with single level of line intensity.
• Erasing requires removal of charge on the storage grid Thus erasing and redrawing
process takes several seconds.
• Selective or part erasing of screen is not possible.
• Erasing of screen produces unpleasant flash over the entire screen surface which prevents
its use of dynamics graphics applications.
• It has poor contrast as a result of the comparatively low accelerating potential applied to
the flood electrons.
• The Performance of DVST is somewhat inferior to the refresh CRT.
Non Emissive Displays: They use optical effects to convert sunlight or light from some
other source into graphics patterns. E.g. LCD (Liquid Crystal Display)
A third type of emissive device is the Light-Emitting Diode (LED). A matrix of diodes is
arranged to form the pixel positions in the display, and picture definition is stored in a refresh
buffer. As in scan-line
line refreshing of a CRT, information is read from the refresh buffer and
converted to voltage levels that are applied to the diodes to produce the light patterns in the
display. Liquid Crystal Display (LCD) are commonly used in small systems, such as
calculators (see figure below) and portable, laptop computers. These nonemissive devices
produce a picture by passing polarized light from the surroundings or from an internal light
lig
source through a liquid-Crystal
Crystal material that can be aligned to either block or transmit the light.
The term liquid crystal refers to the fact that these compounds have a crystalline arrangement of
molecules, yet they flow like a liquid. Flat
Flat-panel displays
lays commonly use nematic (threadlike)
liquid-crystal
crystal compounds that tend to keep the long axes of the rodshaped molecules aligned. A
flat-panel
panel display can then be constructed with a nematic liquid crystal
crystal. Two glass plates, each
containing a light polarizer
izer at right angles to the
the-other
other plate, sandwich the liquid-crystal
liquid material.
Rows of horizontal transparent conductors are built into oneglass plate, and columns of vertical
conductors are put into the other plate. The intersection of two conductors defines
defi a pixel
position.
Normally, the molecules are aligned as shown in the "on state". Polarized light passing through
the material is twisted so that it will pass through the opposite polarizer. The light is then
reflected back to the viewer. To turn off the pixel, we apply a voltage to the two intersecting
conductors to align the molecules so that the light is not .twisted. This type of flat-panel
flat device is
referred to as a passive-matrix
matrix LCD. Picture definitions are stored in a refresh buffer, and the
screen
reen is refreshed at the rate of 60 frames per second, as in the emissive devices. Back lighting
is also commonly applied using solidstate electronic devices, so that the system is not completely
dependent on outside light sources. Colors can be displayed by using different materials or dyes
and by placing a triad of color pixels at each screen location. Another method for constructing
LCDs is to place a transistor at each pixel location, using thin
thin-film
film transistor technology. The
transistors are used to control
ntrol the voltage at pixel locations and to prevent charge from gradually
leaking out of the liquid-crystal
crystal cells. These devices are called active
active-matrix
matrix displays.
INPUT DEVICES
• Printers
• Plotters
Subscript k takes integer values starting from 0, for the 1st point and incr
increases
eases by until end point
is reached. Y value is rounded off to nearest integer to correspond to a screen pixel.
For lines with slope greater than 1, we reverse the role of x and y i.e. we sample at dy=1 and
calculate consecutive x values as
X k+1 = X k + 1/m
Digital Differential Analyzer (DDA) algorithm is the simple line generation algorithm which is
explained step by step here.
• Get the input of two end points (X0, Y0) and (X1, Y1).
• Calculate the difference between two end points.
• Based on the calculated difference, you need to identify the number of steps to put pixel.
If dx >dy, then you need more steps in x coordinate; otherwise in y coordinate.
• Calculate the increment in x coordinate and y coordinate.
• Put the pixel by successfully incrementing x and y coordinates accordingly and complete
co
the drawing of the line.
Algorithm:
Advantages:
• It is the simplest algorithm and it does not require special skills for implementation.
• It is a faster method for calculating pixel positions than the direct use of equation y=mx +
b. It eliminates the multiplication in the equation by making use of raster characteristics,
so that appropriate increments are applied in the x or y direction to find the pixel
positions along the line path
path.
Disadvantages:
The Bresenham’s algorithm is another incremental scan conversion algorithm. The big
advantage of this algorithm is that, it uses only integer calculations. Moving across the x axis in
unit intervals and at each step choose between two different y coordinates.
For example, as shown in the following illustration, from position (2, 3) you need to choose
between (3, 3) and (3, 4). You would like the point that is closer to the original line.
At sample position Xk+1,the vertical separations from the mathematical line are labelled
as dupperand dlower.
Algorithm
procedurelineBresenham(xa, ya, xb, yb : integer)
var
dx,dy,x, y, xend, p : integer;
begin
dx=abs(xa-xb);
dy=abs(ya-yb);
p=2*dy-dx;
if(xa>xb) then
begin
x=xb;y=yb;xend=xa;
end
else
begin
x=xa; y=ya;xend=xb;
end;
putpixel(x,y,4);
while(x<=xend) do
begin
x=x+1;
if (p<0) then
p=p+2*dy;
else
begin
y=y+1;
p=p+2*(dy-dx);
end;
putpixel(x,y,4);
end
end
Difference between DDA Line Drawing Algorithm and Bresenhams Line Drawing
Algorithm
Digital Differential Analyzer Line Bresenham’s Line Drawing Algorithm
Drawing Algorithm
Arithmetic DDA algorithm uses floating points i.e. Bresenham’s algorithm uses fixed points i.e.
Real Arithmetic. Integer Arithmetic
Operations DDA algorithm uses multiplication and Bresenham’s algorithm uses only subtraction
division in its operations. and addition in its operations.
Speed DDA algorithm is rather slowly than Bresenham’s algorithm is faster than DDA
Bresenham’s algorithm in line drawing algorithm in line drawing because it performs
because it uses real arithmetic (floating only addition and subtraction in its calculation
point operations) and uses only integer arithmetic so it runs
significantly faster.
Accuracy & DDA algorithm is not as accurate and Bresenham’s algorithm is more efficient and
Efficiency efficient as Bresenham’s algorithm much accurate than DDA algorithm.
Drawing DDA algorithm can draw circles and Bresenham’s algorithm can draw circles and
curves but that are not as accurate as curves with much more accuracy than DDA
Bresenham’salgorithm algorithm.
Round off DDA algorithm round off the coordinates Bresenham’s algorithm does not round but
to integer that is nearest to the line takes the incremental value in its operation.
Expensive DDA algorithm uses an enormous Bresenham’s algorithm is less expensive than
number of floating-point multiplications DDA algorithm as it uses only addition and
so it is expensive subtraction.
CIRCLE DRAWING ALGORITHM
(Midpoint Circle drawing algorithm)
A Circle is defined as the set of points that are all at a given distance r from a
center position (xc,yc).
The distance relationship is expressed by Pythagorean theorem in Cartesian
coordinates as ,
(x-xc)2 – (y-yc)2=r2,
Therefore,
Anti-Aliasing
UnweightedArea Sampling
Primitive cannot affect intensity of pixel if it does not intersect the pixel
pixel.
Equal areas cause equal intensity, regardless of distance from pixel center to area.
Unweighted sampling colors two pixels identically when the primitive cuts the same area
through the two pixels.
Intuitively, pixel cut through the center should be more heavily weighted than one cut
along corner.
Unweighted sampling
Filtering Techniques
A continuous weighting surface (or filter function) covering the pixel.
Applying the filter function by integrating over the pixel surface to obtain the weighted
average intensity
Weighted (Filter ) Function
http://www.graphics.cornell.edu/online/tutorial/
https://www.cs.utexas.edu/~fussell/courses/cs324e2003/hear50265_ch03.pdf
http://www.slideshare.net/rajeshkamboj/computer-graphics-notes-btech-kuk-mdu
http://www.slideshare.net/rhspcte/computer-graphics-ebookhearn-baker