These slides are containing basic concept of Computer Graphics with the cooperation of various resources.
We have targeted to visit various field of Computer graphics which can be beneficial for any beginner that they can follow the basic concept with the help of various pictures and diagrams.
The quality of Image and their presentation is very important parameter by which we can upgrade the quality of teaching and learning process .
The Vector or Bit map method,involves the full orientation of image drying with the help of parameters which is bets for the area of computer graphics.
1. UNIT-1
Introduction to Computer Graphics
Computer Graphics is the area where we study about
audio,vedeo and animation of the objects or we can also
say that drawing pictures on the screen is also called
computer graphics.
We can also say that its an art of drawing pictures on
computer screen with the help of programming.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 1
2. APPLICATION OF COMPUTER GRAPHICS
Computer graphics user interfaces (GUIs) – A graphic, mouse-oriented
paradigm which allows the user to interact with a computer.
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 .
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 2
3. Types of computer graphics
Basically there are two types of computer graphics
Raster Graphics
Raster graphics can be prepared with the help of individual pixels & Its
also called Bitmap images. A bitmap image contains a grid of individual
images
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 3
4. Vector Graphics
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. Its also useses mathematical
relationship between points & path.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 4
5. Frame Buffer & video controller
A frame buffer is a memory of contiguous location & Typically it is stored
in the memory chips on the video adapter.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 5
6. Video controller
It is used to control the operation of the display device (Monitor/Screen).
Video controller accesses the frame buffer to refresh the screen. In figure,
the basic refresh operations of the video-controller are shown.
Raster System
Register 1 Register 2
Memory References
Frame Buffer
Pixel
Record
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 6
7. Line Drawing Algorithms
For drawing a line we need two end points so there are some algorithms
that provide line generation.
We know that Y=Mx + C
Where M=(Y2-Y1)/(X2-X1)
DDAAlgorithm: The full name of this algorithm is Digital
Differential Analyzer & the basics concept of this algo is as follows
1.A line can be specified in the form: Y=mx+c
2.Let m be between 0 to 1, then the slope of the line is between 0 and 45
degrees.
3. For the x-coordinate of the left end point of the line, compute the
corresponding y value according to the line equation. Thus we get the left
end point as (x1,y1), where y1 may not be an integer
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 7
8. 4. Calculate the distance of (x1,y1) from the center of the pixel immediately
above it and call it D1.
5.Calculate the distance of (x1,y1) from the center of the pixel immediately below
it and call it D2.
6.If D1 is smaller than D2, it means that the line is closer to the upper pixel than
the lower pixel, then, we set the upper pixel to on; otherwise we set the pixel.
7. This method assumes the width of the line to be zero.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 8
9. The Bresenham’s algorithm
This is the another incremental scan conversion algorithm &
The major advantage of this algorithm is that, it uses only
integer calculations not the fraction. Moving across the x axis in
unit intervals and at each step choose between two different y
coordinates.
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 −
If pk < 0, the next point to plot is (xk+1,yk) and
pk+1=pk+2dy
Otherwise,
pk+1=pk+2dy−2dx
Step 5 − Repeat step 4 (dx – 1) times.
For m > 1, find out whether we need to increment x while
incrementing y each time.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 9
10. Circle Generation Algorithm
The first thing we can notice to make our circle drawing
algorithm more efficient is that circles centred at (0, 0) have
Eight-way symmetry
(x, y)
(y, x)
(y, -x)
(x, -y)(-x, -y)
(-y, -x)
(-y, x)
(-
x,y)
2
R
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 10
11. Mid Point Circle Generation Algo
Mid Point algo is the one of the circle generation algo which
is depend on eight point symmetry.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 11
12. BRESENHAM’S CIRCLE ALGORITHM
1. Set X = 0 and Y = R
2.Set D = -(-3 +2R)
3.Repeat While (X < Y)
4. Call Draw Circle(X1, Y1, X, Y)
5. Set X = X + 1
6. If (D < 0) Then
7. D = D + 4X + 6
8. Else
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 12
13. Continued……
9. Set Y = Y –1
10. D = D + 4(X –Y) + 10
[End of If]
11. Call Draw Circle(X1, Y1, X, Y)
[End of While]
12.Exit
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 13
16. Translation
A translation basically means adding a vector to a point, making a
point transforms to a new point
Changing the position of the object
P’(x’,y’)
Translated Place
P(x,y)
Original Place
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 16
19. Composite Transformation
It is a special type of transformation which consider various aspects
of transformation compare to basic.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 19
20. Composite Transformation
Some are as follows
1. Rotation about an arbitrary point
2. Scaling about a arbitrary Point
3. Reflection of an object about any line
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 20
22. Windowing & Clipping
windowing system is a system for sharing a computer's graphical display
presentation resources to various multiple applications at the same time
Clipping is the process of cutting the portion of the object with the help of specific
algorithm or dimension.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 22
23. Clipping
We need to clip objects outside the canonical
view volume
Clipping lines (Cohen-Sutherland algorithm)
Clipping polygons (Sutherland-Hodgman algorithm)
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 23
26. Line Clipping Algo.
1. Cohen Sutherland Line clipping algo.
2.Liang Barsky line clipping algo.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 26
27. Cohen–Sutherland algo
This algo is used for line clipping & follow the divide-and-
conquer strategy.
The algorithm divides a two-dimensional space into 9 regions
Efficiently determines the lines and portions of lines that are
visible in the centre region of interest (the viewport).
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 27
28. Cohen–Sutherland algo
Given a line segment with endpoint A(q1,q2) and B(q2,q3)
Compute the 4-bit codes for each endpoint.
If both codes are 0000,(bitwise OR of the codes yields 0000 )
line lies completely inside the window
If both codes have a 1 in the same bit position (bitwise AND
of the codes is not 0000), the line lies outside the window.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 28
29. Continued….
If a line cannot be trivially accepted or rejected, at least one of the
two endpoints must lie outside the window and the line segment
crosses a window edge.
Examine one of the endpoints, say P1=(q1,q2) . Read P1 as 4-bit code
in order: Left-to-Right, Bottom-to-Top.
When a set bit (1) is found, compute the intersection I of the
corresponding window edge with the line from to . P1 to P2 Replace
P1 with I and repeat the algorithm.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 29
31. Liang Barsky algorithm
Liang and Barsky have created an algorithm that uses floating-point
arithmetic but finds the appropriate end points with at most four
computations
Express line segments in parametric form.
Derive equations for testing if a point is inside the window
Compute new parameter values for visible portion of line segment, if
any
Display visible portion of line segment
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 31
32. Liang Barsky algorithm
Read two end points of line P1 (x1, y1) and P2 (x2, y2)
Read two corner vertices, left top and right bottom of
window: (XwMIN, YwMAX) and (XwMAX, YwMIN)
Calculate values of parameters pi and qi for I =1, 2, 3, 4
such that
p1 = -Δx
q1 = x1 – XwMIN
p2 = Δx
q2 = XwMAX – xi
q1 = – Δy
q3 = y1 – YwMIN
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 32
33. Continued….
q2 = Δy
q4 = YwMAX – y1
If pi = 0 then,
{
Line is parallel to ith boundary.
If qi < 0 then,
{
Line is completely outside the boundary. Therefore, discard
line segment and Go to Step 10.
}
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 33
34. Continued….
else
If line endpoints lie within the bounded area then
use them to draw line. Otherwise use boundary
coordinates to draw line. Go to Step 10.
Initialize t1 = 0 and t2 = t1
Calculate values for qi/pi for i= 1,2,3,4
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 34
35. Continued….
Select values of qi/pi where pi<0 and assign maximum out of them
as t1.
Select values of qi/pi where pi>0 and assign maximum out of them
as t2.
If (t1 < t2)
{
Calculate endpoints of clipped line:
xx1 = x1 + t1 Δx
xx2 = x1 + t2 Δx
yy1 = y1 + t1 Δy
yy2 = y1 + t2 Δy
Draw line (xx1, yy1, xx2, yy2)
}
Stop.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 35
38. Sutherland Hodgeman Algorithm
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
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 38
39. Sutherland …….
Note that the number of vertices usually changes and will often
increases.
We are using the Divide and Conquer approach.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 39
40. Conditions of Polygon Clipping Algo
C 1 : Wholly inside visible region - save endpoint
C 2: Exit visible region - save the intersection
C 3 : Wholly outside visible region - save nothing
C 4 : Enter visible region - save intersection and end point .
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 40
41. Steps of Sutherland …….
Step 1: Clip Right of the Boundary
Step 2: Clip Bottom Boundary
Step 3:Clip Left Boundary
Step 4:Clip Top Boundary
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 41
42. Weiler and Atherton polygon clipping
This algorithm is used for clipping concave polygons
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 42
43. Weiler and Atherton Algo.
In this algorithm we take a starting vertex like I1
And traverse the polygon like I1, V3, I2.
Leaving intersection the algorithm follows the clip polygon vertex list from
leaving vertex in downward direction.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 43
44. Weiler and Atherton Algo.
At occurrence of entering intersection the algorithm follows subject
polygon vertex list from the entering intersection vertex.
This process is repeated till we get starting vertex.
This process has to be repeated for all remaining entering
intersections which are not included in the previous traversing of
vertex list.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 44
45. TYPE OF TEXT CLIPPING
A. Stardust
B. Bitmap
C. Stroke
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 45
46. STARDUST
This method of character generation is called
stardust method because of its characteristics
appearance.
a code conversion software is used in it to display a
character .
A character quality is also poor.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 46
47. BITMAP
In bitmap method characters are represented by array of dots in the
matrix form.
It is 2D array that means having rows and columns.
Each dot in the matrix is pixel.
The value of pixel control the intensity of the pixel.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 47
48. STROKE
This method uses small line segments to generate a character
we can built our own stoke method character generate by call through the
line drawing algorithm.
In this method a fixed pattern of line segments are used to generate the
characters.
There are 24 line segments. out of these 24 line segments the segments
required to display for a particular character are highlighted.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 48
49. UNIT-III
3D Geometric Primitives
Polygon meshes and polyhedra are the geometric figures that are created
with a surface modeler.
A polygon mesh is a collection of edges, vertices and polygons connected
in such a way that each edge is shared by at most two polygons.
Polyhedra are volumetric solids, such as the cube or a sphere, represented
as facets.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 49
50. 3D Object Representation
Polygon and Quadric surfaces
Spline surfaces and construction
Procedural methods
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 50
52. Rotation
In 3D rotation, we have to specify the angle of rotation along with the axis
of rotation
Rotation about x-axis
X-Axis
Y Axis
Z Axis1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 52
53. Y Axis
X Axis
Z Axis
Rotation About Y Axis
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 53
54. Y Axis
X Axis
Z Axis
Rotation About Z Axix
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 54
55. 3D Viewing
For representing 3D-objects on a 2D -screen in a nice or recognizable
way, many techniques are combined. First, the projection has to be
defined, which will be described in the next paragraph
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 55
56. Possible Qualities
Wire-Frame-Representation: Only the edges of polygons are drawn.
Depth-Cueing = Edges or parts which are nearer to the viewer are displayed
with more intensity.
Correct Visibility = Surface-elements (edges, polygons), which are occluded
by other surface-elements, are not drawn so that only visible areas are shown.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 56
57. 3D-Viewing-Pipeline
Object
Coordinate
world Co. Viewing Co.
Projection Co.
Normdivice Co.
Device Coordinate
Creation of
Object
Creation of
Object
Definition Projection
Mapping
Transform to
specific region
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 57
58. Projections
Process of moving in positive with time through imaging of future events or
calculation based on past trends.
However, in computer graphics mainly only the parallel and the perspective
projection are used generally. In geometry science various types of
projections are known
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 58
62. For parallel projections, we specify a direction of projection instead of a
Centre of projection
There are two types of parallel projections:
Orthographic projection – DOP perpendicular to PP
Oblique projection --- DOP not perpendicular to PP
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 62
63. 3D Clipping
In 3D clipping you do everything in 3D space. Map graphics
are clipped to one side of an arbitrary clipping plane in one
or more clipping stages.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 63
64. Cohen Sutherland 3D Clipping Algo
The outcode for 3D clipping is a 6-bit code
Bit 1 - point above view volume
Bit 2 - point below view volume
Bit 3 - point to the right of view volume
Bit 4 - point to the left of view volume
Bit 5 - point behind view volume
Bit 6 - point in front of view volume
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 64
65. UNIT-IV
Bézier curve
A Bézier curve approximates any number of control points for a curve section
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 65
68. Blobby Object
A Blobby Object is non rigid object like
Like rubber,liquids,water droplets cloths etc.
These objects tend to exhibit a degree of fluidity
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 68
69. Continued….
Several models have been developed to handle
these kind of objects.
One technique is to use a combination of Gaussian
density functions (Gaussian bumps)
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 69
70. Spline Representations
A spline is a flexible strip used to produce a smooth curve through a designated
set of points
Small weights would be distributed along the strip to hold
it in position on the drafting table
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 70
71. Spline Specifications
There are three different ways to specify splines
state the set of boundary conditions that are imposed on the spline
state the matrix that characterizes the spline
state a set of blending/basis function that determines how specified constraints
on the curve are combined to calculate positions along the curve path
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 71
72. Boundary Condition Example
Boundary conditions may be the coordinates of x(0), x(1) and the derivatives
x’(0), x’(1). These four numbers are enough to fix ax, bx, cx, dx
After this representation we can connected to the other representations.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 72
73. Interpolation and Approximation Splines
To specify a spline we need to give a set of coordinate positions called control
points
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 73
76. Ambient Light
Approximates the indirect illumination
Equal amount of light from all directions
I K=(I is intensity of ambient light & K=percentage of the light
reflected by the object)
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 76
77. Lighting at a point on surface surface
I = Ikdcosθ
I=intensity of light
K=coefficient of diffuse reflection
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 77
79. Diffuse reflection
I = Idkd(N.L)
Id(N.L) is like the irradiance
kdI is like the reflectivit
No dependency on viewer
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 79
80. Specular reflection and Phong model
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 80
P
A
A2
81. Specular Component Component
One area depend on other
Some time depends on both
Numbers controls the view dependency.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 81
82. Intensity Attenuation
Providing enough control so that one can simulate
effect via trial and error of many different
parameters
May be not be close to the physical phenomenon
If we see different brightness of the same light can
be used for different component computation
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 82
83. Properties of Bézier curves
Passes through start and end points P0 & Pn.
First derivates at start and end
Lies in the convex hull
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 83
84. Shading
Independent of the Illumination model used
Phong Shading and Phong Illumination
Simple and hence widely used
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 84
85. Phong Shading
Calculate the illumination at every pixel using rasterization
Interpolate the normal across the triangle
Slower than Gauaurd
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 85
86. Gouraud Shading Shading
Edges get same color, irrespective of which triangle
they are rendered from Shading is continuous at edges
Tends to spread sharp illumination spots over the triangle
THANKS
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 86