CG Unit1
CG Unit1
IMAGE REPRESENTATION
Image representation is the approximations of the real world displayed in a
computer.
A picture in computer graphics is represented as a collection of discrete picture
elements termed as pixels.
A pixel is the smallest element of a picture or object that can be represented on the
screen of a device like a computer.
Computer Graphics Application and Software
● Financial Reports
● Statistical Reports
7. Computer Art: Computer Graphics are also used in the field of commercial
arts. It is used to generate television and advertising commercials.
3.Trackball and Spaceball:- Trackball is ball that can be rotated with the finger
or palm of the hand to produce cursor movement. Potentiometer attached to the
ball measures the amount and direction of rotation. They are often mounted on a
keyboard or Z mouse. Space balls provide six degrees of freedom i.e. three
dimensional. In space ball strain gauges measure the amount of pressure applied to
the space ball to provide input for spatial positioning and orientation as the ball is
pushed or pulled in various directions. Space balls are used in 3D positioning and
selection operations in virtual reality systems, modeling, animation, CAD and
other applications.
4.Joysticks:- A joystick consists of a small vertical lever mounted on a base that is
used to steer the screen cursor around. Most joysticks select screen positioning
according to actual movement of stick (lever). Some joysticks work on
pressure applied on sticks. Sometimes the joystick is mounted on the keyboard or
sometimes used alone. Movement of the stick defines the movement of the cursor.
In pressure sensitive stick pressure applied on the stick decides movement of
the cursor. This pressure is measured using a strain gauge. These pressure
sensitive joysticks are also called isometric joy sticks and they are non-movable
sticks.
Data glove:- Data glove is used to grasp virtual objects. The glow is constructed
with a series of sensors that detect hand and figure motions. Electromagnetic
coupling is used between transmitter and receiver antennas which are used to
provide position and orientation of the hand. Input from the glove can be used to
position or manipulate objects in a virtual scene.
Optical method:- Optical touch panel employs a line of infrared LEDs along one
vertical and one horizontal edge. The opposite edges of the edges containing
LEDs contain light detectors. When we touch at a particular position the line of
light path breaks and according to that breaking line coordinate values are
measured. In case two line cuts it will take the average of both pixel positions.
LEDs operate at infrared frequency so it cannot be visible to the user.
Electrical method:- An electrical touch panel is constructed with two
transparent plates separated by a small distance. One is coated with
conducting material and the other is coated with resistive material. When the
outer plate is touched it will come into contact with the internal plate. When both
plates touch it creates voltage drop across the resistive plate that is converted
into coordinate values of the selected position.
Acoustical method:- In an acoustical touch panel high frequency sound waves are
generated in horizontal and vertical direction across a glass plate. When we
touch the screen the waves from that line are reflected from our fingers. These
reflected waves reach again at transmitter position and the time difference between
sending and receiving is measured and converted into coordinate values.
Light pens:- Light pens are pencil-shaped devices used to select positions by
detecting light coming from points on the CRT screen. Activated light pens
pointed at a spot on the screen as the electron beam lights up that spot and
generates an electronic pulse that causes the coordinate position of the electron
beam to be recorded.
Voice systems:- It is used to accept voice command in some graphics workstations.
It is used to initiate graphics operations. It will match input against a predefined
directory of words and phrases. Dictionary is set up for a particular operator by
recording his voice. Each word is spoken several times and then analyzes the
word and establishes a frequency pattern for that word along with
corresponding functions that need to be performed. When the operator speaks
command it will match with a predefined dictionary and perform the desired
action.
Active and Passive Graphics Devices
Advantages:
1. Higher Quality
3. Greater Productivity
Display Technologies
Components of DVST:
i) Two Electron Guns ii) Phosphor coated screen, iii) Storage grid mesh iv)
Collector
Working Principle:
● 1. There are two electron guns, namely primary gun and flood gun.
● 2. The primary gun stores the picture pattern and the flood gun maintains the
picture display.
● 3. A primary gun produces high-speed electrons, which strike on the storage
grid to draw the picture pattern.
● 4. Continuous low speed electrons from flood guns pass through the control
grid and get attracted to the positive charged areas of the storage grid.
● 5. The low speed electron then penetrates the storage grid and strikes the
phosphor coating.
● 6. During this process, the collector behind the storage grid smooths out the
flows of food electrons.
Advantage:
Disadvantages:
2.Cathode-ray-tubes
● CRT stands for Cathode Ray Tube. CRT is a technology used in traditional
computer monitors and televisions.
● The image on the CRT display is created by firing electrons from the back of the
tube of phosphorus located towards the front of the screen.
● Once the electron heats the phosphorus, they light up, and they are projected on
a screen. The color you view on the screen is produced by a blend of red, blue
and green light.
5. Phosphor-coated screen: The inside front surface of every CRT is coated with
phosphors. Phosphors glow when a high-energy electron beam hits them.
Phosphorescence is the term used to characterize the light given off by a phosphor
after it has been exposed to an electron beam.
● There are two techniques used for producing images on the CRT screen: i.
Vector scan/Random scan display. ii. Raster scan display.
Components: A CRT display unit with electron beam, Refresh display files,
Graphics controller.
Working Principle:
● A CRT, as a random scan display unit, has an electron beam 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.
● The component of a picture can be drawn and refreshed by a random scan
system in a specified order.
● A picture definition is stored as a set of line-drawing commands in an area
of memory called a refresh display file or refresh buffer.
● To display a specified picture, the system cycles through the set of
commands in the display file, drawing each component line one by one.
● After all line drawing commands have been processed, the system cycles
back to the first line command in the list and repeats the procedure of scan,
display, and retrace.
● Random scan displays draw all the component lines of a picture 30 to 60
times for each second.
● The faster refreshing of the set of lines could burn out the phosphor.
Therefore, when a small set of lines are to be displayed, each refresh cycle is
delayed to avoid greater refresh rates, typically 60 frames per second.
Random scan systems are designed for line drawing applications; hence it
cannot display realistic shaded scenes.
● Application program resides in system memory.
● Graphics packages translate the graphics commands in the application
program into a display file. Display file is also stored in system memory.
● Display processor accesses the content of the display file and displays it on
the monitor screen.
● Display processor retrieves one by one a command from the display file and
draws it on the screen.
● Display processor in a random scan system is also called a graphics
controller or display processing unit.
● Random scan devices render the scene using a short line.
● Electron beams track the line position directly, rather than going through
each and every pixel on screen. Entire scene is defined using a segment of
line in the application program.
Advantages:
1. A CRT has the electron beam directed only to the parts of the screen where
an image is to be drawn.
3. High Resolution
Disadvantages:
i. Beam-penetration technique
Beam-penetration technique
● This technique is used with random-scan monitors. In this technique, the
inside of CRT screen is coated with two layers of phosphor, usually red and
green.
● The displayed color depends on how far the electron beam penetrates into
the phosphor layers.
● The outer layer is of red phosphor and the inner layer is of green phosphor.
A beam of slow electrons excites only the outer red color.
● A beam of very fast electrons penetrates through the red layer and excites
the inner green layer.
● At intermediate beam speeds, combination of red and green light are emitted
and two additional colors, orange and yellow are displayed.
● The beam acceleration voltage controls the speed of electrons and hence the
screen color at any point on the screen.
Merits:
Demerits:
LCD displays.
Low cost.
Low weight.
Small size.
● Two registers are used to store the coordinates of the screen pixels which are
X and Y. Initially the X is set to 0 and Y is set to Ymax.
● The value stored in the frame buffer for this pixel is retrieved and used to set
the intensity of the CRT beam. After this X register is incremented by one.
● This procedure is repeated till X becomes equal to Xmax. Then X is set to 0
and Y is decremented by one pixel and repeat the above procedure.
● This whole procedure is repeated till Y becomes equal to 0 and completes
the one refresh cycle. Then controller reset the register as top –left corner i.e.
X=0 and Y=Ymax and the refresh process starts for the next refresh cycle.
● Since the screen must be refreshed at the rate of 60 frames per second the
simple procedure illustrated in figure cannot be accommodated by typical
RAM chips.
● To speed up pixel processing, the video controller retrieves multiple values
at a time using more numbers of registers and simultaneously refreshes
blocks of pixels.
● Such a way it can speed up and accommodate a refresh rate more than 60
frames per second.
Chapter 2 : Scan conversion
Problem-01:
Calculate the points between the starting point (5, 6) and ending point (8, 12).
Advantages of DDA algorithm
● It is a faster algorithm.
● It is a simple algorithm.
● It also does not provide smooth lines though accuracy has been improved.
Example: 1
1. This algorithm does not produce smooth results due to its integer arithmetic
as it fails to diminish the zigzags completely.
2. The Bresenhem’s circle drawing algorithm is not accurate in the case of
drawing of complex graphical images.
Example:
Midpoint Circle Algorithm
The points generation using Mid Point Circle Drawing Algorithm involves the
following steps-
Example:
1. Given the centre point coordinates (0, 0) and radius as 10, generate all the points
to form a circle.
2. Given the center point coordinates (4, -4) and radius as 10, generate all the points to
form a circle.
Advantages:
Disadvantages:
Algorithm
Step 1: Start
x=0 , y = ry
dy = 2 rx2 y
Plot (x,y)
if(P < 0)
Update x = x+1 ;
P += ry2 [2x + 3 ]
Else
Update x = x + 1
y= y - 1
If (P2 > 0)
else
x = x+1
y = y-1
Advantages:
Disadvantages:
Problems of Aliasing
● In computer graphics, the process by which smooth curves and other lines
become jagged because the resolution of the graphics device or file is not
high enough to represent a smooth curve.
● In the line or circle drawing algorithms, we have seen that all rasterized
locations do not match with the true line and we have to select the optimum
raster locations to represent a straight line.
● This problem is severe in low resolution screens. In such screens the line
appears like a stair-step. This effect is known as aliasing.
● The aliasing effect occurs when rasterized images have jagged edges,
sometimes called "jaggies" (an image rendered using pixels).
● Technically, jagged edges are a problem that arises when scan conversion is
done with low-frequency sampling, also known as under-sampling; this
under-sampling causes distortion of the image.
● Moreover, when real-world objects made of continuous, smooth curves are
rasterized using pixels, aliasing occurs.
● Smoothing and Anti Aliasing techniques can reduce the effect of aliasing.
1.Jagged Profiles
The picture on the left shows the sampling grid superimposed on the original
scene. The picture on the right is the rendered image. A jagged profile is quite
evident in the rendered image. Also known as "jaggies", jagged silhouettes are
probably the most familiar effect caused by aliasing. Jaggies are especially
noticeable where there is a high contrast between the interior and the exterior of the
silhouette.
2.Improperly rendering
The original scene on the left shows a group of small polygons. In the rendered
scene, one of the two red rectangles disappears entirely, and the other doubles in
width. Two of the orange triangles disappear. Although the two yellow triangles are
identical in size, one is larger than the other in the rendered image.
3.Disintegrating textures.
1.Point Clipping:
● Clipping a point from a given window is very easy. Consider the following
figure, where the rectangle indicates the window.
● Point clipping tells us whether the given point X,Y is within the given
window or not; and decides whether we will use the minimum and
maximum coordinates of the window.
● The X-coordinate of the given point is inside the window, if X lies in
between Wx1 ≤ X ≤ Wx2. Same way, the Y coordinate of the given point is
inside the window, if Y lies in between Wy1 ≤ Y ≤ Wy2.
2. Line Clipping
The concept of line clipping is the same as point clipping. In line clipping, we will
cut the portion of the line which is outside of the window and keep only the portion
that is inside the window.
1. Test a given line segment to determine whether it lies completely inside the
clipping window,
2. If it does not, we try to determine whether it lies completely outside the window.
3. If the line segment is not completely inside or completely outside, perform
intersection calculations with one or more clipping boundaries, with the use of
various line clipping algorithms.
● This algorithm uses the clipping window as shown in the following figure.
The minimum coordinate for the clipping region is (XW min, YWmin) and
the maximum coordinate for the clipping region is (XW max, YWmax).
● We will use 4-bits to divide the entire region. These 4 bits represent the Top,
Bottom, Right, and Left of the region as shown in the following figure. Here,
the TOP and LEFT bit is set to 1 because it is the TOP-LEFT corner.
Algorithm
Step 1 − Assign a region code for each endpoints.
Step 2 − If both endpoints have a region code 0000 then accept this line.
Step 3 − Else, perform the logical ANDoperation for both region codes.
Step 3.1 − If the result is not 0000, then reject the line.
Step 3.2.1 − Choose an endpoint of the line that is outside the window.
Step 3.2.3 − Replace endpoint with the intersection point and update the region
code.
Step 3.2.4 − Repeat step 2 until we find a clipped line either trivially accepted or
trivially rejected.
Step 4 − Repeat step 1 for other lines.
Example:
When pk < 0, as t increase line goes from the outside to inside (entering).
When pk = 0 and qk < 0 then line is trivially invisible because it is outside view
window.
When pk = 0 and qk > 0 then the line is inside the corresponding window
boundary.
Algorithm:
3.Clipping Polygons and Problem with multiple components
● An algorithm that clips a polygon must deal with many different cases. The
case is particularly noteworthy in that the concave polygon is clipped into
two separate polygons. All in all, the task of clipping seems rather complex.
● Each edge of the polygon must be tested against each edge of the clip
rectangle; new edges must be added, and existing edges must be discarded,
retained, or divided.
● Multiple polygons may result from clipping a single polygon. We need an
organized way to deal with all these cases.
● Polygons are clipped based on the window, the portion inside the window is
kept as it is and the portion outside the window is clipped.
● There are two types of polygons: (i) Concave (ii) Convex.
● (i) Concave polygon: It does not have any part of its diagonal in its exterior
and at least one angle should be greater than 180o .
● (ii) Convex polygon: It has at least one part of the diagonal in its exterior
and all angles should be less than 180o .
● Polygons can be clipped against each edge of the window one at a time.
Windows/edge intersections, if any, are easy to find since the X or Y
coordinates are already known.
● Vertices which are kept after clipping against one window edge are saved for
clipping against the remaining edges.
● Note that the number of vertices usually changes and will often increase.
● We are using the Divide and Conquer approach.
There are four possible cases for any edge of a given polygon against the current
clipping edge.
Procedure:
Case 1- Both vertices are inside: Only the second vertex is added to the output list.
Case 2 - First vertex is outside while second one is inside: Both the point of
intersection of the edge with the clip boundary and the second vertex are added to
the output list.
Case 3 - First vertex is inside while second one is outside: Only the point of
intersection of the edge with the clip boundary is added to the output list.
Case 4 - Both vertices are outside: No vertices are added to the output list.
Example:
Examples: