Computer Graphics Techniques Overview
Computer Graphics Techniques Overview
Jun • Transformation II
2023 •Bezier & B-Splines III
•Rectangle Line clipping II
• Clipping II
Dec • Basic - color models I
2023 • Transformation - Line II
• Algorithms I & II
• Transformation – triangle II
Computer graphics is the use of a computer to define,
store, manipulate, and represent the pictorial output.
Cognitive
1. Cathode-Ray Tube (CRT)
6. Plasma Display
7. 3D Display
Components:
Phosphorus-coated Screen:
Horizontal & Vertical Deflection The phosphorus coated screen is
Plates: These plates are used to guide the used to produce bright spots
path of the electron the beam. The plates when the high-velocity electron
produce an electromagnetic field that beam hits it.
bends the electron beam through the area
as it travels. [Link]
Random Scan (Vector scan) Raster Scan
Aka: Stroke-writing display or calligraphic •It is a scanning technique in which
• In this, the electron beam points only to covering one line at a time.
[Link]
Two basic color display producing techniques:
Beam Penetration Method: Shadow-Mask Method:
• It is used with a random scan monitor
• It is used with a raster scan monitor for
for displaying pictures.
displaying pictures.
• There are two phosphorus layers- Red
•It has more range of color than the beam
and Green are coated inside the
penetration method.
screen. The color shown depends on
•It is used in television sets and monitors.
how far the electron beam penetrates
the phosphorus surface
The emissive displays are devices that Displays use optical effects to convert
convert electrical energy into light. sunlight or light from some other source into
graphics patterns.
All LEDs are a subset of LCD TV All LCDs are not a subset of LED TV
Light emitting diodes are usually placed Fluorescent lights are usually placed behind
behind the screen or around the edges the screen
Digital Differential
Analyzer
A ( 0, 0 ) B( 8, 4 )
x1, y1 x2 , y2
dx = x2-x1 = 8 – 0 =8
dy = y2-y1 = 4 – 0 = 4
if |8| > |4| then T
steps= |8|= 8
xincr = 8 / 8 = 1
yincr = 4 / 8 = 1 / 2 = 0.5
0 0 1 0.5 1 1
1 0.5 2 1 2 1
2 1 3 1.5 3 2
3 1.5 4 2 4 2
4 2 5 2.5 5 3
5 2.5 6 3 6 3
6 3 7 3.5 7 4
Trace the Bresenham algorithm for drawing a line segment from (20,10) to (30,18)
A (20, 10) B (30, 18)
x1,y1 x2,y2
X= 20 ; y=10
dx = 30-20=10 m <= 1
dy = 18-10 = 8
m= dy / dx = 8 / 10 = 4 / 5 = 0. 8
Decision point:
P = 2dy – dx = 16 – 10 = 6
Pk >= 0 ; x + 1, y+1 2dx = 2 * 10 = 20 2dy-2dx=16 -20 =-4
Pk < 0 ; x + 1 2dy = 2 * 8 = 16
0 6 21 11 --- 6+16-20=6-4=2
1 2 22 12 ---- 2+16-20=2-4=-2
2 -2 23 12 -2+16=14 ---
3 14 24 13 ---- 14-4=10
4 10 25 14 ---- 10-4=6
5 6 26 15 ---- 6-4=2
6 2 27 16 ---- 2-4=-2
7 -2 28 16 -2+16=14 ----
8 14 29 17 ---- 14-4=10
9 10 30 18
k Pk xk+1 yk+1 Pk < 0 Pk >= 0
p = p + 2dy p = p + 2dy – 2dx
(20) (10)
0 6 21 11 --- 6+16-20=6-4=2
1 2 22 12 ---- 2+16-20=2-4=-2
2 -2 23 12 -2+16=14 ---
3 14 24 13 ---- 14-4=10
4 10 25 14 ---- 10-4=6
5 6 26 15 ---- 6-4=2
6 2 27 16 ---- 2-4=-2
7 -2 28 16 -2+16=14 ----
8 14 29 17 ---- 14-4=10
9 10 30 18
Ans: (21,11),(22,12),(23,12),(24,13),(25,14),(26,15),(27,16),(28,16),(29,17)
Trace the Midpoint algorithm for drawing a line segment from (4,8) to (9,12)
A (4, 8) B (9, 12)
x1,y1 x2,y2
X= 4 ; y=8
dx = 9 – 4 = 5 m <= 1
dy = 12 - 8 = 4
m= dy / dx = 4 / 5 = 0. 8
Decision point:
Output:
(4,8), (5,9),(6,10),(7,10),(8,11),(9,12)
CIRCLE DRAWING ALGORITHM
BRESENHAM MIDPOINT
COMPUTER GRAPHICS
Trace the Bresenham algorithm for drawing a line segment from (4,6) to (15,12)
A (4, 6) B (15, 12)
x1,y1 x2,y2
X= 4 ; y=6
dx = 15-4=11
dy = 12-6 = 6
m= dy / dx = 6 / 11 = 4 / 5 = 0. 5 m <= 1
Decision point:
P = 2dy – dx = 12– 11 = 1
Pk >= 0 ; x + 1, y+1 2dx = 2 * 11 = 22 2dy-2dx=12 -22 =-10
Pk < 0 ; x + 1 2dy = 2 * 6 = 12
0 1 5 7 --- 1-10=-9
1 -9 6 7 -9+12=3 ---
2 3 7 8 --- 3-10=-7
3 -7 8 8 -7+12=5 ---
4 5 9 9 ---- 5-10=-5
5 -5 10 9 -5+12=7 ---
6 7 11 10 7-10=-3
7 -3 12 10 -3+12=9 ---
8 9 13 11 ---- 9-10=-1
9 -1 14 11 -1+12=11
CIRCLE DRAWING ALGORITHM
BRESENHAM MIDPOINT
Plot a circle having radius 10 units using bresenham algorithm:
r = 10 pk < 0 ;xk+1 = xk + 1
origin (0,0)
1st octant = 0,r = (0,10) pk >= 0 ;xk+1 = xk + 1,yk+1 = yk -1
p = 3 – 2 r = 3 -2(10)=3-20= -17
Pk < 0 Pk >= 0
K xk yk pk Xk+1 Yk+1 p = pk + 4xk + 6 p = pk + 4(xk - yk) + 10
2 2 10 -1 3 10 -1+4(2)+6=13 ---
3 3 10 13 4 9 ----- 13+4(3-10)+10=
13-28+10=-5
4 4 9 -5 5 9 -5+4(4)+6= - -----
5+16+6=17
5 5 9 17 6 8 ----- 17+4(5-9)+10=
17-16+10 =11
6 6 8 11 7 7 Stop when x>= y
Answer :
1st octant : (0,10),(1,10),(2,10),(3,10),(4,9),(5,9),(6,8),(7,7)
Plot a circle having radius 10 units using Midpoint algorithm:
r = 10
origin (0,0) pk < 0 ;xk+1 = xk + 1
1st octant = 0,r = (0,10) pk >= 0 ;xk+1 = xk + 1,yk+1 = yk - 1
p = 1 - r = 1 - 10= -9
Pk < 0 Pk >= 0
K xk yk Pk Xk+1 Yk+1 p = pk + 2xk + 3 p = pk + 2(xk - yk) + 5
(-9)
0 0 10 -9 1 10 -9 +2(0)+3=-6 -----
1 1 10 -6 2 10 -6+2(1)+3=-1 -----
2 2 10 -1 3 10 -1+2(2)+3=6 ---
3 3 10 6 4 9 ----- 6+2(3-10)+5=
6-14+5=-3
4 4 9 -3 5 9 -3+2(4)+3= - -----
3+8+3=8
5 5 9 8 6 8 ----- 8+2(5-9)+5=
8-8+5 =5
6 6 8 5 7 7 Stop when x>= y
Answer :
1st octant : (0,10),(1,10),(2,10),(3,10),(4,9),(5,9),(6,8),(7,7)
1st octant : (0,10),(1,10),(2,10),(3,10),(4,9),(5,9),(6,8),(7,7)
(x,y)
2nd octant : (10,0),(10,1),(10,2),(10,3),(9,4),(9,5),(8,6),(7,7)
(y,x)
3rd octant : (10,0),(10,-1),(10,-2),(10,-3),(9,-4),(9,-5),(8,-6),(7,-7)
(y,-x)
4th octant : (0,-10),(1,-10),(2,-10),(3,-10),(4,-9),(5,-9),(6,-8),(7,-7)
(x,-y)
5th octant : (0,-10),(-1,-10),(-2,-10),(-3,-10),(-4,-9),(-5,-9),(-6,-8),(-7,-7)
(-x,-y)
6th octant : (-10,0),(-10,-1),(-10,-2),(-10,-3),(-9,-4),(-9,-5),(-8,-6),(-7,-7)
(-y,-x)
7th octant : (-10,0),(-10,1),(-10,2),(-10,3),(-9,4),(-9,5),(-8,6),(-7,7)
(-y, x)
8th octant : (0,10),(-1,10),(-2,10),(-3,10),(-4,9),(-5,9),(-6,8),(-7,7)
(-x,y)
DDA BRESENHAM MIDPOINT
Advantage: Advantage: Advantage:
• Use Floating point (Real • Use Fixed point (Integer arithmetic) • Aka: Generalized Bresenham
arithmetic) so Simple to implement •This algorithm is efficient for
•Uses Multiplication and •Uses only subtraction & Addition scan conversion for drawing
Division Operation (Costly) operations geometric curves on raster
•Faster algorithm than the •Fast incremental algorithm than the display
direct line equation (y=mx+c) DDA •High accuracy & speed
•Do not use floating point operation
so no round-off
• Pointing accuracy is higher than
DDA algorithm
•High accuracy & Speed than
midpoint
Disadvantage: Disadvantage: Disadvantage:
• Floating point arithmetic •Anti-aliasing is not the part of the • Time consumption is high
operation and round-off the Bresenham’s circle drawing algorithm •Resulted line/circle is not smooth
value is time consuming (Straight lines cannot be
• Point position is not displayed straight because
accurate & Efficient distance between the pixel is not
equal)
Polygon – A closed planer path composed of a finite number of sequential line segments
Types of Ploygon Filling Algorithm: Types of Polygon
1. Seed Fill Algorithm Boundary Fill Algorithm
Flood Fill Algorithm
2. Scan Fill Algorithm
Boundary Fill Algorithm -This algorithm picks a point inside
an object and starts to fill until it hits the boundary of the object.
• 4-Connected Polygon • 8-Connected Polygon
➢ Neighboring pixels are pixels on left, ➢ Neighboring pixels are left, right ,above,
right, above and below of current pixel. below and 4 diagonal pixels
Restrictions:
✓Starting point should be inside closed polygon.
✓For all edges of a polygon, boundary color should be same.
✓It may fail to fill in case some interior pixels are already filled with color.
Flood Fill Algorithm - Fill the area with multiple boundary colors.
Fundamental Geometrical
Transformation
Derived Geometrical
Transformation
Xnew = Xold + Tx
Translation is a process of moving
an object from one position to Ynew = Yold + Ty
another in a two dimensional plane.
Given a square with coordinate points A(0, 3), B(3, 3), C(3, 0), D(0, 0). Apply the translation with
distance 1 towards X axis and 1 towards Y axis. Obtain the new coordinates of the square.
Given-
Old coordinates of the square = A (0, 3), B(3, 3), C(3, 0), D(0, 0)
Translation vector = (Tx, Ty) = (1, 1)
Reflection On X-Axis:
Xnew = Xold
Ynew = -Yold
Reflection On Y-Axis:
Xnew = -Xold
Ynew = Yold
Given a triangle with coordinate points A(3, 4), B(6, 4), C(5, 6). Apply the reflection on the X axis and
obtain the new coordinates of the object.
Old corner coordinates of the triangle = A (3, 4), B(6, 4), C(5, 6)
Reflection has to be taken on the X axis
Q
Southerland Hodgeman(Convex polygon clipping)
(-1,0)
• To identify those parts of a scene that are visible from a chosen viewing position
❑ Property 2:
✓ They generally follow the shape of the control polygon, which consists of the segments
joining the control points.
✓ They always pass through the first and last control points.
❑ Property 3:
✓ The degree of the polynomial defining the curve segment is one less that the number of
defining polygon point. Therefore, for 4 control points, the degree of the polynomial is 3,
i.e. cubic polynomial.
Degree= Number of Control points - 1
❑ Property 4:
The order of the polynomial defining the curve segment is equal to the total number of
control points.
Order = Number of Control Points
❑ Property 5:
✓ Bezier curves exhibit global control means moving a control point alters the shape of the
whole curve. (points are not always on curve)
✓ Bezier curve are generated using the concept of approximation.
✓The curve line within the convex hull of its defining polygon.
✓Each basis function is positive or zero for all parameter values.
✓The maximum order of the curve is equal to the number of vertices of defining polygon.
✓The curve generally follows the shape of defining polygon.
✓The degree of B-spline polynomial is independent on the number of vertices of defining
Polygon
✓B-spline allows the local control over the curve surface because each vertex affects the shape
of a curve only over a range of parameter values where its associated basis function is nonzero.
B-Bias
t-tension
P0=(-2,0);P1=(-2,4);p2=(2,4);and P3=(2,0).
A. Bezier curve P(t) has degree 3 - True C. Bezier curve P(t) may extend
outside the convex hull of its control
Property 3: points – False
Degree= Number of Control points – 1
Property 1: Bezier curve always
Degree = 4 – 1 = 3 contained within a polygon called as
convex hull of its control points
Top
Side Front