CG
CG
COMPUTER GRAPHICS
6th Sem BCA
E-Mail:[email protected]
Website:www.vidyavahini.org/bca
ntroduction to Graphics
Chapter 1
Computer graphics is a picture that is generated by a computer; it converts a scene to an image or the
process of transformations, shading, and animation of the image.
• Then “Ben Laposky” created the first graphic images generated by an electronic machine.
• In the 1960‟s beginning of modern interactive graphics and vector graphics .One of the
• In 1990‟s , since the introduction of VGA[Video Graphics Array] and SVGA[Super Video
Graphics Array], pc could easily display the images and movies. 3D image become the main
advances and it helpsnematic
in ci Graphics applications.
3. Computer art
4. Entertainment
5. Educational and Training
6. Information visualization
7. Image processing
8. Information Graphics
9. Virtual Reality.
Computer Aided Design (CAD): it is a type of computer based tool used for drafting and
designing. CAD is useful in various designing fields such as architecture, mechanical and
electrical, automobiles, aircrafts, spacecrafts, textiles etc.
Presentation Graphics: it is used to produce bar charts, pie charts, line graphs, surface
graphs and other displays. Computer Graphics is applicable in financial, statistical,
mathematical, scientific data for research reports and other types of reports.
Computer Art:computer graphics methods are widely used in both fine art and commercial
art applications, artists use a variety of computer methods including special purpose hardware,
paint brush, animations, CAD etc.
Entertainment:computer Graphics methods are also used in making motion pictures, video games,
television shows, music videos etc.
Educational and Training: it is used in education and training. Computer generated models of
physical, financial and economic systems are often used, which helps trainee to understand the
operation of the system.
Image processing: it is a technique used to modify or interpret existing pictures. In image processing
methods we first digitize a photograph or other picture into an image file.
Information Graphics: it is also called as info graphics are Graphics Visual representation of
information, data or knowledge, these Graphics presents complex information quickly and
clearly such as signs, maths, generalism, technical writing and education.
Virtual Reality: it is a term that applies to computer simulated environments that can simulate places
in the real world as well as in imaginary world.
b) Type of Interaction: it determines the user control over the object and its image.
c) Role of Pictures: CAD application is used to drawing is just a representation of the object
being designed or analyzed.
d) Relationship b/w objects and their pictures: this category arises from the logical and
temporal relationship b\w objects and their pictures.
Graphics Software:
It is a program or collection of programs that enable a person to manipulate visual images on a
computer. Graphics software are classified into two types
b) Application Graphics Packages: it is designed for non programmers so that users can
generate and display without knowing how graphics operation works. Some
software‟s are photoshop, coraldraw, Microsoft paint, picasa etc.
its zero‟s and one‟s (0‟s & 1‟s) into corresponding video signal then the signal is transferred to the
TV monitor producing a black and white pattern on the screen.
Phosphorus used in graphic display, the electric energy is converted to light when the electron
beam fall on the phosphor coated screen
2. Persistence: how long small spots continue to emit light after the beam is moved or
removed is called persistence. Lower persistence requires higher refresh rate and
it‟s good for animation. Higher persistence is useful for displaying complex static
picture.
4. Aspect ratio: ratio between vertical points and horizontal points necessary to
produce equal length lines in both directions on the screen.
Aspect ratio=3/4
Vertical line with 3 points is equal in length to horizontal line of 4 points(pixels)
Picture definition is stored in a memory area called the frame buffer. This memory area holds
the set of int ensity values for all screen points. Stored intensity values are then retrieved from
the buffer and painted on the screen one row at a time. Each screen point is referred to as a pixel
(or) pel.
A bit value of 1 indicates that the electron beam is to be turned on at that position and a value
of 0 indicates that the beam intensity is to be off. Refreshing on raster scan display is carried
out at the rate of 60 to 80 frames/second. At the end of each scan line the electron beam returns
to the left side of the screen to begin displaying the next line. Returning to left screen after
refreshing each scan line is called horizontal retrace. Similarly when an electron beam returns to
the top left corner of the screen to begin next frame is called vertical retrace.
(i) Images can be displayed with realistic and includes 3D effects also.
(ii) The cost is very low compared to other devices.
Disadvantages:
(i) Costlier (or) over cost.
(ii) Difficult to display realistic images.
(iii) This technique cannot be used to draw complex images.
i) Beam – Penetration method. ii)
Shadow – mask method.
In order to provide a flicker free display the display processor must execute its program 30 to
60 times/sec.Graphic packages create a display program and tell the DPU where to start the
program. DPU then execute the display program until it is told to stop by graphics packages.
JUMP instruction at the end of display program transfers control back to its start, so that display
continues to start without CPU intervention.
Color Mapping
A color model is an abstract mathematical model describing the way colors can be represented
as Tupiles of numbers, typically as 3 (or) is values (or) color components. A color model is a
specification of 3D coordinate system.
Questions:
1. What is staircase effect?(1M,DEC 2011)
2. Define the terms refresh rate and aspect ratio. (1M,DEC 2011)
3. Explain any five applications of computer graphics.(5M,DEC 2011)
4. Explain functioning of CRT with a neat diagram.(9M,DEC 2011)
5. Explain RGB and CMY color models.(5M,DEC 2011)
6. Explain the concept of interactive graphics.(3M,DEC 2011)
7. Explain application computer graphics in education and health care.(3M,DEC 2011)
8. Discuss the working of a Beam penetration CRT, with a neat diagram.(5M,DEC 2011)
2 Chapter
Points and Lines
Point plotting techniques are based on Cartesian co-ordinate system where they are referred to
by their „x‟ and „y‟ co-ordinates.
X2– X1
b = Y1– mx1
The „Y‟ intercept „b‟ is
dy else
steps = dx
x1nc = dx | Steps
y1nc = dy | Steps
Bresenhams algorithm is designed such that each interaction changes one of the coordinate values by +
1 (or) – 1.
Algorithm: let (x1, y1) (x2, y2) = (10, 10) (15, 15)
Step 1 : Input two end points (x1, y1) & (x2, y2)
Step 2 : calculate dx = |x1
– x2| dy = |y1 –
• X inc and Y inc are calculated The increment value of X and Y is always based on the formula.
Unity.
Circle Generations
A circle is defined as the set of points that are all at a given distance „r‟ from a centre position (Xc, Yc).
(x-x c ) 2 +(y-y c ) 2 =r 2
The distance relationship is written as
Putpixel(Xc-X,Yc+Y,RED);
Putpixel(Xc+X,Yc-Y,RED);
Putpixel(Xc-X,Yc-Y,RED);
Putpixel(Xc+Y,Yc+X,RED);
Putpixel(Xc-Y,Yc+X,RED);
Putpixel(Xc+Y,Yc-X ,RED);
Putpixel(Xc-Y,Yc-X RED);}
An ellipse is defined as the set of points such that the sum of the distance from 2 fixed positions is
the same for all points. The ellipse has 2 access:
Color (i)
Line
Type :
Line Color:
Set the line color attribute with the command set Polyline ColorIndex (lc) Where, lc is a
non-negative values to allow color choices. Eg: Set Line type
(2);
Set Line width Scale Factor (2);
Set Polyline Color Index (4);
Area Filling:
The solid color filled (or) a pattern filled polygon is a standard o/p primitive of a graphics package.There
are 2 ways of area filling on rasters system.
(i) Using boundary definitions, identifying which pixels belongs to the interior of the area specified.
• For each scanline locate the intersection of the scanline with the edges.
• Generate frame buffer positions along the current scanline between each pair of intersections are
set to the specified fill color.
• When a scanline passes through a vertex, it intersects 2 polygon edges at that point and fills the
color.
Fill Styles:
There are 3 basic fill styles.
(i) Hallow with a color border.
(ii) Filled with a solid color.
(iii) Filled with specified pattern (or) design.
2. Character Height : It is defined as the distance between the base line and cap line of characters.
Doubling the height also doubles the character width and height between the characters. Eg:
Heigh 1
Height2
Height3
3. Character Width:The width of text can be set with the function “set Character Expansion Factor
(cw);” Where cw is a positive value.
The height dosenotchange by this attribute setting Eg:
width 1.0
W i d t h 2. 0
W i d t h 3.0
4. Character Spacing: The spacing between the characters can be changed with
“setCharacter Space (cs);”
Where cs can be assigned any real value. Eg:
spacing o.o
“Transformationis the
ability to rearrange a
picture so that its details
appear more clearly and
modifying the picture.”
2D TRANSFORMATION
Chapter 3 The basic Geometric
transformations are
(i) Translation: An object is re-positioning (moving) from one place to another place is known as
translation.
A 2 – dimensional point can be translated by adding translation distances tx and ty to the original coordinate
position (x, y), after moved the object the new positions are (Xnew, Ynew).
The translation distance pair T(tx, ty) is called the translation vector (or) shift vector.
(ii) Scaling:It is the ability to change the size of an image (or) object each vertex of an object has the scaling
factor Sr and Sy to produce the transformed co-ordinates.
p Pnew
Pnew= P*S
Xnew=x.Sx
Ynew=y.Sy
+ 𝜽)
Xnew= rcos 𝜱cos 𝜽-rsin 𝜱 sin 𝜽 Ynew=
angle.
3. Rotation
Other Transformations
1. Shear.
2. Reflection.
1. Shear: The shape of an object can be distorted by sliding the internal layers of the original object is
known as shear. Two common shearing transformations are (i) Shift X values.
Xnew=X+ Shx.Y
Ynew = Y
(b) Scaling :
To apply 2 successive scaling to an object, the concatenation of scaling matrices is performed and
then the composite matrices is applied to the co-ordinates points.
S(Sx1,Sy1).S(Sx2,Sy2)=S(Sx1.Sx2,Sy1.Sy2)
(c) Rotation
To apply 2 rotations to an object, we can first perform the concatenation of rotation matrices and then
apply the composite matrices to the co- ordinate point
Questions:
1. Give scaling factors to double the object size.(1M,DEC 2011)
2. Give matrix representation for reflection about X and Y axes. (1M,DEC 2011)
3. Explain 2 dimensional translations. (1M,DEC 2011)
4. Explain scaling transformation.(1M,DEC2011)
Chapter 4 Windowing
& Clipping
Normally graphical packages allow a user to specify what portion of the image is to be displayed
and where the image is to be displayed.
A convenient co -ordinate system which is used to define a reference frame of the picture forms the
world co-ordinates.
“A rectangular area of the display device, which will contain the picture to which a window is
mapped, is called a view port.”
The commands to set the window and view port areas from an application program may be defined as set
of pre-defined function.
Clipping
Whenever a window area is mapped onto a viewport, this results in the display of only
those parts of the picture within the window. All other portions of the picture which are outside
the window are discarded.
Clipping Operations
(i) Test whether the line segment lies completely inside the window.
(ii) Test whether the line segment lies completely outside the window.
(iii) If the line is neither completely inside nor outside the window, intersection calculations are
performed within the clipping boundaries.
This algorithm is invented by Dan Cohen and Ivan Sutherland, is very good for clipping picture that are
much larger than the screen.
If the 4 – bit code for both end – points are zero then the line lies entirely on the screen. If the logical
intersection AND of the 2 codes is not zero then the line must lie off the screen.
If the line cannot be eliminated, it must be divided. This can be done by finding the point of intersection of
the line with one edge of the screen and discard the part that lies off the screen.
3. Text Clipping:
(a) String Clipping: If the complete string is inside the clip window boundary, then we it to a
viewport otherwise the string is discarded.
The bounding rectangle for the curved object is first tested for ovelap (or) intersection
then the object is saved otherwise discarded.
Line clipping technique can also be applied to clip hallow polygons. Polygon clipping can
be done by clipping each component line using line clipping technique.
The Sutherland – Hodgeman algorithm is based on the fact it is easy to click a polygon against a single
must be retained but within the window boundary region is discarded is known as blanking (or)
The algorithm operates on the vertices of polygon, when each pair of vertices is passed to a window boundary
clipper. There are 4 possible techniques,
1. Left Clipper.
2. Top Clipper.
3. Right Clipper.
4. Bottom Clipper.
First left clipping is applied to the polygon starting from the intersection point, the outside
window boundary is discarded and the inside the window boundary will be saved. This procedure is
applied to the top clipper, right clipper and bottom clipper.
1. If the first vertex is outside the window boundary and the second vertex is inside the window
boundary, the intersection point of the polygon edge with the window boundary and the second
vertex is added to the output vertex list.
2. If both vertices is inside the window boundary, only the second vertex is added to the output vertex
list.
3. If the first vertex is inside the window boundary and the second vertex is outside, only the edge
intersection with the window is added to the output vertex list.
4. If both the input vertices are outside the window boundary nothing is added to the output vertex list.
The line is divided at its midpoint into 2 shorter line segments. The clipping categories of the 2 new line
segment are next computed using the region.
Category 2: Lines are not visible and lines outside the window.
Category 3: Lien is again divided into shorter segments and apply these 3 categories.
The midpoint co-ordinates (Xm, Ym) of a line (x1,y1) and (x2,y2) are given by xm=(x1+x2)/2 In
the above picture, we can determine the 2 intersection points A1 and B1 With 5 bisections using
midpoint subdivision algorithm.
Questions:
8. What are the different types of text clipping explain with example.
9. How is curve clipping performrd?
10. Distinguish between windows and viewport?
Chapter 5 Three
Dimensional Displays
Parallel projection involves generating a view of a solid object by projecting points on the object
surface along parallel lines onto the display plane.
By selecting different viewing positions we can project visible points of the object on the display plane and
obtain different 2 – Dimensional views of the object.
2. Perspective Projection:
For generating a view of a 3D object, the points are projected onto the display plane
along converging lines. This makes the objects which are far away from the viewing position
to be displayed smaller than the objects with the same size. If the object si nearer to the viewing
position to be displayed.
For generating a view of a 3 D object, the points are projected onto the display plane
along converging lines. This makes the objects which are far away from the viewing position
to be displayed smaller than the objects with the same size. If the object isnearer to the viewing
position to be displayed larger.
Using perspective projection, the images displayed look more realistic, since that is the way our
eyes (or) the camera, forms images.
Polygon Surfaces.
Any closed object can be classified as a polygon, i.e., any 3 – D object can be represented as a set of plain
polygon surfaces.
A 3 – D graphics object is generally represented using a set of surface polygons enclosing the
object interior. The object descriptions are stored as a set of surface polygons. Realistic images
can be produced by interpolating shaded patterns on the polygon surface.
Polygon Tables
A polygon surface is specified with a set of vertex co-ordinates and attributes parameters. The
information for each polygon is stored in data tables which are later used for processing display
and manipulation of the objects.
1. Geometric Table:It consists of vertex co-ordinates and parameters for identifying orientation of
polygon surface.
2. Attribute Table:it contains parameters specifying the degree of transparency, surface reflectivity
Another useful technique for solid modelling is to combine the volumes occupied by overlapping 3D
objects using set of operations. This method is called CSG.
It created a new object by applying the union, intersection and difference operation to two specified
objects.
(i) Union: A block and pyramid are placed adjacent to each other using union operation we obtain the
combined object.
(ii) Intersection: A block and a cylinder with overlapping volumes, using the intersection operation,
Fractal Geometry representations for objects are applied in many fields to describe the features
of natural phenomenon. In computer graphics we use fractal method to generate images of
natural objects and for viewing of various mathematical and physical systems.
A pplications of Fractals
1. Fractal representations are used for modelling clouds, water, trees, plants, etc.,
2. Fractal patterns are also found in distribution of stars, moon, music, traffic flow, etc.,
Classification of Fractals.
Bezier Curves
P Bezier pioneered the use of computer modelling of surfaces in automobile design. His method has been
applied to defin e the outer panels of several cause marketed by Reyna
Bezier defines the curve p (u) in terms of the location (n + 1) control points pi as a blending function B
I, n (u)
– face test can be done by considering a normal vector „N‟ with Cartesian co
ordinates (a,b,c) in a right – handed system viewing along the negative Z, axis.
If C < O the polygon is a back – face since the normal vector points away from the viewing position.
2 Buffer areas are required to store depth values and intensity. One a depth buffer is used to
store depth values for each (x, y) positions. Second is refresh buffer stores the intensity values
for each position.
An extension of scan l ine polygon filling with multiple surfaces, it is to intersect each polygon with a
particular scan line solving hidden surface problem. Across each scan line depth calculations are made
for each over lapping surface to determine which is nearest to the view plane.
Scan lines are processed from left to right. For the various surfaces 2 tables are used to store the
data.
(i) Edge Table: contains co-ordinate points for each line in the screen.
(ii) Polygon table: contains co-efficient of the plane equation for each surface.
Questions:
1. .Explain intensity cueing.(1M,DEC 2011)
2. Explain perspective projection technique.(1M,DEC 2011)
3. What is a cubic Bezier curve? What is the order of the polynomial for a cubic Bezier curve?
(5M,DEC 2011)
4. lustrate polygon tables with an example.(5M,DEC 2011)
5. Explain Depth-Buffer algorithm.(5M,DEC 2011)
6. Explain scan-line method for multiple surfaces.(5M,DEC 2011)
7. Explain union, intersection and differencesolid-geometry methods.(3M,DEC 2011) 8. Write
a short note on Graphical input techniques and octrees.(3M,DEC 2011)
9. What is Fractal? Explian.
10. Explain parallel and perspective projection?
Chapter 6
Segments
A segment is a set of output primitives that are joined for modification purpose.
Segments are the subdivision of pictures, segments are the visualization of a particular part of the
picture and we can apply translation scaling and rotation.
Segment Attributes
1. Visibility - Visibility of a segment can be set by the user with the function.
Questions:
1. Give any two functions for segmenting.(1M,DEC2011)
2. Explain storage of segment files. (1M,DEC2011)
3. Explain the attributes of segments?
achieve segment transformations, the user can specify the transformation like size, position
and orientation matrix which needs to be applied to the individual segments.
The Co-Ordinate information of the object can be entered using input devices.
Once the information has entered in it can be modified to re-arrange (or) reshape the object. We
see several techniques available in Graphical packages to construct the interactive pictures using
input devices.
Positioning Techniques
Positioning involves the user in the first moving cursor (or) tracking cross to the desired spot on
the screen and then notifying the computer by pressing a button (or) key. A single positioning
operation can be used to insert a symbol as in the picture and two succession can be defined the
end points of a line.
The user indicates a position on the screen with an input device and this position is used to insert
a symbol. Positioning is also known as locating.
Constraints
There are many kinds of constraints functions that can be specified, but the most common
Any selected position with the gravity field of a line is moved to the nearest position on the line.
Straight lines, Rectangles & circles can be constructed and positioned using RubberBandMethods.
We first select a screen position for one end point of the line, as the cursor moves around the line
stretches out from the starting position to the current position of the cursor. When we finally select
second position then it constructs line.
Options for sketching and drawing and painting comes in a variety of forms curved drawing can
be provided using standard curve shapes such as circular arcs with free hand sketching procedures.
In free hand drawing curves are generated by following the path of styles on graphic tablets (or)
the path of the screen cursor on a video monitor.
Pointing and selecting technique is used to select the picture parts that need modification.
Selection
Selection is a useful tool in the hands of the user for selecting the images.
When the user has positioned the curser over the object to select, we can press one of the several
keys according to the type of object. The selection can be one key to select a line, another to
select a point and a third one to select a symbol.
4. Prefix commands
The type of object to be selected can be determined by the user priori/previous choice of
command. The command is given before the selection and many specifies which type of object
is to be selected.
5. Modes
The user may be able to change the selection mechanism by setting different modes of
operation. In one mode the program allow only line selection and in another program allow
only the symbol selection.
Multiple Selections
The user must be able to select more than one element at a time. Multiple selection can be provided
in a no. of ways.
(i) To indicate the first and last element in the line sequence to be selected.
(ii) To select the element by specifying a bounding rectangle. (iii) The user
must select each one.
Menu Selection
Menu is displayed on the screen and the user points to the selection with a graphical input
device. Menus can be used for a variety of reasons.
Selection By Name
In this technique the user must type the name of the choice. If the user knows the names of
various objects, then referring to them by name would be reasonable and faster than pointing
method.
Selection by naming is also the best method for experienced and regular users. When the name
typed does not match one in the system, other name close to the typed name must be presented
to the user as alternatives.
Questions:
CHAPTER 8
Graphical Input Device
An input device is any peripheral device (piece of hardware) used to provide data and control
signals to an information processing system. All the computers have keyboard which is an input
device. The other input devices are Mouse, trackball, joystick, touchpad and Light pen.
Keyboard.
• It is an Input Device.
• It is design came from typewriter.
• A person can type document access menus, play games and perform variety of tasks.
The keys on computer keyboards are often classified as follows alphanumeric keys,
punctuation keys and special keys.
Types of Mouse:
Actions:
1. Pointing: Points to a particular object on the screen.
2. Single click: It selects the object.
3. Double click: It opens selected files.
4. Right click: Displays a popup menu corresponding to the selected object.
5. Drag and Drop: Dragging the one object to another location.
Advantages:
1. Easy to use
2. Low cost
3. No need to type commands
4. Easy to select menus and open them
Touch Pad
It is pointing devices consists of specialized surface and translate the motion and position of a
user‟s finger to relative position on screen.
Touchpad‟s are small sensitive tablets commonly used on laptop computers.
Most Touchpad supports support an absolute mode to allow Asian language to input or
signature.
Touchpad typically respond in relative mode because of the small size of the pad.
Features
1. They are commonly used for laptops.
2. Used as a substitute for a computer mouse.
3. Touch pads vary in size but are rarely made larger than 40 square centimetres.
A basic touch pad has 3 main components.
1. Touch sensor.
2. Controller.
3. Software driver.
Trackball
It is a computer cursor control device that can be rotated with the fingers (or) palm of the
hand.
It was invented by Tom Cranston and Fred Long staff as part of the Royal Canadian
Navy‟s DATAR system in 1952.
Compared with a mouse, a trackball has no limits on effective travel; a mouse can reach an edge
of its working area.
A Trackball is a ball that can be rotated with the fingers to produce screen cursor
movement. Potentiometers attached to the ball measure the amount and directions of rotation.
Trackball are used for three dimensional positioning and selection operations in virtual systems.
Joystick:
It is an input device consisting of a stick that pivots on a base and reports its angle or direction to
the device it is controlling.