SlideShare a Scribd company logo
UNIT III 
Scan conversion and Output 
Primitives 
1
Line drawing algorithm 
• Computer screen is divided into rows and 
columns. 
• The intersection area is known as pixel. 
• Process of determining which combination 
of pixels provide the best approximation of 
a desired line is known as Rasterization 
• Rasterization is combined with rendering 
of the picture in scan line order, then it is 
known as scan conversion. 
2
Pixels 
3
Horizontal lines 
4
General requirement for 
requirement of a line 
• Line must appear to be straight 
• Lines should start and end accurately 
• Lines should have constant brightness 
along their length. 
• Lines should be drawn rapidly 
5
• On the raster system, lines are plotted with 
pixels 
• Step sizes in horizontal or vertical directions 
are constrained by pixel sepration. 
• Equation for a straight line 
y=mx+c 
m is slope of line c is y-intercept 
m= Δy / Δx 
m= y2-y1/x2-x1 
6
DDA algorithm 
• Digital Differential Analyzer is a scan conversion 
line algorithm based on calculating either Δy or 
Δx 
DDA Procedure 
Line end points are (xa,ya) and (xb,yb) 
dx=xb- xa 
dy=yb-ya 
Determine the length of line 
7
• If abs(dx)>=abs(dy) then length=abs(dx) 
else length=abs(dy) 
Δx = dx / length 
Δy = dy / length 
x= xa 
y =ya 
setpixel (round(x), round(y)); 8
9 
i=1 
while (i<=length) 
x= x+ Δx ; 
y= y+ Δy ; 
setpixel (round(x), round(y)); 
i=i+1 
end while 
Finish
Ex. 1 Consider a line from (0,0) to (6,7). 
Use DDA algorithm to rasterize this line 
Initialization: 
(xa,ya) =(0,0) 
(xb,yb) =(6,7) 
dx=6-0=6 
dy=7-0=7 
Length=7 
Δx=6/7=0.857 
Δy=7/7=1 
x=0 
y=0 
10
Plotting begins 
i Setpixel(x,y) x y 
(0,0) 0 0 
1 0.857 1 
(1,1) 
2 1.714 2 
(2,2) 
3 2.571 3 
(3,3) 
4 3.428 4 
(3,4) 
5 4.285 5 
(4,5) 
6 5.142 6 
(5,6) 
7 5.999 7 
(6,7) 
11
Results of DDA algorithm 
12
Drawbacks 
• Although fast, accumulation of round of 
error may drift the long line segments 
• Rounding off is time consuming 
13
Bresenham’s line drawing 
Algorithm 
• It determines which points in an n-dimensional 
raster should be plotted to form approximate 
straight line between two points. 
• It chooses the integer y corresponding to the 
pixel center that is closest to the ideal (fractional) 
y for the same x; on successive columns y can 
remain the same or increase by 1. 
• Depends upon the slope of the line. 
14
15
16
17
18
19
20
21
22
Generalized algorithm for all 
quadrants 
Initialize variable 
x=x1 
y=y1 
dx=abs(x2-x1) 
dy=abs (y2-y1) 
Sx =Sign (x2-x1) 
Sy = Sign (y2-y1) 
Determine the length of the line 
23
if dy > dx 
then, 
t = dx 
dx = dy 
dy = t 
steps = dy 
flag = 1 
else 
steps = dx 
flag = 0 
endif 
24
Pk = 2dy-dx 
setpixel (x,y) 
for i=1 to steps 
while (P k =>0) 
y = y+1 
x = x + S x 
P k = P k+2dy- 2dx 
endwhile 25
If flag = 1 then 
y = y +1 
x = x 
else 
x = x + Sx 
y= y 
endif 
Pk = Pk + 2dy 
Setpixel (x,y) 
next i 
finish 
26
Use Bresenham’s algorithm to 
rasterize a line from (0,0) to (6,7) 
Initializations 
(x1,y1)=(0,0); (x2,y2)=(6,7) 
x = 0 
y = 0 
dx=abs(6-0)= 6 
dy=abs (7-0) =7 
Sx =Sign (x2-x1)= +1 
Sy = Sign (y2-y1) = +1 
steps (length of the line) = 7 
flag = 1, dx = 7, dy = 6, Pk =5 
27
Plotting begins 
i Setpixel (x,y) Pk x y 
(0,0) 5 
1 1 1 
(1,1) 3 
2 2 2 
(2,2) 1 
3 3 3 
(3,3) -1 
4 3 4 
(3,4) 11 
5 4 5 
(4,5) 9 
6 5 6 
(5,6) 7 
7 6 7 
(6,7) 
28
Results of algorithm 
29
Bresenhem Circle drawing 
Algorithm 
• Algorithm for 1st octant only 
30
31
Properties of a circle: 
• A circle is defined as a set of points that 
are all the given distance (xc,yc). 
• This distance relationship is expressed by 
the Pythagorean theorem in Cartesian 
coordinates as 
(x – xc)2 + (y – yc) 2 = r2 
32
Midpoint Circle Algorithm 
• We will first calculate pixel positions for a circle 
centered around the origin (0,0). 
• Then, each calculated position (x,y) is moved to 
its proper screen position by adding xc to x and 
yc to y 
• Note that along the circle section from x=0 to 
x=y in the first octant, the slope of the curve 
varies from 0 to -1 
• Circle function around the origin is given by 
fcircle(x,y) = x2 + y2 – r2 
• Any point (x,y) on the boundary of the circle 
satisfies the equation and circle function is zero 
33
34
• For a point in the interior of the circle, the 
circle function is negative and for a point 
outside the circle, the function is positive 
• Thus, 
– fcircle(x,y) < 0 if (x,y) is inside the circle 
boundary 
– fcircle(x,y) = 0 if (x,y) is on the circle boundary 
– fcircle(x,y) > 0 if (x,y) is outside the circle 
boundary 
35
Midpoint circle algorithm 
1. Input the origin as centre (x0, y0) = (0,r) 
2. Decision parameter p0=5/4 - r 
3.If pk<0 then (xk+1, yk) 
pk+1= pk+ 2xk+1 +1 
else (xk+1, yk-1) 
pk+1= pk+ 2xk+1 + 1- 2yk-1 
where 2xk+1= 2xk+2 and 2yk-1=2 yk – 2 
4. Determine symmetry points on seven octants 
5. Move the pixels x=x+ xc, y=y+yc 
6. Repeat the steps till x>=y 
39
Midpoint ellipse algorithm 
One quarter of an ellipse is divided into two 
regions. In region I, the slope on the curve is 
greater than –1 while in region II less than –1. 
Equation of an ellipse, b2x2 + a2y2 – a2b2 = 0 where 
a = horizontal radius b = vertical radius, 
Set f(x,y) = b2x2 + a2y2 – a2b2 
40
First point in ellipse centered on origin is 
(x0,y0)= (0,b) 
Initial value of decision parameter 
P0= f(1, b-1/2) 
41
In region I (dy/dx > –1), 
(xk, yk), Prediction- (xk+1, yk–½) SE or E 
42
In region II (dy/dx < –1), all calculations are 
similar to that in region I except that y is 
decremented in each step. 
Prediction-(xk+½, yk–1) 
SE or S 
43
• When 2b2x>=2a2y 
Move from region 1 to region 2 
Decision parameter in region 1 
P1k= f(xk+1, yk-1/2) 
Decision parameter in region 2 
P2k= f(xk+1/2, yk-1) 
44
Midpoint Ellipse Algorithm 
• Initial point = (0,b) 
• Decision parameter in Region 1 
P10=b2-a2b+a2/4 
If P10<0, next point (xk+1, yk) 
P1k+1= P1k+2b2xk+1+b2 
If P10>=0, next point (xk+1, yk-1) 
P1k+1= P1k+2b2xk+1 + b2 -2a2yk+1 
45
• Repeat till 2b2x<2a2y 
Last point of region 1 is the initial point for 
region 2 
• Decision parameter for region 2 
P20= b2 (x0+1/2)2+ a2 (y0-1)2- a2b2 
If P2k>0 next point (xk, yk-1) 
P2k+1= P2k- 2a2yk+1+a2 
If P2k<=0 next point (xk+1, yk-1) 
P2k+1= P2k- 2a2yk+1+ a2 + 2b2xk+1 
pIot the coordinates x=x+ xc, y=y+yc 46
a=7, b=3, centre (5,-3) 
Let (x0,y0)= (0,3), 2a2=98, 2b2=18 
Pk Xk+1 Yk+1 2b2xk+1 2a2yk+1 
-125.75 1 3 18 294 2b2x<2a2y 
-98.75 2 3 36 294 2b2x<2a2y 
-53.75 3 3 54 294 2b2x<2a2y 
9.25 4 2 72 196 2b2x<2a2y 
47
Pk Xk+1 Yk+1 2b2xk+1 2a2yk+1 
-105.75 5 2 90 196 2b2x<2a2y 
-6.75 6 2 108 196 2b2x<2a2y 
110.25 7 1 126 98 2b2x>2a2y 
65.25 7 0 
48
Plotting pixels 
x y Actual x Actual y 
0 3 5 0 
1 3 6 0 
2 3 7 0 
3 3 8 0 
4 2 9 -1 
5 2 10 -1 
6 2 11 -1 
7 1 12 -2 
7 0 12 -3 49
Plot 
1 
0 
-1 
-2 
-3 
-4 
-5 
-6 
-7 
-4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 50
Ellipse a=6, b=4 centre (-2,7) 
Let (x0,y0)= (0,4), 2a2=72, 2b2=32 
Pk Xk+1 Yk+1 2b2xk+1 2a2yk+1 
-119 1 4 32 288 2b2x<2a2y 
-71 2 4 64 288 2b2x<2a2y 
9 3 3 96 216 2b2x<2a2y 
-95 4 3 128 216 2b2x<2a2y 
51
Pk Xk+1 Yk+1 2b2xk+1 2a2yk+1 
49 5 2 160 144 2b2x>2a2y 
-56 6 1 192 72 2b2x>2a2y 
100 6 0 
52
Pixels 
x y Actual x Actual y 
0 4 -2 11 
1 4 -1 11 
2 4 0 11 
3 3 1 10 
4 3 2 10 
5 2 3 9 
6 1 4 8 
6 0 4 7 
53
12 
11 
10 
9 
8 
7 
6 
5 
4 
3 
2 
1 
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 54
a=8, b=6 centre (7,-3) 
2a2=128, 2b2= 72 (x0,y0)=(0,6) 
Pk 
(region 1) 
Xk+1 Yk+1 2b2xk+1 2a2yk+1 Check 
2b2x < 2a2y 
-332 1 6 72 768 Yes 
-224 2 6 144 768 yes 
-44 3 6 216 768 Yes 
208 4 5 288 640 Yes 
-108 5 5 360 640 Yes 
288 6 4 432 512 Yes 
244 7 3 504 384 no 55
Pk 
(regio 
n 1) 
Xk+1 Yk+1 2b2xk+1 2a2yk+1 Check 
2b2x < 2a2y 
-151 8 2 576 256 no 
233 8 1 576 128 no 
745 8 0 
56
(xc,yc)= (-3,-1) Actual x= x+ xc 
Actual y=y+yc 
x y Actual x Actual y 
1 6 -2 5 
2 6 -1 5 
3 6 0 5 
4 5 1 4 
5 5 2 4 
6 4 3 3 
7 3 4 2 
8 2 5 1 
8 1 5 0 
8 0 5 -1 57
5 
4 
3 
2 
1 
0 
-1 
-2 
-3 
-4 
-5 
-6 
-7 
-8 
58
Filled area primitives 
In graphics packages this is referred to as 
filled polygons. 
• Scan line fill algorithm 
• Boundary fill or flood fill algorithm. 
59
Polygon filling 
• Region filling is a process of ‘colouring in’ 
a defined area. 
• Classified as- 
Boundary defined:-defined in terms of 
bounding pixels that outline it 
Interior defined region:-defined in terms of 
pixels which it comprises of 
60
Scan line algorithm 
• A scan line intersects a polygon at one or 
more points. 
• For each scan line crossing a polygon, 
algorithm locates the intersection points of 
the scan line with the polygon edges. 
• Intersection is considered in pairs. 
• For interval between the pair of 
intersection, colour is that of background. 
61
62
• It starts with the closed polygon with 
defined interior and exterior regions. 
• Colour of interior and vertices of the 
polygon to be filled are known. 
• Scan line moves downwards from top to 
bottom. 
63
• For regular geometric figures, such as 
squares or rectangles, edges are well 
defined. 
• Area can be filled directly by edge 
detection. 
• Some polygons may requires special 
handling hen there are more than one 
intersection along the scan line. 
64
Flood Fill algorithm 
65
• In flood fill algorithm user provides a seed 
pixel 
• Starting from the seed pixel, algorithm will 
inspect each of the surrounding pixel to 
determine the extent of reach. 
• Process is repeated until all pixels inside 
the region are inspected 
66
• The seed pixel progresses recursively 
towards the boundary. 
• If it encounters the boundary the chain 
terminates. 
• The seed pixel enlarges to fill the area 
within the boundary. 
• The enlargement of area and examining of 
neighbouring pixels can progress in two 
ways: 
67
• Firstly to the four connected pixels, 
adjacent to it like right , left, bottom and 
top. 
• Secondly through eight connected pixels 
including diagonal pixels. 
• First way may fail to fill the complete area. 
• Eight connected pixel is preferred. 
• A curve or a circle leaves several diagonal 
pasages which prevents the application of 
boundary filling algorithm. 
68
69
Scan line seed fill algorithm 
• In seed fill algorithm, the stack size is very 
large. 
• The duplicate pixels make the process 
slow. 
• SLSF algorithm minimizes the duplicate 
pixels. 
• Algorithm processes in raster pattern, 
along left to right in each scan line. 
70
Flow of Algorithm 
• A seed pixel located on the scan line is selected. 
• The line or span containing the seed pixel is 
filled from left to right 
• including the seed pixel itself until the boundary 
is found. 
• The extreme left and extreme right unprocessed 
pixel in the span are saved. 
• The scan lines above and below the current 
scan line are examined in the range of x-right 
and x-left. 
71
THANKYOU 
72

More Related Content

What's hot

Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
Mani Kanth
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
Laxman Puri
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing Algorithm
Mrinmoy Dalal
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
Drishti Bhalla
 
Graphics software standards
Graphics software standardsGraphics software standards
Graphics software standards
Ankit Garg
 
Computer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methodsComputer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methods
Joseph Charles
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversionMohd Arif
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformationsMohammad Sadiq
 
3 d geometric transformations
3 d geometric transformations3 d geometric transformations
3 d geometric transformationsMohd Arif
 
2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)
AditiPatni3
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algoMohd Arif
 
Output primitives computer graphics c version
Output primitives   computer graphics c versionOutput primitives   computer graphics c version
Output primitives computer graphics c version
Marwa Al-Rikaby
 
Image compression .
Image compression .Image compression .
Image compression .
Payal Vishwakarma
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
Mani Kanth
 
Composite transformations
Composite transformationsComposite transformations
Composite transformationsMohd Arif
 
Windows to viewport transformation
Windows to viewport transformationWindows to viewport transformation
Windows to viewport transformation
Prashant Singh
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
2013901097
 

What's hot (20)

Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing Algorithm
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Graphics software standards
Graphics software standardsGraphics software standards
Graphics software standards
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Computer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methodsComputer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methods
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformations
 
3 d geometric transformations
3 d geometric transformations3 d geometric transformations
3 d geometric transformations
 
2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algo
 
Output primitives computer graphics c version
Output primitives   computer graphics c versionOutput primitives   computer graphics c version
Output primitives computer graphics c version
 
point operations in image processing
point operations in image processingpoint operations in image processing
point operations in image processing
 
Image compression .
Image compression .Image compression .
Image compression .
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
Windows to viewport transformation
Windows to viewport transformationWindows to viewport transformation
Windows to viewport transformation
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 

Viewers also liked

Bazier curve Algorithom for Computer Gramphics prsentation
Bazier curve Algorithom for Computer Gramphics prsentation Bazier curve Algorithom for Computer Gramphics prsentation
Bazier curve Algorithom for Computer Gramphics prsentation
Google
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
PrathimaBaliga
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
Kamal Acharya
 
Introduction to Computer Graphics
Introduction to Computer GraphicsIntroduction to Computer Graphics
Introduction to Computer Graphics
Yatin Singh
 
Graphics Standards and Algorithm
Graphics Standards and AlgorithmGraphics Standards and Algorithm
Graphics Standards and Algorithm
Yatin Singh
 
New microsoft power point presentation
New microsoft power point presentationNew microsoft power point presentation
New microsoft power point presentation
Sing Ho WOng
 
Line drawing algorithms
Line drawing algorithmsLine drawing algorithms
Line drawing algorithmsSusheel Thakur
 
Bbc coordinates
Bbc coordinatesBbc coordinates
Bbc coordinates
ClintParisCom
 
Cs580
Cs580Cs580
BEST 3D COMPUTER GRAPHICS TOOLS
BEST 3D COMPUTER GRAPHICS TOOLSBEST 3D COMPUTER GRAPHICS TOOLS
BEST 3D COMPUTER GRAPHICS TOOLS
EugeneFitchett123
 
Polygon Mesh Representation
Polygon Mesh RepresentationPolygon Mesh Representation
Polygon Mesh Representation
Pirouz Nourian
 
On NURBS Geometry Representation in 3D modelling
On NURBS Geometry Representation in 3D modellingOn NURBS Geometry Representation in 3D modelling
On NURBS Geometry Representation in 3D modelling
Pirouz Nourian
 
OpenGL 4.4 Reference Card
OpenGL 4.4 Reference CardOpenGL 4.4 Reference Card
OpenGL 4.4 Reference Card
The Khronos Group Inc.
 
Notepad Presentation Mca
Notepad Presentation McaNotepad Presentation Mca
Notepad Presentation Mca
hamzaghanchi
 
Full Presentation on Notepad
Full Presentation on NotepadFull Presentation on Notepad
Full Presentation on Notepad
manish chaturvedi
 
Polygon Notes
Polygon NotesPolygon Notes
Polygon Notesacavis
 
projections - engineering drawing
projections - engineering drawing projections - engineering drawing
projections - engineering drawing
Krishna Gali
 

Viewers also liked (20)

Bazier curve Algorithom for Computer Gramphics prsentation
Bazier curve Algorithom for Computer Gramphics prsentation Bazier curve Algorithom for Computer Gramphics prsentation
Bazier curve Algorithom for Computer Gramphics prsentation
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Introduction to Computer Graphics
Introduction to Computer GraphicsIntroduction to Computer Graphics
Introduction to Computer Graphics
 
Graphics Standards and Algorithm
Graphics Standards and AlgorithmGraphics Standards and Algorithm
Graphics Standards and Algorithm
 
New microsoft power point presentation
New microsoft power point presentationNew microsoft power point presentation
New microsoft power point presentation
 
Line drawing algorithms
Line drawing algorithmsLine drawing algorithms
Line drawing algorithms
 
Cgp lecture1 introduction
Cgp lecture1 introductionCgp lecture1 introduction
Cgp lecture1 introduction
 
Bbc coordinates
Bbc coordinatesBbc coordinates
Bbc coordinates
 
Cs580
Cs580Cs580
Cs580
 
BEST 3D COMPUTER GRAPHICS TOOLS
BEST 3D COMPUTER GRAPHICS TOOLSBEST 3D COMPUTER GRAPHICS TOOLS
BEST 3D COMPUTER GRAPHICS TOOLS
 
Polygon Mesh Representation
Polygon Mesh RepresentationPolygon Mesh Representation
Polygon Mesh Representation
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Notepad ++
Notepad ++Notepad ++
Notepad ++
 
On NURBS Geometry Representation in 3D modelling
On NURBS Geometry Representation in 3D modellingOn NURBS Geometry Representation in 3D modelling
On NURBS Geometry Representation in 3D modelling
 
OpenGL 4.4 Reference Card
OpenGL 4.4 Reference CardOpenGL 4.4 Reference Card
OpenGL 4.4 Reference Card
 
Notepad Presentation Mca
Notepad Presentation McaNotepad Presentation Mca
Notepad Presentation Mca
 
Full Presentation on Notepad
Full Presentation on NotepadFull Presentation on Notepad
Full Presentation on Notepad
 
Polygon Notes
Polygon NotesPolygon Notes
Polygon Notes
 
projections - engineering drawing
projections - engineering drawing projections - engineering drawing
projections - engineering drawing
 

Similar to Unit 3

2.circle
2.circle2.circle
2.circle
SakshiNailwal
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
NaveenaKarthik3
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
aravindangc
 
CG-Lecture3.pptx
CG-Lecture3.pptxCG-Lecture3.pptx
CG-Lecture3.pptx
lakshitasarika2014
 
10994479.ppt
10994479.ppt10994479.ppt
10994479.ppt
ALIZAIB KHAN
 
Computer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipseComputer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipse
Hisham Al Kurdi, EAVA, DMC-D-4K, HCCA-P, HCAA-D
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithmsMohammad Sadiq
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
KimTaehyung188352
 
mid point algorithm.pdf
mid point algorithm.pdfmid point algorithm.pdf
mid point algorithm.pdf
MehulMunshi3
 
Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.ppt
AliZaib71
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
saranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
saranyan75
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
Ankit Garg
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4Roziq Bahtiar
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptx
Kokebe2
 
Lec05 circle ellipse
Lec05 circle ellipseLec05 circle ellipse
Lec05 circle ellipse
Maaz Rizwan
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
Prabin Gautam
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
Amol Gaikwad
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdf
meenasp
 
Shape drawing algs
Shape drawing algsShape drawing algs
Shape drawing algs
MusawarNice
 

Similar to Unit 3 (20)

2.circle
2.circle2.circle
2.circle
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
CG-Lecture3.pptx
CG-Lecture3.pptxCG-Lecture3.pptx
CG-Lecture3.pptx
 
10994479.ppt
10994479.ppt10994479.ppt
10994479.ppt
 
Computer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipseComputer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipse
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
 
mid point algorithm.pdf
mid point algorithm.pdfmid point algorithm.pdf
mid point algorithm.pdf
 
Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.ppt
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptx
 
Lec05 circle ellipse
Lec05 circle ellipseLec05 circle ellipse
Lec05 circle ellipse
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdf
 
Shape drawing algs
Shape drawing algsShape drawing algs
Shape drawing algs
 

Recently uploaded

HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 

Recently uploaded (20)

HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 

Unit 3

  • 1. UNIT III Scan conversion and Output Primitives 1
  • 2. Line drawing algorithm • Computer screen is divided into rows and columns. • The intersection area is known as pixel. • Process of determining which combination of pixels provide the best approximation of a desired line is known as Rasterization • Rasterization is combined with rendering of the picture in scan line order, then it is known as scan conversion. 2
  • 5. General requirement for requirement of a line • Line must appear to be straight • Lines should start and end accurately • Lines should have constant brightness along their length. • Lines should be drawn rapidly 5
  • 6. • On the raster system, lines are plotted with pixels • Step sizes in horizontal or vertical directions are constrained by pixel sepration. • Equation for a straight line y=mx+c m is slope of line c is y-intercept m= Δy / Δx m= y2-y1/x2-x1 6
  • 7. DDA algorithm • Digital Differential Analyzer is a scan conversion line algorithm based on calculating either Δy or Δx DDA Procedure Line end points are (xa,ya) and (xb,yb) dx=xb- xa dy=yb-ya Determine the length of line 7
  • 8. • If abs(dx)>=abs(dy) then length=abs(dx) else length=abs(dy) Δx = dx / length Δy = dy / length x= xa y =ya setpixel (round(x), round(y)); 8
  • 9. 9 i=1 while (i<=length) x= x+ Δx ; y= y+ Δy ; setpixel (round(x), round(y)); i=i+1 end while Finish
  • 10. Ex. 1 Consider a line from (0,0) to (6,7). Use DDA algorithm to rasterize this line Initialization: (xa,ya) =(0,0) (xb,yb) =(6,7) dx=6-0=6 dy=7-0=7 Length=7 Δx=6/7=0.857 Δy=7/7=1 x=0 y=0 10
  • 11. Plotting begins i Setpixel(x,y) x y (0,0) 0 0 1 0.857 1 (1,1) 2 1.714 2 (2,2) 3 2.571 3 (3,3) 4 3.428 4 (3,4) 5 4.285 5 (4,5) 6 5.142 6 (5,6) 7 5.999 7 (6,7) 11
  • 12. Results of DDA algorithm 12
  • 13. Drawbacks • Although fast, accumulation of round of error may drift the long line segments • Rounding off is time consuming 13
  • 14. Bresenham’s line drawing Algorithm • It determines which points in an n-dimensional raster should be plotted to form approximate straight line between two points. • It chooses the integer y corresponding to the pixel center that is closest to the ideal (fractional) y for the same x; on successive columns y can remain the same or increase by 1. • Depends upon the slope of the line. 14
  • 15. 15
  • 16. 16
  • 17. 17
  • 18. 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. 22
  • 23. Generalized algorithm for all quadrants Initialize variable x=x1 y=y1 dx=abs(x2-x1) dy=abs (y2-y1) Sx =Sign (x2-x1) Sy = Sign (y2-y1) Determine the length of the line 23
  • 24. if dy > dx then, t = dx dx = dy dy = t steps = dy flag = 1 else steps = dx flag = 0 endif 24
  • 25. Pk = 2dy-dx setpixel (x,y) for i=1 to steps while (P k =>0) y = y+1 x = x + S x P k = P k+2dy- 2dx endwhile 25
  • 26. If flag = 1 then y = y +1 x = x else x = x + Sx y= y endif Pk = Pk + 2dy Setpixel (x,y) next i finish 26
  • 27. Use Bresenham’s algorithm to rasterize a line from (0,0) to (6,7) Initializations (x1,y1)=(0,0); (x2,y2)=(6,7) x = 0 y = 0 dx=abs(6-0)= 6 dy=abs (7-0) =7 Sx =Sign (x2-x1)= +1 Sy = Sign (y2-y1) = +1 steps (length of the line) = 7 flag = 1, dx = 7, dy = 6, Pk =5 27
  • 28. Plotting begins i Setpixel (x,y) Pk x y (0,0) 5 1 1 1 (1,1) 3 2 2 2 (2,2) 1 3 3 3 (3,3) -1 4 3 4 (3,4) 11 5 4 5 (4,5) 9 6 5 6 (5,6) 7 7 6 7 (6,7) 28
  • 30. Bresenhem Circle drawing Algorithm • Algorithm for 1st octant only 30
  • 31. 31
  • 32. Properties of a circle: • A circle is defined as a set of points that are all the given distance (xc,yc). • This distance relationship is expressed by the Pythagorean theorem in Cartesian coordinates as (x – xc)2 + (y – yc) 2 = r2 32
  • 33. Midpoint Circle Algorithm • We will first calculate pixel positions for a circle centered around the origin (0,0). • Then, each calculated position (x,y) is moved to its proper screen position by adding xc to x and yc to y • Note that along the circle section from x=0 to x=y in the first octant, the slope of the curve varies from 0 to -1 • Circle function around the origin is given by fcircle(x,y) = x2 + y2 – r2 • Any point (x,y) on the boundary of the circle satisfies the equation and circle function is zero 33
  • 34. 34
  • 35. • For a point in the interior of the circle, the circle function is negative and for a point outside the circle, the function is positive • Thus, – fcircle(x,y) < 0 if (x,y) is inside the circle boundary – fcircle(x,y) = 0 if (x,y) is on the circle boundary – fcircle(x,y) > 0 if (x,y) is outside the circle boundary 35
  • 36. Midpoint circle algorithm 1. Input the origin as centre (x0, y0) = (0,r) 2. Decision parameter p0=5/4 - r 3.If pk<0 then (xk+1, yk) pk+1= pk+ 2xk+1 +1 else (xk+1, yk-1) pk+1= pk+ 2xk+1 + 1- 2yk-1 where 2xk+1= 2xk+2 and 2yk-1=2 yk – 2 4. Determine symmetry points on seven octants 5. Move the pixels x=x+ xc, y=y+yc 6. Repeat the steps till x>=y 39
  • 37. Midpoint ellipse algorithm One quarter of an ellipse is divided into two regions. In region I, the slope on the curve is greater than –1 while in region II less than –1. Equation of an ellipse, b2x2 + a2y2 – a2b2 = 0 where a = horizontal radius b = vertical radius, Set f(x,y) = b2x2 + a2y2 – a2b2 40
  • 38. First point in ellipse centered on origin is (x0,y0)= (0,b) Initial value of decision parameter P0= f(1, b-1/2) 41
  • 39. In region I (dy/dx > –1), (xk, yk), Prediction- (xk+1, yk–½) SE or E 42
  • 40. In region II (dy/dx < –1), all calculations are similar to that in region I except that y is decremented in each step. Prediction-(xk+½, yk–1) SE or S 43
  • 41. • When 2b2x>=2a2y Move from region 1 to region 2 Decision parameter in region 1 P1k= f(xk+1, yk-1/2) Decision parameter in region 2 P2k= f(xk+1/2, yk-1) 44
  • 42. Midpoint Ellipse Algorithm • Initial point = (0,b) • Decision parameter in Region 1 P10=b2-a2b+a2/4 If P10<0, next point (xk+1, yk) P1k+1= P1k+2b2xk+1+b2 If P10>=0, next point (xk+1, yk-1) P1k+1= P1k+2b2xk+1 + b2 -2a2yk+1 45
  • 43. • Repeat till 2b2x<2a2y Last point of region 1 is the initial point for region 2 • Decision parameter for region 2 P20= b2 (x0+1/2)2+ a2 (y0-1)2- a2b2 If P2k>0 next point (xk, yk-1) P2k+1= P2k- 2a2yk+1+a2 If P2k<=0 next point (xk+1, yk-1) P2k+1= P2k- 2a2yk+1+ a2 + 2b2xk+1 pIot the coordinates x=x+ xc, y=y+yc 46
  • 44. a=7, b=3, centre (5,-3) Let (x0,y0)= (0,3), 2a2=98, 2b2=18 Pk Xk+1 Yk+1 2b2xk+1 2a2yk+1 -125.75 1 3 18 294 2b2x<2a2y -98.75 2 3 36 294 2b2x<2a2y -53.75 3 3 54 294 2b2x<2a2y 9.25 4 2 72 196 2b2x<2a2y 47
  • 45. Pk Xk+1 Yk+1 2b2xk+1 2a2yk+1 -105.75 5 2 90 196 2b2x<2a2y -6.75 6 2 108 196 2b2x<2a2y 110.25 7 1 126 98 2b2x>2a2y 65.25 7 0 48
  • 46. Plotting pixels x y Actual x Actual y 0 3 5 0 1 3 6 0 2 3 7 0 3 3 8 0 4 2 9 -1 5 2 10 -1 6 2 11 -1 7 1 12 -2 7 0 12 -3 49
  • 47. Plot 1 0 -1 -2 -3 -4 -5 -6 -7 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 50
  • 48. Ellipse a=6, b=4 centre (-2,7) Let (x0,y0)= (0,4), 2a2=72, 2b2=32 Pk Xk+1 Yk+1 2b2xk+1 2a2yk+1 -119 1 4 32 288 2b2x<2a2y -71 2 4 64 288 2b2x<2a2y 9 3 3 96 216 2b2x<2a2y -95 4 3 128 216 2b2x<2a2y 51
  • 49. Pk Xk+1 Yk+1 2b2xk+1 2a2yk+1 49 5 2 160 144 2b2x>2a2y -56 6 1 192 72 2b2x>2a2y 100 6 0 52
  • 50. Pixels x y Actual x Actual y 0 4 -2 11 1 4 -1 11 2 4 0 11 3 3 1 10 4 3 2 10 5 2 3 9 6 1 4 8 6 0 4 7 53
  • 51. 12 11 10 9 8 7 6 5 4 3 2 1 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 54
  • 52. a=8, b=6 centre (7,-3) 2a2=128, 2b2= 72 (x0,y0)=(0,6) Pk (region 1) Xk+1 Yk+1 2b2xk+1 2a2yk+1 Check 2b2x < 2a2y -332 1 6 72 768 Yes -224 2 6 144 768 yes -44 3 6 216 768 Yes 208 4 5 288 640 Yes -108 5 5 360 640 Yes 288 6 4 432 512 Yes 244 7 3 504 384 no 55
  • 53. Pk (regio n 1) Xk+1 Yk+1 2b2xk+1 2a2yk+1 Check 2b2x < 2a2y -151 8 2 576 256 no 233 8 1 576 128 no 745 8 0 56
  • 54. (xc,yc)= (-3,-1) Actual x= x+ xc Actual y=y+yc x y Actual x Actual y 1 6 -2 5 2 6 -1 5 3 6 0 5 4 5 1 4 5 5 2 4 6 4 3 3 7 3 4 2 8 2 5 1 8 1 5 0 8 0 5 -1 57
  • 55. 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 58
  • 56. Filled area primitives In graphics packages this is referred to as filled polygons. • Scan line fill algorithm • Boundary fill or flood fill algorithm. 59
  • 57. Polygon filling • Region filling is a process of ‘colouring in’ a defined area. • Classified as- Boundary defined:-defined in terms of bounding pixels that outline it Interior defined region:-defined in terms of pixels which it comprises of 60
  • 58. Scan line algorithm • A scan line intersects a polygon at one or more points. • For each scan line crossing a polygon, algorithm locates the intersection points of the scan line with the polygon edges. • Intersection is considered in pairs. • For interval between the pair of intersection, colour is that of background. 61
  • 59. 62
  • 60. • It starts with the closed polygon with defined interior and exterior regions. • Colour of interior and vertices of the polygon to be filled are known. • Scan line moves downwards from top to bottom. 63
  • 61. • For regular geometric figures, such as squares or rectangles, edges are well defined. • Area can be filled directly by edge detection. • Some polygons may requires special handling hen there are more than one intersection along the scan line. 64
  • 63. • In flood fill algorithm user provides a seed pixel • Starting from the seed pixel, algorithm will inspect each of the surrounding pixel to determine the extent of reach. • Process is repeated until all pixels inside the region are inspected 66
  • 64. • The seed pixel progresses recursively towards the boundary. • If it encounters the boundary the chain terminates. • The seed pixel enlarges to fill the area within the boundary. • The enlargement of area and examining of neighbouring pixels can progress in two ways: 67
  • 65. • Firstly to the four connected pixels, adjacent to it like right , left, bottom and top. • Secondly through eight connected pixels including diagonal pixels. • First way may fail to fill the complete area. • Eight connected pixel is preferred. • A curve or a circle leaves several diagonal pasages which prevents the application of boundary filling algorithm. 68
  • 66. 69
  • 67. Scan line seed fill algorithm • In seed fill algorithm, the stack size is very large. • The duplicate pixels make the process slow. • SLSF algorithm minimizes the duplicate pixels. • Algorithm processes in raster pattern, along left to right in each scan line. 70
  • 68. Flow of Algorithm • A seed pixel located on the scan line is selected. • The line or span containing the seed pixel is filled from left to right • including the seed pixel itself until the boundary is found. • The extreme left and extreme right unprocessed pixel in the span are saved. • The scan lines above and below the current scan line are examined in the range of x-right and x-left. 71