I
jktunoteain
KTU STUDY MATERIALS | SYLLABUS | LIVE
NOTIFICATIONS l SOLVED QUESTION PAPERS
@ Website: www.ktunotes.in
CST 304
Computer Graphics and Image Processing
Syllabus
Module – 1 (Basics of Computer graphics and Algorithms)
Basics of Computer Graphics and its applications. Video Display
devices- Refresh Cathode Ray Tubes, Random Scan Displays and
systems, Raster scan displays and systems. Line drawing algorithms-
DDA, Bresenham’s algorithm. Circle drawing algorithms- Midpoint
Circle generation algorithm, Bresenham’s algorithm.
CST 304
Computer Graphics and Image Processing
Module – 2 (Filled Area Primitives and transformations)
Filled Area Primitives- Scan line polygon filling, Boundary filling and
flood filling. Two dimensional transformations-Translation, Rotation,
Scaling, Reflection and Shearing, Composite transformations, Matrix
representations and homogeneous coordinates. Basic 3D
transformations.
CST 304
Computer Graphics and Image Processing
Module - 3 (Clipping and Projections)
Window to viewport transformation. Cohen Sutherland Line clipping
algorithm. Sutherland Hodgeman Polygon clipping algorithm. Three
dimensional viewing pipeline. Projections- Parallel and Perspective
projections. Visible surface detection algorithms- Depth buffer
algorithm, Scan line algorithm.
CST 304
Computer Graphics and Image Processing
Module - 4 (Fundamentals of Digital Image Processing)
Introduction to Image processing and applications. Image as 2D data.
Fundamentalstepsinimageprocessing.Components of
Image representationinGrayscale,Binaryand Colour images.
image
processing system. Coordinate conventions. Sampling and quantization.
Spatial and Gray Level Resolution. Basic relationship between pixels–
neighbourhood, adjacency, connectivity. Fundamentals of spatial
domain-convolution operation.
CST 304
Computer Graphics and Image Processing
Module - 5 (Image Enhancement in Spatial Domain and Image
Segmentation)
Basic gray level transformation functions - Log transformations, Power-
Law transformations, Contrast stretching. Histogram equalization.
Basics of spatial filtering - Smoothing spatial filter- Linear and nonlinear
filters, and Sharpening spatial filters-Gradient and Laplacian.
Fundamentals of Image Segmentation. Thresholding - Basics of
Intensity thresholding and Global Thresholding. Region based Approach
- Region Growing, Region Splitting and Merging. Edge Detection - Edge
Operators- Sobel and Prewitt.
Module 1 - Basics of Computer Graphics and
Algorithms
Basics of Computer Graphics and its applications. Video Display
devices- Refresh Cathode Ray Tubes, Random Scan Displays and
systems, Raster scan displays and systems. Line drawing algorithms-
DDA, Bresenham’s algorithm. Circle drawing algorithms- Midpoint
Circle generation algorithm, Bresenham’s algorithm.
Basics of Computer Graphics
What is Computer Graphics?
• Computer Graphics includes all aspects of creating or synthesizing images
using a computer.
• Creation of images, Storage, Modelling of geometric objects and
Projecting 3D models onto 2D plane (Rendering) are part of Computer
Graphics.
• Displaying these images on computer screen or other hardcopy output
devices like printers, plotters etc. is also part of Computer Graphics.
Basics of Computer Graphics
Computer Graphics Vs Image Processing
• In Computer Graphics, computer is used to create a picture.
• In Image Processing, computer is used to modify or interpret existing
pictures.
Basics of Computer Graphics
Types of Computer Graphics – broadly divided into two:
• Non interactive (Passive) Computer Graphics – observer has no
control over the image. Example: Titles shown on TV
• Interactive Computer Graphics – involves two way communication
between computer and user. Example: Video games
Applications of Computer Graphics
• Computer Aided Design (CAD)
• Presentation Graphics
• Computer Art
• Entertainment (Animation, Games etc.)
• Education and Training
• Visualization (Scientific and Business)
• Image Processing
• Graphical User Interfaces
Applications of Computer Graphics
Applications of Computer Graphics
Computer Aided Design
Animations – real time animations using wire frame displays are helpful
in many industries
Animations in Virtual Reality environment
Architectural designs and visualization – 3D rendering and
walkthroughs
Applications of Computer Graphics
LEARN G ROW .E X C E L Dr
. Santízesíz P Matíze
SAINTGITS
Examples of presentation
graphics
30 Bananas Z9 CUCLlMbef5
30
20 Oranges
20
10 10 'Omat
Stcmrlrii ‹:l Line Cfini I Lin S n
Neural Networks – Loss Visualization
Applications of Computer Graphics
Applications of Computer Graphics
Applications of Computer Graphics
Applications of Computer Graphics
Applications of Computer
Graphics
• Gaming
• VR experience
Applications of Computer Graphics
Applications of Computer Graphics
Applications of Computer Graphics
Applications of Computer Graphics
Applications of Computer
Graphics
Applications of Computer Graphics
Applications of Computer Graphics
Applications of Computer Graphics
Applications of Computer Graphics
Applications of Computer Graphics
• Computer Aided Design (CAD)
• Presentation Graphics
• Computer Art
• Entertainment (Animation, Games etc.)
• Education and Training
• Visualization (Scientific and Business)
• Image Processing
• Graphical User Interfaces
Video Display Devices
Refresh Cathode Ray Tube
Video Display Devices
Refresh Cathode Ray Tube
Video Display Devices
– Refresh Cathode Ray Tube
Video Display Devices
– Refresh Cathode Ray Tube
How are spots of light produced on the CRT Screen?
• Spots of light are produced on the screen by the transfer of the
CRT beam energy to the phosphor.
• Part of the beam energy (kinetic) is converted by friction into
heat energyandtheremaindercauseselectrons in the
phosphor atoms to move up to higher quantum energy levels.
• After ashorttime,theexcitedphosphorelectrons
begin
dropping back to their stable ground state, giving up their
extra energy as small amounts of light energy.
• What we see on the screen is the combined effect of all the
electron light emissions and these spots of light quickly fading
as the phosphor electrons return to ground energy level.
Hence refreshing is done to retain the image.
Video Display Devices
– Refresh Cathode Ray Tube
Cutaway rendering of a color
CRT:
1.Three electron emitters
(for red, green, and blue
phosphor dots)
2. Electron beams
3. Focusing coils
4. Deflection coils
5. Connection for final
anodes
6.Mask for separating
beams for red, green, and b
lue part of the displayed
image
7.Phosphor layer
(screen)with red, green, and
blue zones
Video Display Devices
– Refresh Cathode Ray Tube
The rear of a 14-inch color cathode-ray tube showing its deflection coils
and electron guns
Video Display Devices
Some terms connected with the display screen:
• Persistence
Persistence is defined as the time it takes the emitted
light from the screen to decay to one tenth of its original
intensity.
• Resolution
The maximum number of points that can be displayed
without overlap on a CRT is referred to as the resolution.
• Aspect Ratio
This number gives the ratio of horizontal points to
vertical points (sometimes - vertical points to horizontal
points).
Video Display Devices
Here’s a breakdown of the different aspect ratios:
• 16:9 aspect ratio: (modern standard) 1366 x 768,
1600 x 900, 1920 × 1080, 3840 × 2160, 2560 × 1440
• 4:3 aspect ratio: (old standard) 1400 × 1050, 1440 ×
1080, 1920 × 1440
• 21:9 aspect ratio: (ultrawide) 2560 × 1080, 3440 ×
1440
• 32:9 aspect ratio: (superwide) 3840 × 1080
Video Display Devices
Video Display Devices
Video Display Devices
– Raster Scan Displays
Video Display Devices
– Raster Scan Displays
Video Display Devices
– Raster Scan Displays
Video Display Devices
– Raster Scan Displays
Video Display Devices
– Raster Scan Displays
Video Display Devices
Video Display Devices
– Random Scan Displays
Line Drawing algorithms
Line Drawing algorithms
Line Drawing algorithms
Line Drawing algorithms- DDA
m = (yk+1 – yk) /( xk+1 –xk)
Here we increment x by 1. So xk+1 -xk = 1
Therefore, m = (yk+1 – yk)/1
Yk+1 = yk + m
Here we increment y by 1 . So yk+1 – yk = 1
Hence: m = 1 / ( xk+1 – xk )
(xk+1 – xk ) = 1/m
xk+1 = xk + 1/m
Line Drawing algorithms - DDA
Xinc = dx/steps Yinc = dy/steps. When slope m<1, steps = dx and
Xinc = dx/dx =1. We need to increment x by 1 and calculate
corresponding y.
When slope m>1, steps =dy and Yinc = dy/steps =1 and
Xinc = dx/steps = dx/dy = 1/m We need to increment y by 1
and calculate corresponding x value.
when m>1, y
k+1 = yk + 1 xk+1
= xk + 1/m
when m<1,
xk+1 = xk + 1
yk+1 = yk + m
Line Drawing algorithms - DDA
Line Drawing algorithms - DDA
• Problem:
Use DDA line drawing algorithm to plot the line with end points (25,15)
and (35,18).
Line Drawing algorithms - DDA
Line Drawing algorithms - DDA
Problem 2:
x1, y1 = (15,25)
X2, y2 = (18,35)
Computer Graphics for engineering students.pptx
Bresenham’s Line Algorithm
.
LEARN G ROW .E X C E L Dr
. Santízesíz P Matíze
BRINTBITS
s ^¥'-It.H.G
CEL
!2
£16URE 3-BA mctiori of a
display screen where a
straight-line segment is to
be ploaed, starting &mthe
. Specified
—
FIGURE 2-9A gchon
of a disphy screen where s
I1ne se//nect
is
The Problem (cont…)
• What happens when we try to draw this on a pixel
based display?
How do we choose which pixels to turn
• In Bresenham’s line drawing algorithm the
incremental integer calculations are used to scan
convert the lines, that can be adapted to display
circles and the other curves as well.
?
??
?
• .The next sample positions can be plotted either at (3,2) or
(3,3) ?
?
?
(2,2) ?(3,2)
(3,3)
?
Computer Graphics for engineering students.pptx
Line Drawing algorithms – Bresenham’s
SRINTGITS
To illustraie Brewnham's approach, we first consider the scan«onversion
prŒCss Éor 1inŒ vilži posíŃ>’e slgpe les« than
.0. 7ixelgo«ÌtÌasss aÎong a line
path are Œen determined by sampÍing at unił s irlRrvals. Starting from the le8
endpoint (at, p) of a @ven line, we sRp to oach succmsive <olumn țr position) and plot the
pixel whnse scan-line ș valueis c
l
o
s
e
s
t to t
h
e hne pnh. Figue %
1
0 denionsłratm the
kth Sh«p č‹ this pu›cess. Æsumïng v
•
e ha‹'e d 't
e
rmiDe
dt
h
a
t ltte pixel at (z•t,
¡ș} is to be displeșed, we next need to decide which pixel to plot
in column x¡_; = Sp 4- 1. Our choices are the pixels ał pœitìons (xt + 1, q) and
-'i•i -› 'i -' '‹ . ‹
r›r»UfiŁ :t1‹ i
A sc,ti„„ of the
6€reõn shoTt•ing a pixel in
cnlumn xr on xan line g-
that G
s to be pIottød along
For lines with positive slope m<1
 The pixel positions on line can be identified by doing sampling along x
axis at unit intervals.
 The process of sampling begins from the pixel position (X0,Y0) and
proceeds by plotting the pixels whose ‘Y’ value is nearest to the line
path.
 If the pixel to be displayed occurs at a position (Xk, Yk) then the next
pixel is either at (Xk +1 ,Yk) or (Xk +1,Yk+1) i.e, (3,2) or (3,3)
 The ‘Y’ coordinate at the pixel position Xk+1 can be obtained from
Y=m(Xk+1)+b. . . . . . . . . . …….eq 1
Bresenham’s - for lines with positive
slope m<1
• the separation between (Xk+1,Yk) and (Xk+1,Y) is d1 and the
separation between (Xk+1,Y) and (Xk+1, Yk+1) is d2 then
• d1 = y – ykand
• d2 = (Yk+1) – Y
.
(Xk, yk+1) (Xk+1, yk+1)
d2
(xk+1,y)
P0
(Xk, yk)
d1
(Xk+1,yk)
Bresenham’s - for lines with positive
slope m<1
. . . . . . . …….eqn 1
y=m(Xk+1)+b d1=y
– yk ………..eqn 2
d1=m(xk+1)+b – Y
k
( from eqn (1)…..( 2)
And d2= (Yk+1) – Y
=(YK+1) – [m(Xk+1)+b]
=(YK+1) – m(Xk+1) – b…….(3)
The difference is given as
d1-d2 =
= m(Xk+1)+b-Yk
-[(Yk+1)-m(Xk+1)-
b]
Contd..
A decision parameter Pk can be obtained by substituting m= dy/dx in equation 4
d1 – d2 = 2m(Xk+1)-2Yk+2b – 1
= 2 dy/dx (Xk+1) – 2Yk + 2b – 1
= 2 dy(Xk+1)-2 dx.Yk + 2b.dx -
dx dx
dx(d1-d2) = 2 dy(Xk+1)-2 dx.Yk + 2b.dx - dx
= 2 dyXk+2 dy-2 dx.Yk + 2b.dx -dx
= 2 dyXk- 2 dx.Yk + c
Where, dx(d1-d2) = Pk andc= 2 dy+ dx(2b-1)
Pk = 2 dyXk- 2 dx.Yk + c . . . . . . . . . . . . . . . . . . . … …(5 )
The value of c is constant and is independent of the pixel position. It can be deleted in the recursive
calculations, of for Pk
if d1 < d2 then, Pk is negative (i.e, Yk is nearer to the line path than Yk+1)
If Pk is –ve, a lower pixel (Yk)is plotted else, an upper pixel (Yk+1)is plotted.
At k+1 step, the value of Pk is given as
PK+1 = 2 dyXk+1- 2 dx.Yk+1 + c …………………………………..(6 ) (from 5)
• Eq 6 – eq 5
• Pk+1 – Pk = (2 dyXk+1- 2 dx.Yk+1 + c ) - (2 dyXk+2 dx.Yk + c)
• = 2dy(Xk+1-Xk ) – 2 dx(Yk+1 – Yk ) ………….(7)
• Since Xk+1 = Xk +1The eqn 7 becomes
• Pk+1 – Pk = 2dy(Xk +1-Xk ) – 2 dx(Yk+1 – Yk )
• = 2dy - 2 dx(Yk+1 – Yk )
• Pk+1 = Pk + 2dy - 2 dx(Yk+1 – Yk )………………..( 8)
• Where (Yk+1 – Yk) is either 0 or 1 based on the sign of Pk (if Pk is –ve, Yk is not incremented: Yk+1 = Yk)
• The starting parameter P0 at the pixel position (X0,Y0) is given as
• P0 = 2dy – dx………………………(9)
y=mx+c is the eq of line
In col 2 the line is passing through x0+1 so
the y value is given by
y=m(x0+1)+c(green dot)
Now we need to find out the values of d1
and d2
d1= y-y0
d2=(y0+1)-y
d1=m(x0
+1) – y0
and d2= (y0
+1) - m(x0
+1)
d1-d2=[mx
0+m – y0] -
[(y0+1) - mx
0-m]
=mx0
+m –
y0 - y0
P0= 2∆y - ∆x
Col 1 Col 2
∆x(d1-d2) = 2∆y - ∆x
(X0, y0+1) (X0+1, y0+1)
d2
(x0+1,y)
P0
(X0, y0)
d1
(X0+1,y0)
Bresenham’s algorithm
• Step 1: Enter the 2 end points for a line and store the
left end point in (X0,Y0).
• Step 2: Plot the first point by loading (X0,Y0) in the
frame buffer.
• Setp 3: determine the initial value of the decision parameter
by calculating the constants dx, dy, 2dy and 2dy-2dx as
• P0 = 2dy –dx
• Step 4: for each Xk, conduct the following test, starting from k=
0
• If Pk <0, then the next point to be plotted is at (Xk+1, Yk) and
• Pk+1 = Pk + 2dy
• Note: Pk+1 = Pk + 2dy - 2 dx(Yk+1 – Yk ) ….here y values remain the same. Hence Yk+1 – Yk = 0
• Else, the next point is (Xk+1, Yk+1) and
• P = P + 2dy –2dx(step 3)
Example
• Let the given end points for the line be (30,20)and (40, 28)
• m = dy = y2 – y1= 28 – 20= 8
dx x2 – x140 – 30 = 10
• m =0.8
dy = 8anddx = 10
• The initial decision parameter P0
is
• P0 = 2dy – dx= 2(8) – 10 = 16 –
10= 6
P0 = 6
• The constants 2dy and 2dy-2dx
are
• 2dy = 2(8) = 16
2dy = 16
2dy-2dx = 2(8)- 2(10) =16 – 20 = -4
2dy – 2dx = - 4
The starting point (x0, y0)=(30,20) and the successive
pixel positions are given in the following table
dy = 8 and dx = 10 If Pk is +ve, Pk+1 = Pk + 2dy –2dx = Pk – 4 If Pk is –ve, Pk+1 = Pk+2dy = Pk+16
K Pk
(Xk+1, Yk+1)
0 6 (31,21)
1 2 (32,22
2 -2 33,22
3 14 34,23
4 10 35,24
5 6 36,25
6 2 37,26
7 -2 38,26
8 14 39,27
9 10 40,28
• End points (30,20)(40,28)
• dx=x2-x1=40-30=10dy= y2-y1=28-20=8
• P0=2dy-dx=2X8-10 = 6 >0
• Pk+1= pk+2dy-2dx= 6+16-20 =2 >0
• Pk+1=2+16-20 =-2 <0
• Pk+1= pk+2dy =-2+16 = 14 >0
• Pk+1= pk+2dy-2dx=14+16-20=10>0
• Pk+1=10+16-20=6 >0
• Pk+1= 6+16-20=2>0
• Pk+1=2+16-20=-2 <0
• Pk+1= pk+2dy=-2+16=14>0
• Pk+1=pk+2dy-2dx= 14+16-20=10>0
pt(31,21)
(32,22)
(
3
3
,
2
2
)
(34,23)
(35,24)
(
3
• In bresenham’s algorithm, if the positive slope of a line is greater than 1, the
roles of x and y are interchanged.
• For positive slope lines:
1. If the initial position of a line is the right end point, then both x and y are
decremented as we move from right to left.
2. If d1 = d2 then select the upper or the lower candidate pixel.
• For negative slope lines:
• One coordinate increases and the other coordinate decreases.
• Special cases:
• the vertical lines dx = 0, horizontal lines dy = 0 and diagonal lines |dx| =
|dy| can be directly loaded into the frame buffer.
Void LineBres( int x1, int y1, int x2, int y2)
{
int dx =abs(x2-x1), dy= abs(y2-y1)
int p=2* dy- dx ;
int x, y, Xend; // Xend is similar to steps in DDA
// Determine which point to start and which as
end If(x1>x2)
{
x=x2;y=y2;Xend=x1;
}
else
{
x=x1;y=y1;Xend=x2;
}
setPixel( x, y );
While( x < Xend)
{
x++;
if( p < 0)
p=p+2dy;
else
{
y++;
p=p+2dy-2
dx;
}
setPixel(x,y);
}// End While
}//End LineBres
Advantages of Bresenham’s Alg.
It uses only integer calculations
It is faster than DDA
Circle Drawing Algorithms
• Circle – As et of all points in a plane which are at a
fixed distance from a fixed point
• Circle Equation:
(Polynomial) -
When center is at (xc, yc) => (x-xc)2 + (y-yc)2= r2
(0,0)=> x2 + y2 = r2
Trigonometric (Polar coordinate) –
x = r cosӨ and y = r sinӨ
Circle Drawing Algorithms
Circle Drawing Algorithms
Polynomial Method of Circle representation
In this method, Circle is represented by a Polynomial Equation: x2 + y2 = r2
Here, this equation can be used to find ‘y’ coordinates for the known ‘x’ coordinates
– ‘r’ is also known.
The scan converting circle using this method is
achieved by stepping ‘x’ from 0 to r/√2 and each ‘y’
coordinate value Is found by evaluating √(r2-x2) for
each step of ‘x’.
This will generate 1/8 portion (900 to 450) of the
circle. Remaining for other octants are generated
the circle symmetry principle.
Circle Drawing Algorithms
Circle Drawing Algorithms
• Trigonometric / Polar CoordinateMethod:
x = r cosӨ and y = r sinӨ
where Ө is the current angle and x and y are the respective x and y
coordinates.
The scan convertingcircleusingPolar
coordinate method is achieved by
stepping Ө from 0 to 450and
calculating each x and y value. Using 1/8
symmetry concept remaining points in
other octants are found out.
This method is also quite inefficient and
time consuming because of the
repeated computation of sinӨ and
cosӨ.
Bresenham’s Circle Drawing Algorithm
This is an efficient circle drawing algorithm because it avoids
square root and trigonometric calculations. It involves only in
teger operations. 1/8th of a circle is plotted from 90o to 45o
where x moves in the positive direction and y in the negative
direction. 8 way symmetry of the circle is considered to
generate the remaining points.
Bresenham’s Circle Drawing
Algorithm
Circle equation can also be applied at A and B to get da and db respectively.
Bresenham’s Circle Drawing Algorithm
Bresenham’s Circle Drawing Algorithm
Circle eqn. can be applied at
points A and B to get d1 and
d2 respectively.
Bresenham’s Circle Drawing Algorithm
Bresenham’s Circle Drawing Algorithm
Bresenham’s Circle Drawing Algorithm
Bresenham’s Circle Drawing Algorithm
(xk, yk) = (0,r)
LEARN G ROW .E X C E L Dr
. Santízesíz P Matíze
BRIMTBIT
S
B
re
s
e
n
h
a
m
'
s circie drawing
algorithm
Algorithm:
ten-I: Input radius r and circle K
M
2Xc.Jq ) obtained the first point
(Xo, Yo) — (0.r)
Sitep-2: QIE$lnte the init»l value of decision p»ameter es
P -3 -Zr
.Step-3: At each Xs position starting at k = 0, peiTonn, the following test:
If Pz < 0, the next point is (Xe + 1, Yx)
Px+i = Pz + 4Xz + 6
otherwise the next point is (Nz + 1. 3"x — I )
as., =, • qx›—,) • io
Deteriiiiiie the symmetry points in other seven octant
fep—I:
?itep-fi: Move each pixel position (?£. Y) into circular pnth
.Uterv-Ii:Repeat step 3 to 5 until XY.
Bresenham’s Circle Drawing Algorithm
10)
Bresenham’s Circle Drawing Algorithm
Mid-Point Circle Algorithm
Mid-Point Circle Algorithm
• In the midpoint circle drawing algorithm, the midpoint
between two pixels along the circle path is first foun
d out.
• Using a decision variable, it is then checked whether
the midpoint is inside or outside the circle path. If the
midpoint is inside, the outside pixel is chosen and if it
is outside, the inside pixel is chosen.
• Circle is plotted from 90 to 45 degrees and ‘x’ moves in
the positive direction, while ‘y’ moves in the negative
direction.
• Points are identified for one octet and the remaining
points are found out using 8 way symmetry of the
circle.
Mid-Point Circle Algorithm
Mid-Point Circle Algorithm
Mid-Point Circle Algorithm
Mid-Point
Cir
cle Algori
thm
Mid-Point
Circle Alg
orithm
Mid-Point Circle Algorithm
Po = (1.25 – r) or (1 – r) when r is an integer
pk+1 = pk+2xk+3
pk+1 = pk+2(xk-yk)+5
pk+1 = pk+2(xk-yk)+5
pk+1 = pk+2xk+3
P0 = (1.25 – r)
~ (1 - r) for integer r
Mid-Point Circle Algorithm
• Calculate the points of a circle with radius 7 and
center at (10,10) using midpoint circle
algorithm. (x0, y0) =(0,r) = (0,7)
center (xc,yc) = (10,10)
d0 = 1-r = 1-7 = -6
k (xk, yk) dk (xk+1 +xc, yk+1 +yc)
0 (x0,y0)=(0,7) d0 = -6 (1,7) => (11,17)
1 (x1,y1)=(1,7) d1 = d0+2x0+3 = -6+2x0+3 = -3 (2,7) => (12,17)
2 (x2,y2)=(2,7) d2 = d1+2x1+3 = -3+2x1+3 = 2 (3,6) => (13,16)
3 (x3,y3)=(3,6) d3 = d2+2(x2-y2)+5 = 2+2(-5)+5 = -3 (4,6) => (14,16)
4 (x4,y4)=(4,6) d4 = d3+2x3+3 = -3+2x3+3 = 6 (5,5) => (15,15)
The points in this octet (90o to 45o) are (10,17), (11,17), (12,17), (13,16), (14,16), (15,15). At 45o,
x=y and we stop here. (We can stop when ‘y’ gets equal or less than x – or continue while y >= x)

More Related Content

PDF
Computer Graphics Notes 2.pdf
PPT
Introduction to Computer Graphics computer
PPT
Introduction to Computer Graphics elements
PPT
Unit I-cg.ppt Introduction to Computer Graphics elements
PPTX
dda algorithm-cg.pptx
PPTX
Computer graphics
PPTX
796680052-Computer-Graphics-PPT-CH1.pptx
PPTX
Computer Graphics Notes 2.pdf
Introduction to Computer Graphics computer
Introduction to Computer Graphics elements
Unit I-cg.ppt Introduction to Computer Graphics elements
dda algorithm-cg.pptx
Computer graphics
796680052-Computer-Graphics-PPT-CH1.pptx

Similar to Computer Graphics for engineering students.pptx (20)

PDF
Unit 2
PPTX
computer graphics-C/C++-dancingdollcode
PDF
Computer graphics notes
PDF
Computer graphics notes watermark
PPTX
PPTX
Computer_Graphics_Presentationa (1).pptx
PPTX
Unit 1 computer graphicss introduction .pptx
PPTX
Introduction with graphics
PDF
Introduction to computer graphics - Copy.pdf
PDF
Computer Graphics involves technology to access. The Process transforms and p...
PPTX
A concept of graphics
PDF
raster algorithm.pdf
PDF
Computer Graphics
PPTX
CG_ch1.pptx
PPT
Computer Graphics
PPTX
CG _LINE DRAWING_algorithm_Algorithm_frame_buffer.pptx
DOCX
Computer Graphics Practical
PDF
Midterm revision 2022 without answer.pdf
PPT
Lecture _Line Scan Conversion.ppt
Unit 2
computer graphics-C/C++-dancingdollcode
Computer graphics notes
Computer graphics notes watermark
Computer_Graphics_Presentationa (1).pptx
Unit 1 computer graphicss introduction .pptx
Introduction with graphics
Introduction to computer graphics - Copy.pdf
Computer Graphics involves technology to access. The Process transforms and p...
A concept of graphics
raster algorithm.pdf
Computer Graphics
CG_ch1.pptx
Computer Graphics
CG _LINE DRAWING_algorithm_Algorithm_frame_buffer.pptx
Computer Graphics Practical
Midterm revision 2022 without answer.pdf
Lecture _Line Scan Conversion.ppt
Ad

Recently uploaded (20)

PPTX
CS6006 - CLOUD COMPUTING - Module - 1.pptx
PDF
Mechanics of materials week 2 rajeshwari
PDF
electrical machines course file-anna university
PDF
Project_Mgmt_Institute_-Marc Marc Marc .pdf
PDF
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf
PDF
Principles of operation, construction, theory, advantages and disadvantages, ...
PPTX
BBOC407 BIOLOGY FOR ENGINEERS (CS) - MODULE 1 PART 1.pptx
PDF
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL
PPTX
AI-Reporting for Emerging Technologies(BS Computer Engineering)
PDF
Software defined netwoks is useful to learn NFV and virtual Lans
PPTX
Module1.pptxrjkeieuekwkwoowkemehehehrjrjrj
DOCX
ENVIRONMENTAL PROTECTION AND MANAGEMENT (18CVL756)
PDF
Lesson 3 .pdf
PDF
LS-6-Digital-Literacy (1) K12 CURRICULUM .pdf
PPT
Programmable Logic Controller PLC and Industrial Automation
PDF
Cryptography and Network Security-Module-I.pdf
DOCX
An investigation of the use of recycled crumb rubber as a partial replacement...
PPTX
INTERNET OF THINGS - EMBEDDED SYSTEMS AND INTERNET OF THINGS
PPTX
Environmental studies, Moudle 3-Environmental Pollution.pptx
PPTX
WN UNIT-II CH4_MKaruna_BapatlaEngineeringCollege.pptx
CS6006 - CLOUD COMPUTING - Module - 1.pptx
Mechanics of materials week 2 rajeshwari
electrical machines course file-anna university
Project_Mgmt_Institute_-Marc Marc Marc .pdf
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf
Principles of operation, construction, theory, advantages and disadvantages, ...
BBOC407 BIOLOGY FOR ENGINEERS (CS) - MODULE 1 PART 1.pptx
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL
AI-Reporting for Emerging Technologies(BS Computer Engineering)
Software defined netwoks is useful to learn NFV and virtual Lans
Module1.pptxrjkeieuekwkwoowkemehehehrjrjrj
ENVIRONMENTAL PROTECTION AND MANAGEMENT (18CVL756)
Lesson 3 .pdf
LS-6-Digital-Literacy (1) K12 CURRICULUM .pdf
Programmable Logic Controller PLC and Industrial Automation
Cryptography and Network Security-Module-I.pdf
An investigation of the use of recycled crumb rubber as a partial replacement...
INTERNET OF THINGS - EMBEDDED SYSTEMS AND INTERNET OF THINGS
Environmental studies, Moudle 3-Environmental Pollution.pptx
WN UNIT-II CH4_MKaruna_BapatlaEngineeringCollege.pptx
Ad

Computer Graphics for engineering students.pptx

  • 1. I jktunoteain KTU STUDY MATERIALS | SYLLABUS | LIVE NOTIFICATIONS l SOLVED QUESTION PAPERS @ Website: www.ktunotes.in
  • 2. CST 304 Computer Graphics and Image Processing Syllabus Module – 1 (Basics of Computer graphics and Algorithms) Basics of Computer Graphics and its applications. Video Display devices- Refresh Cathode Ray Tubes, Random Scan Displays and systems, Raster scan displays and systems. Line drawing algorithms- DDA, Bresenham’s algorithm. Circle drawing algorithms- Midpoint Circle generation algorithm, Bresenham’s algorithm.
  • 3. CST 304 Computer Graphics and Image Processing Module – 2 (Filled Area Primitives and transformations) Filled Area Primitives- Scan line polygon filling, Boundary filling and flood filling. Two dimensional transformations-Translation, Rotation, Scaling, Reflection and Shearing, Composite transformations, Matrix representations and homogeneous coordinates. Basic 3D transformations.
  • 4. CST 304 Computer Graphics and Image Processing Module - 3 (Clipping and Projections) Window to viewport transformation. Cohen Sutherland Line clipping algorithm. Sutherland Hodgeman Polygon clipping algorithm. Three dimensional viewing pipeline. Projections- Parallel and Perspective projections. Visible surface detection algorithms- Depth buffer algorithm, Scan line algorithm.
  • 5. CST 304 Computer Graphics and Image Processing Module - 4 (Fundamentals of Digital Image Processing) Introduction to Image processing and applications. Image as 2D data. Fundamentalstepsinimageprocessing.Components of Image representationinGrayscale,Binaryand Colour images. image processing system. Coordinate conventions. Sampling and quantization. Spatial and Gray Level Resolution. Basic relationship between pixels– neighbourhood, adjacency, connectivity. Fundamentals of spatial domain-convolution operation.
  • 6. CST 304 Computer Graphics and Image Processing Module - 5 (Image Enhancement in Spatial Domain and Image Segmentation) Basic gray level transformation functions - Log transformations, Power- Law transformations, Contrast stretching. Histogram equalization. Basics of spatial filtering - Smoothing spatial filter- Linear and nonlinear filters, and Sharpening spatial filters-Gradient and Laplacian. Fundamentals of Image Segmentation. Thresholding - Basics of Intensity thresholding and Global Thresholding. Region based Approach - Region Growing, Region Splitting and Merging. Edge Detection - Edge Operators- Sobel and Prewitt.
  • 7. Module 1 - Basics of Computer Graphics and Algorithms Basics of Computer Graphics and its applications. Video Display devices- Refresh Cathode Ray Tubes, Random Scan Displays and systems, Raster scan displays and systems. Line drawing algorithms- DDA, Bresenham’s algorithm. Circle drawing algorithms- Midpoint Circle generation algorithm, Bresenham’s algorithm.
  • 8. Basics of Computer Graphics What is Computer Graphics? • Computer Graphics includes all aspects of creating or synthesizing images using a computer. • Creation of images, Storage, Modelling of geometric objects and Projecting 3D models onto 2D plane (Rendering) are part of Computer Graphics. • Displaying these images on computer screen or other hardcopy output devices like printers, plotters etc. is also part of Computer Graphics.
  • 9. Basics of Computer Graphics Computer Graphics Vs Image Processing • In Computer Graphics, computer is used to create a picture. • In Image Processing, computer is used to modify or interpret existing pictures.
  • 10. Basics of Computer Graphics Types of Computer Graphics – broadly divided into two: • Non interactive (Passive) Computer Graphics – observer has no control over the image. Example: Titles shown on TV • Interactive Computer Graphics – involves two way communication between computer and user. Example: Video games
  • 11. Applications of Computer Graphics • Computer Aided Design (CAD) • Presentation Graphics • Computer Art • Entertainment (Animation, Games etc.) • Education and Training • Visualization (Scientific and Business) • Image Processing • Graphical User Interfaces
  • 13. Applications of Computer Graphics Computer Aided Design Animations – real time animations using wire frame displays are helpful in many industries Animations in Virtual Reality environment Architectural designs and visualization – 3D rendering and walkthroughs
  • 15. LEARN G ROW .E X C E L Dr . Santízesíz P Matíze SAINTGITS Examples of presentation graphics 30 Bananas Z9 CUCLlMbef5 30 20 Oranges 20 10 10 'Omat Stcmrlrii ‹:l Line Cfini I Lin S n
  • 16. Neural Networks – Loss Visualization
  • 21. Applications of Computer Graphics • Gaming • VR experience
  • 31. Applications of Computer Graphics • Computer Aided Design (CAD) • Presentation Graphics • Computer Art • Entertainment (Animation, Games etc.) • Education and Training • Visualization (Scientific and Business) • Image Processing • Graphical User Interfaces
  • 32. Video Display Devices Refresh Cathode Ray Tube
  • 33. Video Display Devices Refresh Cathode Ray Tube
  • 34. Video Display Devices – Refresh Cathode Ray Tube
  • 35. Video Display Devices – Refresh Cathode Ray Tube How are spots of light produced on the CRT Screen? • Spots of light are produced on the screen by the transfer of the CRT beam energy to the phosphor. • Part of the beam energy (kinetic) is converted by friction into heat energyandtheremaindercauseselectrons in the phosphor atoms to move up to higher quantum energy levels. • After ashorttime,theexcitedphosphorelectrons begin dropping back to their stable ground state, giving up their extra energy as small amounts of light energy. • What we see on the screen is the combined effect of all the electron light emissions and these spots of light quickly fading as the phosphor electrons return to ground energy level. Hence refreshing is done to retain the image.
  • 36. Video Display Devices – Refresh Cathode Ray Tube Cutaway rendering of a color CRT: 1.Three electron emitters (for red, green, and blue phosphor dots) 2. Electron beams 3. Focusing coils 4. Deflection coils 5. Connection for final anodes 6.Mask for separating beams for red, green, and b lue part of the displayed image 7.Phosphor layer (screen)with red, green, and blue zones
  • 37. Video Display Devices – Refresh Cathode Ray Tube The rear of a 14-inch color cathode-ray tube showing its deflection coils and electron guns
  • 38. Video Display Devices Some terms connected with the display screen: • Persistence Persistence is defined as the time it takes the emitted light from the screen to decay to one tenth of its original intensity. • Resolution The maximum number of points that can be displayed without overlap on a CRT is referred to as the resolution. • Aspect Ratio This number gives the ratio of horizontal points to vertical points (sometimes - vertical points to horizontal points).
  • 39. Video Display Devices Here’s a breakdown of the different aspect ratios: • 16:9 aspect ratio: (modern standard) 1366 x 768, 1600 x 900, 1920 × 1080, 3840 × 2160, 2560 × 1440 • 4:3 aspect ratio: (old standard) 1400 × 1050, 1440 × 1080, 1920 × 1440 • 21:9 aspect ratio: (ultrawide) 2560 × 1080, 3440 × 1440 • 32:9 aspect ratio: (superwide) 3840 × 1080
  • 42. Video Display Devices – Raster Scan Displays
  • 43. Video Display Devices – Raster Scan Displays
  • 44. Video Display Devices – Raster Scan Displays
  • 45. Video Display Devices – Raster Scan Displays
  • 46. Video Display Devices – Raster Scan Displays
  • 48. Video Display Devices – Random Scan Displays
  • 52. Line Drawing algorithms- DDA m = (yk+1 – yk) /( xk+1 –xk) Here we increment x by 1. So xk+1 -xk = 1 Therefore, m = (yk+1 – yk)/1 Yk+1 = yk + m Here we increment y by 1 . So yk+1 – yk = 1 Hence: m = 1 / ( xk+1 – xk ) (xk+1 – xk ) = 1/m xk+1 = xk + 1/m
  • 53. Line Drawing algorithms - DDA Xinc = dx/steps Yinc = dy/steps. When slope m<1, steps = dx and Xinc = dx/dx =1. We need to increment x by 1 and calculate corresponding y. When slope m>1, steps =dy and Yinc = dy/steps =1 and Xinc = dx/steps = dx/dy = 1/m We need to increment y by 1 and calculate corresponding x value. when m>1, y k+1 = yk + 1 xk+1 = xk + 1/m when m<1, xk+1 = xk + 1 yk+1 = yk + m
  • 55. Line Drawing algorithms - DDA • Problem: Use DDA line drawing algorithm to plot the line with end points (25,15) and (35,18).
  • 57. Line Drawing algorithms - DDA Problem 2: x1, y1 = (15,25) X2, y2 = (18,35)
  • 60. LEARN G ROW .E X C E L Dr . Santízesíz P Matíze BRINTBITS s ^¥'-It.H.G CEL !2 £16URE 3-BA mctiori of a display screen where a straight-line segment is to be ploaed, starting &mthe . Specified — FIGURE 2-9A gchon of a disphy screen where s I1ne se//nect is
  • 61. The Problem (cont…) • What happens when we try to draw this on a pixel based display? How do we choose which pixels to turn
  • 62. • In Bresenham’s line drawing algorithm the incremental integer calculations are used to scan convert the lines, that can be adapted to display circles and the other curves as well. ? ?? ?
  • 63. • .The next sample positions can be plotted either at (3,2) or (3,3) ? ? ? (2,2) ?(3,2) (3,3) ?
  • 65. Line Drawing algorithms – Bresenham’s
  • 66. SRINTGITS To illustraie Brewnham's approach, we first consider the scan«onversion prŒCss Éor 1inŒ vilži posíŃ>’e slgpe les« than .0. 7ixelgo«ÌtÌasss aÎong a line path are Œen determined by sampÍing at unił s irlRrvals. Starting from the le8 endpoint (at, p) of a @ven line, we sRp to oach succmsive <olumn țr position) and plot the pixel whnse scan-line ș valueis c l o s e s t to t h e hne pnh. Figue % 1 0 denionsłratm the kth Sh«p č‹ this pu›cess. Æsumïng v • e ha‹'e d 't e rmiDe dt h a t ltte pixel at (z•t, ¡ș} is to be displeșed, we next need to decide which pixel to plot in column x¡_; = Sp 4- 1. Our choices are the pixels ał pœitìons (xt + 1, q) and -'i•i -› 'i -' '‹ . ‹ r›r»UfiŁ :t1‹ i A sc,ti„„ of the 6€reõn shoTt•ing a pixel in cnlumn xr on xan line g- that G s to be pIottød along
  • 67. For lines with positive slope m<1  The pixel positions on line can be identified by doing sampling along x axis at unit intervals.  The process of sampling begins from the pixel position (X0,Y0) and proceeds by plotting the pixels whose ‘Y’ value is nearest to the line path.  If the pixel to be displayed occurs at a position (Xk, Yk) then the next pixel is either at (Xk +1 ,Yk) or (Xk +1,Yk+1) i.e, (3,2) or (3,3)  The ‘Y’ coordinate at the pixel position Xk+1 can be obtained from Y=m(Xk+1)+b. . . . . . . . . . …….eq 1
  • 68. Bresenham’s - for lines with positive slope m<1 • the separation between (Xk+1,Yk) and (Xk+1,Y) is d1 and the separation between (Xk+1,Y) and (Xk+1, Yk+1) is d2 then • d1 = y – ykand • d2 = (Yk+1) – Y . (Xk, yk+1) (Xk+1, yk+1) d2 (xk+1,y) P0 (Xk, yk) d1 (Xk+1,yk)
  • 69. Bresenham’s - for lines with positive slope m<1 . . . . . . . …….eqn 1 y=m(Xk+1)+b d1=y – yk ………..eqn 2 d1=m(xk+1)+b – Y k ( from eqn (1)…..( 2) And d2= (Yk+1) – Y =(YK+1) – [m(Xk+1)+b] =(YK+1) – m(Xk+1) – b…….(3) The difference is given as d1-d2 = = m(Xk+1)+b-Yk -[(Yk+1)-m(Xk+1)- b]
  • 70. Contd.. A decision parameter Pk can be obtained by substituting m= dy/dx in equation 4 d1 – d2 = 2m(Xk+1)-2Yk+2b – 1 = 2 dy/dx (Xk+1) – 2Yk + 2b – 1 = 2 dy(Xk+1)-2 dx.Yk + 2b.dx - dx dx dx(d1-d2) = 2 dy(Xk+1)-2 dx.Yk + 2b.dx - dx = 2 dyXk+2 dy-2 dx.Yk + 2b.dx -dx = 2 dyXk- 2 dx.Yk + c Where, dx(d1-d2) = Pk andc= 2 dy+ dx(2b-1) Pk = 2 dyXk- 2 dx.Yk + c . . . . . . . . . . . . . . . . . . . … …(5 ) The value of c is constant and is independent of the pixel position. It can be deleted in the recursive calculations, of for Pk if d1 < d2 then, Pk is negative (i.e, Yk is nearer to the line path than Yk+1) If Pk is –ve, a lower pixel (Yk)is plotted else, an upper pixel (Yk+1)is plotted. At k+1 step, the value of Pk is given as PK+1 = 2 dyXk+1- 2 dx.Yk+1 + c …………………………………..(6 ) (from 5)
  • 71. • Eq 6 – eq 5 • Pk+1 – Pk = (2 dyXk+1- 2 dx.Yk+1 + c ) - (2 dyXk+2 dx.Yk + c) • = 2dy(Xk+1-Xk ) – 2 dx(Yk+1 – Yk ) ………….(7) • Since Xk+1 = Xk +1The eqn 7 becomes • Pk+1 – Pk = 2dy(Xk +1-Xk ) – 2 dx(Yk+1 – Yk ) • = 2dy - 2 dx(Yk+1 – Yk ) • Pk+1 = Pk + 2dy - 2 dx(Yk+1 – Yk )………………..( 8) • Where (Yk+1 – Yk) is either 0 or 1 based on the sign of Pk (if Pk is –ve, Yk is not incremented: Yk+1 = Yk) • The starting parameter P0 at the pixel position (X0,Y0) is given as • P0 = 2dy – dx………………………(9)
  • 72. y=mx+c is the eq of line In col 2 the line is passing through x0+1 so the y value is given by y=m(x0+1)+c(green dot) Now we need to find out the values of d1 and d2 d1= y-y0 d2=(y0+1)-y d1=m(x0 +1) – y0 and d2= (y0 +1) - m(x0 +1) d1-d2=[mx 0+m – y0] - [(y0+1) - mx 0-m] =mx0 +m – y0 - y0 P0= 2∆y - ∆x Col 1 Col 2 ∆x(d1-d2) = 2∆y - ∆x (X0, y0+1) (X0+1, y0+1) d2 (x0+1,y) P0 (X0, y0) d1 (X0+1,y0)
  • 73. Bresenham’s algorithm • Step 1: Enter the 2 end points for a line and store the left end point in (X0,Y0). • Step 2: Plot the first point by loading (X0,Y0) in the frame buffer. • Setp 3: determine the initial value of the decision parameter by calculating the constants dx, dy, 2dy and 2dy-2dx as • P0 = 2dy –dx • Step 4: for each Xk, conduct the following test, starting from k= 0 • If Pk <0, then the next point to be plotted is at (Xk+1, Yk) and • Pk+1 = Pk + 2dy • Note: Pk+1 = Pk + 2dy - 2 dx(Yk+1 – Yk ) ….here y values remain the same. Hence Yk+1 – Yk = 0 • Else, the next point is (Xk+1, Yk+1) and • P = P + 2dy –2dx(step 3)
  • 74. Example • Let the given end points for the line be (30,20)and (40, 28) • m = dy = y2 – y1= 28 – 20= 8 dx x2 – x140 – 30 = 10 • m =0.8 dy = 8anddx = 10 • The initial decision parameter P0 is • P0 = 2dy – dx= 2(8) – 10 = 16 – 10= 6 P0 = 6 • The constants 2dy and 2dy-2dx are • 2dy = 2(8) = 16 2dy = 16 2dy-2dx = 2(8)- 2(10) =16 – 20 = -4 2dy – 2dx = - 4
  • 75. The starting point (x0, y0)=(30,20) and the successive pixel positions are given in the following table dy = 8 and dx = 10 If Pk is +ve, Pk+1 = Pk + 2dy –2dx = Pk – 4 If Pk is –ve, Pk+1 = Pk+2dy = Pk+16 K Pk (Xk+1, Yk+1) 0 6 (31,21) 1 2 (32,22 2 -2 33,22 3 14 34,23 4 10 35,24 5 6 36,25 6 2 37,26 7 -2 38,26 8 14 39,27 9 10 40,28
  • 76. • End points (30,20)(40,28) • dx=x2-x1=40-30=10dy= y2-y1=28-20=8 • P0=2dy-dx=2X8-10 = 6 >0 • Pk+1= pk+2dy-2dx= 6+16-20 =2 >0 • Pk+1=2+16-20 =-2 <0 • Pk+1= pk+2dy =-2+16 = 14 >0 • Pk+1= pk+2dy-2dx=14+16-20=10>0 • Pk+1=10+16-20=6 >0 • Pk+1= 6+16-20=2>0 • Pk+1=2+16-20=-2 <0 • Pk+1= pk+2dy=-2+16=14>0 • Pk+1=pk+2dy-2dx= 14+16-20=10>0 pt(31,21) (32,22) ( 3 3 , 2 2 ) (34,23) (35,24) ( 3
  • 77. • In bresenham’s algorithm, if the positive slope of a line is greater than 1, the roles of x and y are interchanged. • For positive slope lines: 1. If the initial position of a line is the right end point, then both x and y are decremented as we move from right to left. 2. If d1 = d2 then select the upper or the lower candidate pixel. • For negative slope lines: • One coordinate increases and the other coordinate decreases. • Special cases: • the vertical lines dx = 0, horizontal lines dy = 0 and diagonal lines |dx| = |dy| can be directly loaded into the frame buffer.
  • 78. Void LineBres( int x1, int y1, int x2, int y2) { int dx =abs(x2-x1), dy= abs(y2-y1) int p=2* dy- dx ; int x, y, Xend; // Xend is similar to steps in DDA // Determine which point to start and which as end If(x1>x2) { x=x2;y=y2;Xend=x1; } else { x=x1;y=y1;Xend=x2; } setPixel( x, y ); While( x < Xend) { x++; if( p < 0) p=p+2dy; else { y++; p=p+2dy-2 dx; } setPixel(x,y); }// End While }//End LineBres
  • 79. Advantages of Bresenham’s Alg. It uses only integer calculations It is faster than DDA
  • 80. Circle Drawing Algorithms • Circle – As et of all points in a plane which are at a fixed distance from a fixed point • Circle Equation: (Polynomial) - When center is at (xc, yc) => (x-xc)2 + (y-yc)2= r2 (0,0)=> x2 + y2 = r2 Trigonometric (Polar coordinate) – x = r cosӨ and y = r sinӨ
  • 82. Circle Drawing Algorithms Polynomial Method of Circle representation In this method, Circle is represented by a Polynomial Equation: x2 + y2 = r2 Here, this equation can be used to find ‘y’ coordinates for the known ‘x’ coordinates – ‘r’ is also known. The scan converting circle using this method is achieved by stepping ‘x’ from 0 to r/√2 and each ‘y’ coordinate value Is found by evaluating √(r2-x2) for each step of ‘x’. This will generate 1/8 portion (900 to 450) of the circle. Remaining for other octants are generated the circle symmetry principle.
  • 84. Circle Drawing Algorithms • Trigonometric / Polar CoordinateMethod: x = r cosӨ and y = r sinӨ where Ө is the current angle and x and y are the respective x and y coordinates. The scan convertingcircleusingPolar coordinate method is achieved by stepping Ө from 0 to 450and calculating each x and y value. Using 1/8 symmetry concept remaining points in other octants are found out. This method is also quite inefficient and time consuming because of the repeated computation of sinӨ and cosӨ.
  • 85. Bresenham’s Circle Drawing Algorithm This is an efficient circle drawing algorithm because it avoids square root and trigonometric calculations. It involves only in teger operations. 1/8th of a circle is plotted from 90o to 45o where x moves in the positive direction and y in the negative direction. 8 way symmetry of the circle is considered to generate the remaining points.
  • 86. Bresenham’s Circle Drawing Algorithm Circle equation can also be applied at A and B to get da and db respectively.
  • 88. Bresenham’s Circle Drawing Algorithm Circle eqn. can be applied at points A and B to get d1 and d2 respectively.
  • 92. Bresenham’s Circle Drawing Algorithm (xk, yk) = (0,r)
  • 93. LEARN G ROW .E X C E L Dr . Santízesíz P Matíze BRIMTBIT S B re s e n h a m ' s circie drawing algorithm Algorithm: ten-I: Input radius r and circle K M 2Xc.Jq ) obtained the first point (Xo, Yo) — (0.r) Sitep-2: QIE$lnte the init»l value of decision p»ameter es P -3 -Zr .Step-3: At each Xs position starting at k = 0, peiTonn, the following test: If Pz < 0, the next point is (Xe + 1, Yx) Px+i = Pz + 4Xz + 6 otherwise the next point is (Nz + 1. 3"x — I ) as., =, • qx›—,) • io Deteriiiiiie the symmetry points in other seven octant fep—I: ?itep-fi: Move each pixel position (?£. Y) into circular pnth .Uterv-Ii:Repeat step 3 to 5 until XY.
  • 97. Mid-Point Circle Algorithm • In the midpoint circle drawing algorithm, the midpoint between two pixels along the circle path is first foun d out. • Using a decision variable, it is then checked whether the midpoint is inside or outside the circle path. If the midpoint is inside, the outside pixel is chosen and if it is outside, the inside pixel is chosen. • Circle is plotted from 90 to 45 degrees and ‘x’ moves in the positive direction, while ‘y’ moves in the negative direction. • Points are identified for one octet and the remaining points are found out using 8 way symmetry of the circle.
  • 103. Mid-Point Circle Algorithm Po = (1.25 – r) or (1 – r) when r is an integer pk+1 = pk+2xk+3 pk+1 = pk+2(xk-yk)+5
  • 104. pk+1 = pk+2(xk-yk)+5 pk+1 = pk+2xk+3 P0 = (1.25 – r) ~ (1 - r) for integer r
  • 105. Mid-Point Circle Algorithm • Calculate the points of a circle with radius 7 and center at (10,10) using midpoint circle algorithm. (x0, y0) =(0,r) = (0,7) center (xc,yc) = (10,10) d0 = 1-r = 1-7 = -6 k (xk, yk) dk (xk+1 +xc, yk+1 +yc) 0 (x0,y0)=(0,7) d0 = -6 (1,7) => (11,17) 1 (x1,y1)=(1,7) d1 = d0+2x0+3 = -6+2x0+3 = -3 (2,7) => (12,17) 2 (x2,y2)=(2,7) d2 = d1+2x1+3 = -3+2x1+3 = 2 (3,6) => (13,16) 3 (x3,y3)=(3,6) d3 = d2+2(x2-y2)+5 = 2+2(-5)+5 = -3 (4,6) => (14,16) 4 (x4,y4)=(4,6) d4 = d3+2x3+3 = -3+2x3+3 = 6 (5,5) => (15,15) The points in this octet (90o to 45o) are (10,17), (11,17), (12,17), (13,16), (14,16), (15,15). At 45o, x=y and we stop here. (We can stop when ‘y’ gets equal or less than x – or continue while y >= x)