SlideShare una empresa de Scribd logo
1 de 69
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

Más contenido relacionado

La actualidad más candente

Output primitives computer graphics c version
Output primitives   computer graphics c versionOutput primitives   computer graphics c version
Output primitives computer graphics c versionMarwa Al-Rikaby
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clippingShweta Shah
 
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiTekendra Nath Yogi
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statisticsRajendran
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithmMani Kanth
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesOmprakash Chauhan
 
Pixel Relationships Examples
Pixel Relationships ExamplesPixel Relationships Examples
Pixel Relationships ExamplesMarwa Ahmeid
 
2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)AditiPatni3
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solvedKuntal Bhowmick
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiionMuhammadHamza401
 
Polygon filling
Polygon fillingPolygon filling
Polygon fillingAnkit Garg
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output PrimitivesPrathimaBaliga
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 
Visible Surface Detection
Visible Surface DetectionVisible Surface Detection
Visible Surface DetectionAmitBiswas99
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmMrinmoy Dalal
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts
Image Interpolation Techniques with Optical and Digital Zoom ConceptsImage Interpolation Techniques with Optical and Digital Zoom Concepts
Image Interpolation Techniques with Optical and Digital Zoom Conceptsmmjalbiaty
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cppAlamgir Hossain
 

La actualidad más candente (20)

Output primitives computer graphics c version
Output primitives   computer graphics c versionOutput primitives   computer graphics c version
Output primitives computer graphics c version
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
 
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - Notes
 
Max net
Max netMax net
Max net
 
Pixel Relationships Examples
Pixel Relationships ExamplesPixel Relationships Examples
Pixel Relationships Examples
 
2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiion
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
Visible Surface Detection
Visible Surface DetectionVisible Surface Detection
Visible Surface Detection
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing Algorithm
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts
Image Interpolation Techniques with Optical and Digital Zoom ConceptsImage Interpolation Techniques with Optical and Digital Zoom Concepts
Image Interpolation Techniques with Optical and Digital Zoom Concepts
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
 
Hamming codes
Hamming codesHamming codes
Hamming codes
 

Destacado

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
 
Introduction to Computer Graphics
Introduction to Computer GraphicsIntroduction to Computer Graphics
Introduction to Computer GraphicsYatin Singh
 
Graphics Standards and Algorithm
Graphics Standards and AlgorithmGraphics Standards and Algorithm
Graphics Standards and AlgorithmYatin Singh
 
New microsoft power point presentation
New microsoft power point presentationNew microsoft power point presentation
New microsoft power point presentationSing Ho WOng
 
Line drawing algorithms
Line drawing algorithmsLine drawing algorithms
Line drawing algorithmsSusheel Thakur
 
BEST 3D COMPUTER GRAPHICS TOOLS
BEST 3D COMPUTER GRAPHICS TOOLSBEST 3D COMPUTER GRAPHICS TOOLS
BEST 3D COMPUTER GRAPHICS TOOLSEugeneFitchett123
 
Polygon Mesh Representation
Polygon Mesh RepresentationPolygon Mesh Representation
Polygon Mesh RepresentationPirouz 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 modellingPirouz Nourian
 
Notepad Presentation Mca
Notepad Presentation McaNotepad Presentation Mca
Notepad Presentation Mcahamzaghanchi
 
Full Presentation on Notepad
Full Presentation on NotepadFull Presentation on Notepad
Full Presentation on Notepadmanish chaturvedi
 
Polygon Notes
Polygon NotesPolygon Notes
Polygon Notesacavis
 
projections - engineering drawing
projections - engineering drawing projections - engineering drawing
projections - engineering drawing Krishna Gali
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer GraphicsAdri Jovin
 

Destacado (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
 
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
 
3 D Graphics
3 D Graphics3 D Graphics
3 D Graphics
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 

Similar a Unit 3

Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxNaveenaKarthik3
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1aravindangc
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithmsMohammad Sadiq
 
mid point algorithm.pdf
mid point algorithm.pdfmid point algorithm.pdf
mid point algorithm.pdfMehulMunshi3
 
Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptAliZaib71
 
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 Multimediasaranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivessaranyan75
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesAnkit 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].pptxKokebe2
 
Lec05 circle ellipse
Lec05 circle ellipseLec05 circle ellipse
Lec05 circle ellipseMaaz Rizwan
 
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 algorithmsAmol Gaikwad
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfmeenasp
 
Shape drawing algs
Shape drawing algsShape drawing algs
Shape drawing algsMusawarNice
 

Similar a 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
 

Último

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 

Último (20)

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 

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