Professional Documents
Culture Documents
CG Chapter 1-5
CG Chapter 1-5
CG Chapter 1-5
Chapter One
Outline
Introduction of CG
Application of CG
Types of CG
Graphics Hardware and software
Architecture of raster system
Graphics software
Introduction
• Computer graphics is one of the most effective and commonly used way to
information in form of graphics object such as pictures, chart ,graphs and
diagram instead of simple text.
• Computer graphics is an art of drawing pictures on computer screens with the
help of programming.
• It is a process of generating , manipulating ,storing and displaying graphics
objects.so we can say that computer graphics makes it possible to express data
in pictorial form. Where graphics objects are presented as a collection of
discrete picture elements.
• Pixel is the smallest screen elements so we generate graph by managing pixel.
• The control is achieved by setting the intensity and colour of pixel which
compose screen.
• It is a tool for storing, manipulating and correlating data.
Cont..
• The process of determining the appropriate pixel for representing picture is
known as rasterization but the process of representing continuous picture is
called as scan conversion.
• There is close relationship between input devices and display devices.
• Graphics device =input devices + display devices
• Display devices also known as output devices
• The most commonly used output devices in a graphics system is a video
monitor.
Advantage
1. High quality graphics display
2. it provide tools for producing picture,
3. produce animation.
1.2 Applications of Computer Graphics
• Although most graphics monitors are still constructed with CRTs, other technologies are
emerging that may soon replace CRT monitors.
• The term flat-panel display refers to a class of video devices that have reduced volume,
weight, and power requirements compared to a CRT.
• A significant feature of flat-panel displays is that they are thinner than CRTs, and we can
hang them on walls or wear them on our wrists.
• We can separate flat-panel displays into two categories: emissive displays and non
emissive displays.
GRAPHICS HARDWARE
• The emissive displays are devices that convert electrical energy into light.
Plasma panels, and light-emitting diodes are examples of emissive displays.
• Non emissive displays use optical effects to convert sunlight or light from
some other source into graphics patterns. The most important example of a
non emissive flat-panel display is a liquid-crystal device( LCD).
• Liquid crystal refers to the fact that these compounds have a crystalline
arrangement of molecules, yet they flow like a liquid.
Architecture of Raster Graphics Systems
Most (non-graphics) processing will occur in the CPU of the computer, which uses the system
bus to communicate with the system memory and peripheral devices
When graphics routines are to be executed, instead of being executed by the CPU they are
passed straight to the display processor, which contains dedicated hardware for drawing
graphics primitives.
The display processor is also known by a variety of other names: graphics controller, display
coprocessor, graphics accelerator and video card are all terms used to refer to the display
processor.
The display processor contains dedicated hardware for executing graphics
routines it must be dedicated to a particular set of routines.
Most commercial video cards will support hardware rendering for the OpenGL graphics
package, and many PC video cards will also support hardware rendering for DirectX.
Cont.…
• graphics routines are compiled and executed by the CPU just like any
other code.
• For the raster graphics architecture to support software rendering need
to be modified so that the frame buffer was connected directly to the
system bus in order that it could be updated by the CPU.
• The Architecture of a Raster Graphics System with a Display
Processor.
Color CRT Monitors
• To display coloured pictures, combination of phosphorus is
used that emits different coloured light.
• Two different techniques for producing colour displays with a
CRT.
1. Beam Penetration Method
2. Shadow Mask Method
Beam Penetration Method
• Has been an inexpensive way to produce color and used in random-scan monitors.
• Only four colors are possible, and the quality of pictures is not as good as with other methods.
• Two layers of phosphor, usually red and green, are coated onto the inside of the CRT screen.
• Color producting
• speeds, combinations of red and green light are emitted to show two additional colors, orange and
yellow.
• Colours Produced:- Only four colours are produced in beam penetration due to the speed of the singular
electron gun
• It use random method
• Merits(advantage) it is inexpensive technique to produce color in random scan monitors.
• Demerits(disadvantage) it can display only four colors, the quality of
picture produced by this technique is not good as compared to other
techniques'.
Shadow Mask Method
• Commonly used in raster-scan systems (including color TV).
• Produce a much wider range of colors than the beam-penetration using three phosphor color
dots at each pixel position.
• The phosphor dots are in very close groups of three, which give off red, green and blue light
respectively.
Colors Produced:- millions of colors are able to be produced.
Color Dependency:- Millions of colors are produced with the shadow mask method because it
depends on the intensity of the three available electron guns.
Number of Electron Guns Used:- three electron guns are used to produce the millions of
colors.
In recent years the popularity of 3D graphics display devices has been growing, although
currently they are still quite expensive compared with traditional 2D displays.
CRT:-is an evacuated glass tube
LCD:- LCD requires an AC power supply instead of DC, so it is difficult to use it in circuits.
It generally works on flat panel display technology.
Light Emitting Diode (LED): LED is a device which emits when current passes through it.
It is a semiconductor device.
Direct View Storage Tube (DVST):
• Primary Gun: It is used to store the picture information.
• Flood / Secondary Gun: It is used to display a picture on the screen.
CONT…
• …………………………………………………………(2)
• ………………………………………………………………………….(3)
39
Line Drawing Algorithms
40
DDA Line-Drawing Algorithm
The Digital Differential Analyzer (DDA) algorithm operates by starting at one end-point of the line,
and then using Eqs. (4) and (5) to generate successive pixels until the second end-point is reached.
Therefore, first, we need to assign values for δx and δy.
In other case, we must make sure that both δx and δy have values less than or equal to one. To ensure
this, we must first check the size of the line gradient. The conditions are:
41
DDA Line-Drawing Algorithm
2.
Once we have computed values for δx and δy, the basic DDA algorithm is:
• Start with
• Find successive pixel positions by adding on (δx, δy) and rounding to the nearest integer, i.e
•
42
DDA Line-Drawing Algorithm
The Digital Differential Analyser (DDA) algorithm operates by starting at one end-point of the
line, to generate successive pixels until the second end-point is reached. The algorithm for
drawing lines using DDA algorithm have the following five steps which we discus below:
Step 1: Get the input of two end points (X0, Y0) and (X1, Y1).
Step 2: Calculate the difference between the two end points.
dx = X1 - X0
dy = Y1 - Y0
Step 3: Identify the number of steps to put pixel. If dx > dy, then you need more steps in x
coordinate; otherwise in y coordinate.
if |(dx)| > |(dy)|
No_steps = |dx|;
else
No_steps = |dy|;
Cont..
Step 4: Calculate the increment in x coordinate and y coordinate.
Xinc = dx / (float) No_steps;
Yinc = dy / (float) No_steps;
Step 5: Put the pixel by successfully incrementing x and y coordinates accordingly and complete
the drawing of the line.
x = x + Xinc;
y = y + Yinc;
putpixel(Round(x), Round(y));
Note that the actual pixel value used will be calculated by rounding to the nearest integer, but we
keep the real valued location for calculating the next pixel position.
Let us consider an example of applying the DDA algorithm for drawing a straight-line segment given
the following inputs.
Cont..
Step 1: get the inputs x1=15 x0=10 y1=13 y0=10
Step 2: calculate the difference between the two end points
dx= x1-x0=15-10=5
dy= y1-y0=13-10=3
Step3: identify number of steps
dx>dy= 5>3
No_steps=5;
Step 4: calculate the increment
Xinc=dx/No_steps= 5/5=1
Yinc=dy/No_steps=3/5=0.6
Step 5: Using the values, we can now start to plot line points:
Start with (x0,y0) = (10,10) – colour this pixel
Next, (x1,y1) = (10+1,10+0.6) = (11,10.6) – so we colour pixel (11,11)
Cont….
Next, (x2,y2) = (11+1,10.6+0.6) = (12,11.2) – so we colour pixel (12,11)
Next, (x3,y3) = (12+1,11.2+0.6) = (13,11.8) – so we colour pixel (13,12)
Next, (x4,y4) = (13+1,11.8+0.6) = (14,12.4) – so we colour pixel (14,12)
Next, (x5,y5) = (14+1,12.4+0.6) = (15,13) – so we colour pixel (15,13)
We have now reached the end-point (xend, yend), so the algorithm terminates
Cont…
The DDA algorithm is simple and easy to implement, but it does involve floating
point
operations to calculate each new point.
Floating point operations are time-consuming when compared to integer
operations.
Since line drawing is a very common operation in computer graphics, it would be
nice if we could devise a faster algorithm which uses integer operations only.
Bresenham’s Line-Drawing Algorithm
Bresenham’s line-drawing algorithm provides significant improvements in efficiency over the DDA
algorithm.
These improvements arise from the observation that for any given line, if we know the previous pixel
location, we only have a choice of 2 locations for the next pixel.
This concept is illustrated in Figure 2: given that we know (xk,yk) is a point on the line, we know the
next line point must be either pixel A or pixel B. Therefore we do not need to compute the actual
floating-point location of the ‘true’ line point; we need only make a decision between pixels A and B.
Cont…
Bresenham’s algorithm works as follows.
Plot the start-point of the line (x0,y0)
Compute the first decision variable:
Cont…
OpenGL Line Functions
• We can draw straight-lines in OpenGL using the same glBegin … glEnd
functions that we saw for point-drawing.
• This time we specify that vertices should be interpreted as line end-points
by using the symbolic constant GL_LINES. For example, the following
code
glLineWidth(3.0);
glBegin(GL_LINES);
glVertex2f(100.0, 200.0);
glVertex2f(150.0, 200.0);
glVertex2f(150.0, 250.0);
glVertex2f(200.0, 250.0);
glEnd()
• will draw two separate line segments: one from (100,200) to (150,200) and one from
(150,250) to (200,250).
Cont…
• Two other symbolic constants allow us to draw slightly different types of
straight-line primitive are: GL_LINE_STRIP and GL_LINE_LOOP.
Glint p1[] = {200,100}; Glint p2[] = {50,0}
Glint p3[] = {100,200}; Glint p4[] = {150,0};
Glint p5[] = {0,100};
glBegin(GL_LINES);
glVertex2iv(p1);
glVertex2iv(p2);
glVertex2iv(p3);
glVertex2iv(p4);
glVertex2iv(p5);
glEnd();
LINE_STRIP
glBegin(GL_LINE_STRIP);
glVertex2iv(p1);
glVertex2iv(p2);
glVertex2iv(p3);
glVertex2iv(p4);
glVertex2iv(p5);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2iv(p1);
glVertex2iv(p2);
glVertex2iv(p3);
glVertex2iv(p4);
glVertex2iv(p5);
glEnd();
Circle-Drawing Algorithms
• Some graphics packages allow us to draw circle primitives. Before we examine
algorithms for circle-drawing we will consider the mathematical equations of a circle.
• In Cartesian coordinates we can write:
Midpoint Circle-Drawing Algorithm
• The midpoint algorithm takes advantage of the symmetry property of circles to produce a more
efficient algorithm for drawing circles.
• The algorithm works in a similar way to Bresenham’s
• line-drawing algorithm, in that it formulates a decision variable that can be computed using
integer operations only.
Fill-Area Primitives
• The most common type of primitive in 3-D computer graphics is the fill-area primitive.
• The term fill-area primitive refers to any enclosed boundary that can be filled
with a solid colour or pattern.
• Each pair of adjacent vertices is connected in sequence by edges.
• Polygons are the most common form of graphics primitive because they form
the basis of polygonal meshes, which is the most common representation for
3-D graphics objects.
Cont…
Two algorithms or methods used to fill the polygon.
1) Seed Fill Algorithm
A, Flood-fill Algorithm
Flood-fill algorithm helps to define a region in the boundary, attached to a point in the multi-
dimensional array.
In flood -fill algorithm, we replace all the associated pixels of the selected color with a fill
color. It fill interior of image
It provides an easy way to fill color in graphics
B, Boundary-fill Algorithm
It is also known as the “Edge-fill algorithm.” The boundary fill algorithm is used for area
filling.
We can perform boundary fill where we want to create an attractive painting.
2, Scan Line Algorithm
we can fill the polygons through horizontal lines or scan lines.
The scan-line intersects the edges of the polygon, and the polygon is filled between pairs of the
intersection.
Although colour look-up tables do save storage, they slow down the rasterisation process as
an extra look-up operation is required. They were commonly used in the early days of
computer graphics when memory was expensive, but these days memory is cheaper so most
systems use direct storage.
Cont…
• OpenGL uses direct storage by default, but the programmer can choose to use a colour look-up
table if they wish.
OpenGL Colour Attributes
• we change the current drawing colour using the glColor* function and the current background
colour using the glClearColor function.
• glColor3f(1.0,0.0,0.0); // set drawing colour to red
• glColor4f(0.0,1.0,0.0,0.05); // set drawing colour to semi-
transparent green
• glClearColor(1.0,1.0,1.0,1.0); // set background colour to opaque white
• Before we do any drawing in OpenGL, we must define a frame buffer.
• If we want to do colour drawing then we must specify that we want a colour frame buffer.
• Example glutInitDisplayMode(GLUT_SINGLE,GLUT_RGB)
• In order to store alpha values in the frame buffer we must change the second argument to
GLUT_RGBA.
• To specify that we want to use a colour look-up table we set the second argument equal to
GLUT_INDEX.
Point Attributes
• Points are the simplest type of primitive so the only attributes we can modify
are the colour and size of the point.
• glPointSize(size)
Line Attributes
• Straight-line segment can be displayed with three basic attributes: color, width, and style.
The attributes of line primitives that we can modify include the following:
• Line colour, Line width and Line style (solid/dashed etc)
Line Width
The simplest and most common technique for increasing the width of a line is to plot a line of width 1
pixel, and then add extra pixels in either the horizontal or vertical directions.
Implementation of line-width options depends on the capabilities of the output device. A heavy line
could be display on a video monitor as adjacent parallel line.
•If |m| ≤ 1 plot extra pixels vertically, i.e. same x-coordinate, different y-coordinate, as in Figure
2(a).
•If |m| > 1, plot extra pixels horizontally, i.e. same y-coordinate, different x-coordinate, as in
Figure 2(b).
• Gedeo is a Highland East Cushitic language of the Afro-Asiatic family
spoken in south central Ethiopia. Alternate names for the language
include Derasa, Deresa, Darassa, Geddeo, Derasanya, Darasa. It is
spoken by the Gedeo people, who live in the highland area,
southwest of Dila and east of Lake Abaya.[1]
• The languages has SOV word order. Verbs are marked for person,
number, and gender of subject. Verbs are marked for voice: active,
causative, middle, and passive.
• The New Testament was published in the Gedeo language in 1986,
using the Ethiopian syllabary.
• About: Gedeo language
• An Entity of Type: language, from Named Graph: http://dbpedia.org
, within Data Space: dbpedia.org
• Gedeo is a Highland East Cushitic language of the Afro-Asiatic family
spoken in south central Ethiopia. Alternate names for the language
include Derasa, Deresa, Darassa, Geddeo, Derasanya, Darasa. It is spoken
by the Gedeo people, who live in the highland area, southwest of Dila
and east of Lake Abaya. The languages has SOV word order. Verbs are
marked for person, number, and gender of subject. Verbs are marked for
voice: active, causative, middle, and passive. The New Testament was
published in the Gedeo language in 1986, using the .
•Gedeo is a Highland East Cushitic language of the Afro-Asiatic
family spoken in south central Ethiopia.
•Alternate names for the language include Derasa, Deresa, Darassa,
Geddeo, Derasanya, Darasa.
•It is spoken by the Gedeo people, who live in the highland area,
southwest of Dila and east of Lake Abaya.
• The languages has SOV word order. Verbs are marked for person,
number, and gender of subject.
• Verbs are marked for voice: active, causative, middle, and passive.
•The New Testament was published in the Gedeo language in 1986,
using the . (en)