SlideShare a Scribd company logo
1
Polygon FillingPolygon Filling
Types of filling
• Solid-fill
All the pixels inside the polygon’s boundary
are illuminated.
• Pattern-fill
the polygon is filled with an arbitrary
predefined pattern.
2
Polygon Representation
The polygon can be represented by listing its n
vertices in an ordered list.
P = {(x1
, y1
), (x2
, y2
), ……., (xn
, yn
)}.
The polygon can be displayed by drawing a line
between (x1
, y1
), and (x2
, y2
), then a line between
(x2
, y2
), and (x3
, y3
), and so on until the end vertex.
In order to close up the polygon, a line between (xn
,
yn
), and (x1
, y1
) must be drawn.
One problem with this representation is that if we
wish to translate the polygon, it is necessary to
apply the translation transformation to each vertex in
3
Polygon Representation
For objects described by many polygons with many
vertices, this can be a time consuming process.
One method for reducing the computational
time is to represent the polygon by the (absolute)
location of its first vertex, and represent
subsequent vertices as relative positions from the
previous vertex. This enables us to translate the
polygon simply by changing the coordinates of the
first vertex.
4
Inside-Outside Tests
when filling polygons we should decide whether a
particular point is interior or exterior to a polygon.
A rule called the odd-parity (or the odd-even rule)
is applied to test whether a point is interior or not.
To apply this rule, we conceptually draw a line
starting from the particular point and extending to a
distance point outside the coordinate extends of the
object in any direction such that no polygon vertex
intersects with the line.
5
Inside-Outside Tests
The point is considered to be interior if the number
of intersections between the line and the polygon
edges is odd. Otherwise, The point is exterior point.
8
7
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8 9 10 11
Outside
Inside
6
The Scan-Line Polygon Fill Algorithm
The scan-line polygon-filling algorithm involves
• the horizontal scanning of the polygon from its
lowermost to its topmost vertex,
• identifying which edges intersect the scan-line,
• and finally drawing the interior horizontal lines with
the specified fill color. process.
7
The Scan-Line Polygon Fill Algorithm
Dealing with vertices
8
The Scan-Line Polygon Fill Algorithm
Dealing with vertices
• When the endpoint y coordinates of the two edges are
increasing, the y value of the upper endpoint for the
current edge is decreased by one (a)
• When the endpoint y values are decreasing, the y value
of the next edge is decreased by one (b)
9
The Scan-Line Polygon Fill Algorithm
Determining Edge Intersections
m = (yk+1
– yk
) / (xk+1
– xk
)
yk+1
– yk
= 1
xk+1
= xk
+ 1/m
10
The Scan-Line Polygon Fill Algorithm
• Each entry in the table for a particular scan line contains
the maximum y value for that edge, the x-intercept value
(at the lower vertex) for the edge, and the inverse slope of
the edge.
11
The Scan-Line Polygon Fill Algorithm
(Example) Polygon = {A, B, C, D, E, F, G}
Polygon = {(2, 7), (4, 12), (8,15), (16, 9), (11, 5), (8, 7), (5, 5)}

More Related Content

What's hot

Graphics software standards
Graphics software standardsGraphics software standards
Graphics software standards
Ankit Garg
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
Mohd Arif
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
Ankit Garg
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
Ankit Garg
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
anku2266
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
Mohd Arif
 
Video display devices
Video display devicesVideo display devices
Video display devices
Mohd Arif
 

What's hot (20)

Graphics software standards
Graphics software standardsGraphics software standards
Graphics software standards
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
 
Spline representations
Spline representationsSpline representations
Spline representations
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Clipping
ClippingClipping
Clipping
 
Input of graphical data
Input of graphical dataInput of graphical data
Input of graphical data
 
Shading
ShadingShading
Shading
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Computer graphics chapter 4
Computer graphics chapter 4Computer graphics chapter 4
Computer graphics chapter 4
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
3 d display methods
3 d display methods3 d display methods
3 d display methods
 
Video display devices
Video display devicesVideo display devices
Video display devices
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Depth Buffer Method
Depth Buffer MethodDepth Buffer Method
Depth Buffer Method
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in Graphics
 

Similar to Boundary fill algm

Lecture filling algorithms
Lecture  filling algorithmsLecture  filling algorithms
Lecture filling algorithms
avelraj
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
wahab13
 
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Kasun Ranga Wijeweera
 
Open GL T0074 56 sm3
Open GL T0074 56 sm3Open GL T0074 56 sm3
Open GL T0074 56 sm3
Roziq Bahtiar
 

Similar to Boundary fill algm (20)

Lecture filling algorithms
Lecture  filling algorithmsLecture  filling algorithms
Lecture filling algorithms
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
 
UNIT2.pptx
UNIT2.pptxUNIT2.pptx
UNIT2.pptx
 
Implementation
ImplementationImplementation
Implementation
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & Rasterization
 
CS401_M2_L6_Solid Area Scan Conversion.pptx
CS401_M2_L6_Solid Area Scan Conversion.pptxCS401_M2_L6_Solid Area Scan Conversion.pptx
CS401_M2_L6_Solid Area Scan Conversion.pptx
 
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
 
CGChapter 3.pptx
CGChapter 3.pptxCGChapter 3.pptx
CGChapter 3.pptx
 
Unit-5 BSR-1-02-2024 advanced algorithms .pptx
Unit-5 BSR-1-02-2024 advanced algorithms .pptxUnit-5 BSR-1-02-2024 advanced algorithms .pptx
Unit-5 BSR-1-02-2024 advanced algorithms .pptx
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Clipping
ClippingClipping
Clipping
 
Geometric algorithms
Geometric algorithmsGeometric algorithms
Geometric algorithms
 
Clipping
ClippingClipping
Clipping
 
Comparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for ImprovementComparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for Improvement
 
7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf
 
cg mod2.pdf
cg mod2.pdfcg mod2.pdf
cg mod2.pdf
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - Notes
 
Unit 4 notes
Unit 4 notesUnit 4 notes
Unit 4 notes
 
Open GL T0074 56 sm3
Open GL T0074 56 sm3Open GL T0074 56 sm3
Open GL T0074 56 sm3
 
An ElGamal Encryption Scheme of Adjacency Matrix and Finite Machines
An ElGamal Encryption Scheme of Adjacency Matrix and Finite MachinesAn ElGamal Encryption Scheme of Adjacency Matrix and Finite Machines
An ElGamal Encryption Scheme of Adjacency Matrix and Finite Machines
 

Recently uploaded

Pests of sugarcane_Binomics_IPM_Dr.UPR.pdf
Pests of sugarcane_Binomics_IPM_Dr.UPR.pdfPests of sugarcane_Binomics_IPM_Dr.UPR.pdf
Pests of sugarcane_Binomics_IPM_Dr.UPR.pdf
PirithiRaju
 
FAIR & AI Ready KGs for Explainable Predictions
FAIR & AI Ready KGs for Explainable PredictionsFAIR & AI Ready KGs for Explainable Predictions
FAIR & AI Ready KGs for Explainable Predictions
Michel Dumontier
 
Seminar on Halal AGriculture and Fisheries.pptx
Seminar on Halal AGriculture and Fisheries.pptxSeminar on Halal AGriculture and Fisheries.pptx
Seminar on Halal AGriculture and Fisheries.pptx
RUDYLUMAPINET2
 
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
muralinath2
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
YOGESH DOGRA
 
The importance of continents, oceans and plate tectonics for the evolution of...
The importance of continents, oceans and plate tectonics for the evolution of...The importance of continents, oceans and plate tectonics for the evolution of...
The importance of continents, oceans and plate tectonics for the evolution of...
Sérgio Sacani
 
Gliese 12 b: A Temperate Earth-sized Planet at 12 pc Ideal for Atmospheric Tr...
Gliese 12 b: A Temperate Earth-sized Planet at 12 pc Ideal for Atmospheric Tr...Gliese 12 b: A Temperate Earth-sized Planet at 12 pc Ideal for Atmospheric Tr...
Gliese 12 b: A Temperate Earth-sized Planet at 12 pc Ideal for Atmospheric Tr...
Sérgio Sacani
 

Recently uploaded (20)

Pests of sugarcane_Binomics_IPM_Dr.UPR.pdf
Pests of sugarcane_Binomics_IPM_Dr.UPR.pdfPests of sugarcane_Binomics_IPM_Dr.UPR.pdf
Pests of sugarcane_Binomics_IPM_Dr.UPR.pdf
 
insect taxonomy importance systematics and classification
insect taxonomy importance systematics and classificationinsect taxonomy importance systematics and classification
insect taxonomy importance systematics and classification
 
INSIGHT Partner Profile: Tampere University
INSIGHT Partner Profile: Tampere UniversityINSIGHT Partner Profile: Tampere University
INSIGHT Partner Profile: Tampere University
 
Hemoglobin metabolism: C Kalyan & E. Muralinath
Hemoglobin metabolism: C Kalyan & E. MuralinathHemoglobin metabolism: C Kalyan & E. Muralinath
Hemoglobin metabolism: C Kalyan & E. Muralinath
 
FAIR & AI Ready KGs for Explainable Predictions
FAIR & AI Ready KGs for Explainable PredictionsFAIR & AI Ready KGs for Explainable Predictions
FAIR & AI Ready KGs for Explainable Predictions
 
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
 
Multi-source connectivity as the driver of solar wind variability in the heli...
Multi-source connectivity as the driver of solar wind variability in the heli...Multi-source connectivity as the driver of solar wind variability in the heli...
Multi-source connectivity as the driver of solar wind variability in the heli...
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
 
Seminar on Halal AGriculture and Fisheries.pptx
Seminar on Halal AGriculture and Fisheries.pptxSeminar on Halal AGriculture and Fisheries.pptx
Seminar on Halal AGriculture and Fisheries.pptx
 
Constraints on Neutrino Natal Kicks from Black-Hole Binary VFTS 243
Constraints on Neutrino Natal Kicks from Black-Hole Binary VFTS 243Constraints on Neutrino Natal Kicks from Black-Hole Binary VFTS 243
Constraints on Neutrino Natal Kicks from Black-Hole Binary VFTS 243
 
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
 
The importance of continents, oceans and plate tectonics for the evolution of...
The importance of continents, oceans and plate tectonics for the evolution of...The importance of continents, oceans and plate tectonics for the evolution of...
The importance of continents, oceans and plate tectonics for the evolution of...
 
Gliese 12 b: A Temperate Earth-sized Planet at 12 pc Ideal for Atmospheric Tr...
Gliese 12 b: A Temperate Earth-sized Planet at 12 pc Ideal for Atmospheric Tr...Gliese 12 b: A Temperate Earth-sized Planet at 12 pc Ideal for Atmospheric Tr...
Gliese 12 b: A Temperate Earth-sized Planet at 12 pc Ideal for Atmospheric Tr...
 
National Biodiversity protection initiatives and Convention on Biological Di...
National Biodiversity protection initiatives and  Convention on Biological Di...National Biodiversity protection initiatives and  Convention on Biological Di...
National Biodiversity protection initiatives and Convention on Biological Di...
 
Topography and sediments of the floor of the Bay of Bengal
Topography and sediments of the floor of the Bay of BengalTopography and sediments of the floor of the Bay of Bengal
Topography and sediments of the floor of the Bay of Bengal
 
GBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of LipidsGBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of Lipids
 
Microbial Type Culture Collection (MTCC)
Microbial Type Culture Collection (MTCC)Microbial Type Culture Collection (MTCC)
Microbial Type Culture Collection (MTCC)
 
FAIRSpectra - Towards a common data file format for SIMS images
FAIRSpectra - Towards a common data file format for SIMS imagesFAIRSpectra - Towards a common data file format for SIMS images
FAIRSpectra - Towards a common data file format for SIMS images
 
electrochemical gas sensors and their uses.pptx
electrochemical gas sensors and their uses.pptxelectrochemical gas sensors and their uses.pptx
electrochemical gas sensors and their uses.pptx
 

Boundary fill algm

  • 1. 1 Polygon FillingPolygon Filling Types of filling • Solid-fill All the pixels inside the polygon’s boundary are illuminated. • Pattern-fill the polygon is filled with an arbitrary predefined pattern.
  • 2. 2 Polygon Representation The polygon can be represented by listing its n vertices in an ordered list. P = {(x1 , y1 ), (x2 , y2 ), ……., (xn , yn )}. The polygon can be displayed by drawing a line between (x1 , y1 ), and (x2 , y2 ), then a line between (x2 , y2 ), and (x3 , y3 ), and so on until the end vertex. In order to close up the polygon, a line between (xn , yn ), and (x1 , y1 ) must be drawn. One problem with this representation is that if we wish to translate the polygon, it is necessary to apply the translation transformation to each vertex in
  • 3. 3 Polygon Representation For objects described by many polygons with many vertices, this can be a time consuming process. One method for reducing the computational time is to represent the polygon by the (absolute) location of its first vertex, and represent subsequent vertices as relative positions from the previous vertex. This enables us to translate the polygon simply by changing the coordinates of the first vertex.
  • 4. 4 Inside-Outside Tests when filling polygons we should decide whether a particular point is interior or exterior to a polygon. A rule called the odd-parity (or the odd-even rule) is applied to test whether a point is interior or not. To apply this rule, we conceptually draw a line starting from the particular point and extending to a distance point outside the coordinate extends of the object in any direction such that no polygon vertex intersects with the line.
  • 5. 5 Inside-Outside Tests The point is considered to be interior if the number of intersections between the line and the polygon edges is odd. Otherwise, The point is exterior point. 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 Outside Inside
  • 6. 6 The Scan-Line Polygon Fill Algorithm The scan-line polygon-filling algorithm involves • the horizontal scanning of the polygon from its lowermost to its topmost vertex, • identifying which edges intersect the scan-line, • and finally drawing the interior horizontal lines with the specified fill color. process.
  • 7. 7 The Scan-Line Polygon Fill Algorithm Dealing with vertices
  • 8. 8 The Scan-Line Polygon Fill Algorithm Dealing with vertices • When the endpoint y coordinates of the two edges are increasing, the y value of the upper endpoint for the current edge is decreased by one (a) • When the endpoint y values are decreasing, the y value of the next edge is decreased by one (b)
  • 9. 9 The Scan-Line Polygon Fill Algorithm Determining Edge Intersections m = (yk+1 – yk ) / (xk+1 – xk ) yk+1 – yk = 1 xk+1 = xk + 1/m
  • 10. 10 The Scan-Line Polygon Fill Algorithm • Each entry in the table for a particular scan line contains the maximum y value for that edge, the x-intercept value (at the lower vertex) for the edge, and the inverse slope of the edge.
  • 11. 11 The Scan-Line Polygon Fill Algorithm (Example) Polygon = {A, B, C, D, E, F, G} Polygon = {(2, 7), (4, 12), (8,15), (16, 9), (11, 5), (8, 7), (5, 5)}