Вы находитесь на странице: 1из 15

NOTES of unit-1

INTRODUCTION TO CG-

Computer graphics remains one of the most existing and rapidly growing computer fields. Computer graphics
may be defined as a pictorial representation or graphical representation of objects in a computer. To display a
picture of any size on a computer screen is a difficult process. Computer graphics are used to simplify this
process. Various algorithms and techniques are used to generate graphics in computers. Computer graphics is an
art of drawing pictures on computer screens with the help of programming. It involves computations, creation,
and manipulation of data. In other words, we can say that computer graphics is a rendering tool for the
generation and manipulation of images

INTERACTIVE GRAPHIC DISPLAYS-

1. Cathode Ray Tube-


The primary output device in a graphical system is the video monitor. The main element of a video monitor is
the Cathode Ray Tube (CRT), shown in the following illustration.

The operation of CRT is very simple −

 The electron gun emits a beam of electrons (cathode rays).

 The electron beam passes through focusing and deflection systems that direct it towards specified
positions on the phosphor-coated 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.

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.

Random Scan (Vector Scan)


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.

Picture definition is stored as a set of line-drawing


commands in an area of memory referred to as
the refresh display file. To display a specified picture,
the system cycles through the set of commands in the display file, drawing each component line in turn. After
all the line-drawing commands are processed, the system cycles back to the first line command in the list.

Random-scan displays are designed to draw all the component lines of a picture 30 to 60 times each second.

Types of CRT-
The basic principle behind colored displays is that combining the 3 basic colors –Red, Blue and Green,can
produce every color. By choosing different ratios of these three colors we can produce different colors –
millions of them in-fact. We also have basic phosphors, which can produce these basic colors. So, one should
have a technology to combine them in different combinations.
There are two popular techniques for producing color displays with a CRT are:

Beam Penetration method


This CRT is similar to the simple CRT, but it makes use of multi coloured phosphorus of number of layers.
Each phosphorus layer is responsible for one colour. All other arrangements are similar to simple CRT. It can
produce a maximum of 4 to 5 colours
The organization is something like this - The red, green and blue phosphorus are coated in layers - one behind
the other. If a low speed beam strikes the CRT, only the red colored phosphorus is activated, a slightly
accelerated beam would activate both red and green (because it can penetrate deeper) and a much more
activated one would add the blue component also.
But the basic problem is a reliable technology to accelerate the electronic beam to precise levels to get the exact
colors - it is easier said than done. However, a limited range of colors can be conveniently produced using the
concept.

The Shadow - Mask method.

This works, again, on the principle of combining the basic colors - Red, green and Blue - in suitable
proportions to get a combination of colors, but it's principle is much more sophisticated and stable.
The shadow mask CRT, instead of using one electron gun, uses 3 different guns placed one by the side of the
other to form a triangle or a "Delta" as shown. Each pixel point on the screen is also made up of 3 types of
phosphors to produce red, blue and green colors. Just before the phosphor screen is a metal screen, called a
"shadow mask".
This plate has holes placed strategically, so that when the beams from the three electron guns are focused on a
particular pixel, they get focused on particular color producing pixel only i.e. If for convenience sake we can
call the electronic beams as red, blue and green beams (though in practice the colors are produced by the
phosphors, and until the beams hit the phosphor dots, they produce no colors), the metal holes focus the red
beam onto the red color producing phosphor, blue beam on the blue producing one etc. When focused on to a
different pixel, the red beam again focuses on to the red phosphor and so on.
Now, unlike the beam penetration CRTs where the acceleration of the electron beam was being monitored, we
now manipulate the intensity of the 3 beams simultaneously. If the red beam is made more intense, we get more
of red color in the final combination etc. Since fine-tuning of the beam intensities is comparatively simple, we
can get much more combination of colors than the beam penetration case. In fact, one can have a matrix of
combinations to produce a wide variety of colors.
The shadow mask CRT, though better than the beam penetration CRT in performance, is not without it's
disadvantages. Since three beams are to be focused, the role of the "Shadow mask" becomes critical. If the
focusing is not achieved properly, the results tend to be poor. Also, since instead of one pixel point in a
monochrome CRT now each pixel is made up of 3 points (for 3 colors), the resolution of the CRT (no. of
pixels) for a given screen size reduces.
Another problem is that since the shadow mask blocks a portion of the beams (while focusing them through the
holes) their intensities get reduced, thus reducing the overall brightness of the picture. To overcome this effect,
the beams will have to be produced at very high intensities to begin with. Also, since the 3 color points, though
close to each other, are still not at the same point, the pictures tend to look like 3 colored pictures placed close
by, rather than a single picture. Of course, this effect can be reduced by placing the dots as close to one another
as possible.
The above displays are called refresh line drawing displays, because the picture vanishes (typically in about 100
Milli seconds ) and the pictures have to be continuously refreshed so that the human persistence of vision makes
them see as static pictures. They are costly on one hand and also tend to flicker when complex pictures are
displayed (Because refreshing because complex).
These problems are partly overcome by devices with inherent storage devices - i.e. they continue to display the
pictures, till they are changed or at least for several minutes without the need of being refreshed. We see one
such device called the Direct View Storage Tube (DVST).

Conceptually the Direct View Storage Tube (DVST) behaves like a CRT with highly persistent phosphor.
Pictures drawn on there will be seen for several minutes (40-50 minutes) before fading. It is similar to CRT as
far as the electronic gun and phosphor-coated mechanisms are concerned. But instead of the electron beam
directly writing the pictures on the phosphor coated CRT screen, the writing is done with the help of a fine-
mesh wire grid.
The grid made of very thin, high quality wire, is located with a dielectric and is mounted just before the screen
on the path of the electron beam from the gun. A pattern of positive charges is deposited on the grid and this
pattern is transferred to the phosphor coated CRT by a continuous flood of electrons. This flood of electrons is
produced by a "flood gun" (This is separate frame the electron gun that produces the main electron beam).
Just behind the storage mesh is a second grid called the collector. The function of the collector is to smooth out
the flow of flood electrons. Since a large number of electrons are produced at high velocity by the flood gun, the
collector grid, which is also negatively charged reduces, the acceleration on these electrons and the resulting
low velocity flood pass through the collector and get attracted by the positively charged portions of the storage
mesh (Since the electrons are negatively charged), but are repelled by the other portions of the mesh which are
negatively charged (Note that the pattern of positive charges residing on the storage mesh actually defines the
picture to be displayed).

Thus, the electrons attracted by the positive charges pass through the mesh, travel on to the phosphor coated
screen and display the picture. Since the collector has slowed the electrons down, they may not be able to
produce sharp and bright images. To over come this problem, the screen itself is maintained at a high positive
potential by means of a voltage applied to a thin aluminum coating between the tube face and the phosphor.
The dotted circle on the mesh is created by positive charges the flood of electrons hit the mesh at all points. But
only those electrons that hit the dotted circle pass through and hit the CRT screen. The negatively charged mesh
repels others.
Since the phosphor is of a very high persistence quality, the picture created on the CRT screen will be visible
for several minutes without the need for being refreshed.
Now the problem arises as to how do we remove the picture, when the time for it's erasure or modification
comes up. The simple method is to apply a positive charge to the negatively charged mesh so that it gets
neutralized. This removes all charges and clears the screen. But this technique also produces a momentary flash,
which may be unpleasant to the viewer.
This is mainly so when only portions of the picture are to be modified in an interactive manner. Also, since the
electrons hit the CRT screen at very low speeds (though they are slightly accelerated in the last part of their
journey to the CRT by a positively charged aluminum coating), the contrasts are not sharp. Also, even though
the pictures stay for almost an hour, there will be a gradual degradation because of the accumulation of the
background glow.
The other popular display device is the plasma panel device, which is partly similar to the DVST in principle,
but over comes some of the undesirable features of the DVST.
Important definations -
Persistence -
The time it takes the emitted light from the screen to decay one tenth of its original intensity is called as
persistence.
Resolution -
The maximum number of points that can be displayed without an overlap on a CRT is called as resolution.
Aspect Ratio
The ratio of vertical points to the horizontal points necessary to produce length of lines in both directions of the
screen is called Aspect Ratio. Usually the aspect ratio is ¾.

2. Flat panel display


This term refers to a class of video devices that have reduced volume, weight and power
requirement compared to CRT. Current use of flat panel display is tv monitors, calculators,
pocket video games, laptop computers etc
TYPES OF DISPLAYS-

EMISSIVE:
The emissive display converts electrical energy into light energy. The plasma panels, thin film electro-
luminescent displays are the examples.

NON-EMISSIVE:
They are optical effects to convert the sunlight or light from any other source to graphic form. Liquid crystal
display is an example
a) PLASMA PANEL DISPLAY-

A plasma display is a computer video display in which each pixel on the screen is illuminated by a tiny bit of
plasma or charged gas, somewhat like a tiny neon light. Plasma displays are thinner than cathode ray tube
( CRT ) displays and brighter than liquid crystal displays ( LCD). Plasma displays are sometimes marketed as
"thin-panel" displays and can be used to display either analog video signals or display modes digital computer
input.

In addition to the advantage of slimness, a plasma display is flat rather than slightly curved as a CRT display is
and therefore free of distortion on the edges of the screen. Unlike many LCD displays, a plasma display offers a
very wide viewing angle. Plasma displays come in conventional PC displays sizes and also in sizes up to 60
inches for home theater and high definition television .

b) LCD-

Stands for "Liquid Crystal Display." LCD is a flat panel display technology commonly used in TVs and
computer monitors. It is also used in screens for mobile devices, such as laptops, tablets, and smartphones.

LCD displays don't just look different than bulky CRT monitors, the way they operate is significantly different
as well. Instead of firing electrons at a glass screen, an LCD has backlight that provides light to
individual pixels arranged in a rectangular grid. Each pixel has a red, green, and blue RGB sub-pixel that can be
turned on or off. When all of a pixel's sub-pixels are turned off, it appears black. When all the sub-pixels are
turned on 100%, it appears white. By adjusting the individual levels of red, green, and blue light, millions of
color combinations are possible.

How an LCD works

The backlight in liquid crystal display provides an even light source behind the screen. This light is polarized,
meaning only half of the light shines through to the liquid crystal layer. The liquid crystals are made up of a part
solid, part liquid substance that can be "twisted" by applying electrical voltage to them. They block the
polarized light when they are off, but reflect red, green, or blue light when activated.

Each LCD screen contains a matrix of pixels that display the image on the screen. Early LCDs had passive-
matrix screens, which controlled individual pixels by sending a charge to their row and column. Since a limited
number of electrical charges could be sent each second, passive-matrix screens were known for appearing
blurry when images moved quickly on the screen. Modern LCDs typically use active-matrix technology, which
contain thin film transistors, or TFTs. These transistors include capacitors that enable individual pixels to
"actively" retain their charge. Therefore, active-matrix LCDs are more efficient and appear more responsive
than passive-matrix displays.

3. LED-

A Light Emitting Diode (LED) is one of the latest inventions and is extensively used these days. From your cell
phone to the large advertising display boards, the wide range of applications of these magical light bulbs can be
witnessed almost everywhere. Today their popularity and applications are increasing rapidly due to some
remarkable properties they have. Specifically, LEDs are very small in size and consume very little power. The
magnificent, beautiful, dazzling colors involved with LEDs may be quite picturesque, but do you really know
how these effects are actually created in them or rather how do LED light bulbs work?
What is it??

As is evident from its name, LED (Light Emitting Diode) is basically a small light emitting device that comes
under “active” semiconductor electronic components. It’s quite comparable to the normal general purpose
diode, with the only big difference being its capability to emit light in different colors. The two terminals (anode
and cathode) of a LED when connected to a voltage source in the correct polarity, may produce lights of
different colors, as per the semiconductor substance used inside it.

Working Principle:

A light-emitting diode is a two-lead semiconductor light source. It is a p–n junction diode that emits light when
activated. When a suitable voltage is applied to the leads, electrons are able to recombine with electron holes
within the device, releasing energy in the form of photons. This effect is called electroluminescence, and the
color of the light (corresponding to the energy of the photon) is determined by the energy band gap of the
semiconductor.

Solid Area Scan Conversion or Visible Surface Detection. Visible surface detection algorithms are broadly
classified as: Object Space Methods: Compares objects and parts of objects to each other within the scene
definition to determine which surfaces are visible

Application of Computer Graphics


Computer Graphics has numerous applications, some of which are listed below −

 Computer graphics user interfaces (GUIs) − A graphic, mouse-oriented paradigm which allows the
user to interact with a computer.

 Business presentation graphics − "A picture is worth a thousand words".

 Cartography − Drawing maps.

 Weather Maps − Real-time mapping, symbolic representations.

 Satellite Imaging − Geodesic images.

 Photo Enhancement − Sharpening blurred photos.

 Medical imaging − MRIs, CAT scans, etc. - Non-invasive internal examination.

 Engineering drawings − mechanical, electrical, civil, etc. - Replacing the blueprints of the past.

 Typography − The use of character images in publishing - replacing the hard type of the past.

 Architecture − Construction plans, exterior sketches - replacing the blueprints and hand drawings of
the past.
 Art − Computers provide a new medium for artists.

 Training − Flight simulators, computer aided instruction, etc.

 Entertainment − Movies and games.

 Simulation and modeling − Replacing physical modeling and enactments

2. PRINTERS -
Non
Impact Printer
Impact Printer

Work without any


Work by banging the needle placed needle to produce
inside it on the ink ribbon that scores get created
Working creates marks over the surface and over the surface
then ink spreads throughout the and then ink
paper. spreads throughout
the journal.

Latest type of
History First kind of printers
printers

Have banging noise of needle on Do not have any


Noise
paper noise

Slower speeds
Faster speeds around 250 words per
Speed around 1 page per
second.
30 seconds.

A type of printer
that produces
Produces characters and graphics on
characters and
Type a piece of paper by striking it is
graphics on a piece
called impact printer.
of paper without
striking.

Dot-matrix printer,
inkjet printers, photo printers, laser Daisy wheel
Example
printers, etc. printers, line
printer, etc.
LINE DRAWING ALGORITHMS

What is an ideal line

• Must appear straight and continuous

• Must interpolate both defining end points

• Must have uniform density and intensity

• Must be efficient, drawn quickly

A line connects two points. It is a basic element in graphics. To draw a line, you need two points
between which you can draw a line. In the following three algorithms, we refer the one point of line
as X0,Y0 and the second point of line as X1,Y1

Scan Line - DDA Algorithm


Digital Differential Analyzer (DDA) algorithm is the simple line generation algorithm which is
explained step by step here.
Step 1 − Get the input of two end points (X0,Y0) and (X1,Y1).
Step 2 − Calculate the difference between two end points.
dx = X1 - X0
dy = Y1 - Y0
Step 3 − Based on the calculated difference in step-2, 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.
if (absolute(dx) > absolute(dy))
Steps = absolute(dx);
else
Steps = absolute(dy);
Step 4 − Calculate the increment in x coordinate and y coordinate.
Xincrement = dx / (float) steps;
Yincrement = dy / (float) steps;
Step 5 − Put the pixel by successfully incrementing x and y coordinates accordingly and complete the
drawing of the line.
for(int v=0; v < Steps; v++)
{
x = x + Xincrement;
y = y + Yincrement;
putpixel(Round(x), Round(y));
}

Bresenham’s Line Generation algorithm


The Bresenham 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, Xk+1, the vertical separations from the mathematical line
are labelled as dupper and dlower.

From the above illustration, the y coordinate on the mathematical line at xk+1 is −
Y = m (Xk+1) + b
So, dupper and dlowerare given as follows –

dlower = y−yk
= m(Xk+1)+b−Yk
and
ydupper=(yk+1)−y

=Yk+1−m(Xk+1)−b

You can use these to make a simple decision about which pixel is closer to the mathematical line. This
simple decision is based on the difference between the two pixel positions.
 dlower−dupper=2m(xk+1)−2yk+2b−1

Let us substitute m with dy/dx where dx and dy are the differences between the end-points.

dx(dlower−dupper)=dx(2dy/dx(xk+1)−2yk+2b−1)

=2dy.xk−2dx.yk+2dy+2dx(2b−1)
=2dy.xk−2dx.yk+C

So, a decision parameter Pk for the kth step along a line is given by −
pk=dx(dlower−dupper)pk
=dx(dlower−dupper)

=2dy.xk−2dx.yk+C
The sign of the decision parameter Pk is the same as that of dlower−dupper.
If pk is negative, then choose the lower pixel, otherwise choose the upper pixel.
Remember, the coordinate changes occur along the x axis in unit steps, so you can do
everything with integer calculations. At step k+1, the decision parameter is given as –

pk+1=2dy.xk+1−2dx.yk+1+C
Subtracting pk from this we get –

pk+1−pk=2dy(xk+1−xk)−2dx(yk+1−yk)
But, xk+1 is the same as (xk)+1. So –
pk+1=pk+2dy−2dx(yk+1−yk)
Where, Yk+1–Yk is either 0 or 1 depending on the sign of Pk.
The first decision parameter p0 is evaluated at (x0,y0) is given as −
p0=2dy−dx

Now, keeping in mind all the above points and calculations, here is the Bresenham
algorithm for slope m < 1 −

Step 1 − Input the two end-points of line, storing the left end-point in (x0,y0).
Step 2 − Plot the point (x0,y0).
Step 3 − Calculate the constants dx, dy, 2dy, and (2dy – 2dx) and get the first value
for the decision parameter as −
p0=2dy−dx
Step 4 − At each Xk along the line, starting at k = 0, perform the following test −
If pk< 0, the next point to plot is (xk+1,yk) and
pk+1=pk+2dy
Otherwise,
(xk,yk+1)
pk+1=pk+2dy−2dx

Step 5 − Repeat step 4 (dx – 1) times.

For m > 1, find out whether you need to increment x while incrementing y each time.

After solving, the equation for decision parameter Pk will be very similar, just the x and
y in the equation gets interchanged.

Bresenham’s Midpoint Circle algorithm -


Drawing a circle on the screen is a little complex than drawing a line. The algorithm is based on the idea of
determining the subsequent points required to draw the circle. Let us discuss the algorithms in detail −

The equation of circle is X2+Y2=r2, where r is radius.

We cannot display a continuous arc on the raster display. Instead, we have to choose the nearest pixel position
to complete the arc.

From the following illustration, you can see that we have put the pixel at (X, Y) location and now need to
decide where to put the next pixel − at N (X+1, Y) or at S (X+1, Y-1).
This can be decided by the decision parameter d.

 If d <= 0, then N(X+1, Y) is to be chosen as next pixel.


 If d > 0, then S(X+1, Y-1) is to be chosen as the next pixel.
Algorithm
Step 1 − Get the coordinates of the center of the circle and radius, and store them in x, y, and R respectively.
Set P=0 and Q=R.

Step 2 − Set decision parameter D = 3 – 2R.

Step 3 − Repeat through step-8 while P ≤ Q.

Step 4 − Call Draw Circle (X, Y, P, Q).

Step 5 − Increment the value of P.

Step 6 − If D < 0 then D = D + 4P + 6.

Step 7 − Else Set R = R - 1, D = D + 4(P-Q) + 10.

Step 8 − Call Draw Circle (X, Y, P, Q).

Draw Circle Method(X, Y, P, Q).

Call Putpixel (X + P, Y + Q).


Call Putpixel (X - P, Y + Q).
Call Putpixel (X + P, Y - Q).
Call Putpixel (X - P, Y - Q).
Call Putpixel (X + Q, Y + P).
Call Putpixel (X - Q, Y + P).
Call Putpixel (X + Q, Y - P).
Call Putpixel (X - Q, Y - P).

Mid Point Circle drawingAlgorithm


Step 1 − Input radius r and circle center (xc,yc) and obtain the first point on the circumference of the circle
centered on the origin as
(x0, y0) = (0, r)
Step 2 − Calculate the initial value of decision parameter as

P0 = 5/4 – r (See the following description for simplification of this equation.)

f(x, y) = x2 + y2 - r2 = 0

f(xi - 1/2 + e, yi + 1)

= (xi - 1/2 + e)2 + (yi + 1)2 - r2

= (xi- 1/2)2 + (yi + 1)2 - r2 + 2(xi - 1/2)e + e2

= f(xi - 1/2, yi + 1) + 2(xi - 1/2)e + e2 = 0

Let di = f(xi - 1/2, yi + 1) = -2(xi - 1/2)e - e2

Thus,

If e < 0 then di > 0 so choose point S = (xi - 1, yi + 1).

di+1 = f(xi - 1 - 1/2, yi + 1 + 1) = ((xi - 1/2) - 1)2 + ((yi + 1) + 1)2 - r2

= di - 2(xi - 1) + 2(yi + 1) + 1

= di + 2(yi + 1 - xi + 1) + 1

If e >= 0 then di <= 0 so choose point T = (xi, yi + 1)

di+1 = f(xi - 1/2, yi + 1 + 1)


= di + 2yi+1 + 1

The initial value of di is

d0 = f(r - 1/2, 0 + 1) = (r - 1/2)2 + 12 - r2

= 5/4 - r {1-r can be used if r is an integer}

When point S = (xi - 1, yi + 1) is chosen then

di+1 = di + -2xi+1 + 2yi+1 + 1

When point T = (xi, yi + 1) is chosen then

di+1 = di + 2yi+1 + 1

Step 3 − At each XK position starting at K=0, perform the following test −

If PK < 0 then next point on circle (0,0) is (XK+1,YK) and

PK+1 = PK + 2XK+1 + 1

Else

PK+1 = PK + 2XK+1 + 1 – 2YK+1

Where, 2XK+1 = 2XK+2 and 2YK+1 = 2YK-2.

Step 4 − Determine the symmetry points in other seven octants.

Step 5 − Move each calculate pixel position (X, Y) onto the circular path centered on (XC,YC) and plot the
coordinate values.

X = X + XC, Y = Y + YC
Step 6 − Repeat step-3 through 5 until X >= Y.

Вам также может понравиться