SlideShare a Scribd company logo
1 of 11
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

Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
Mohd Arif
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
Mohd Arif
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
Mohd Arif
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
Mohd Arif
 

What's hot (20)

Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
Area filling algo
Area filling algoArea filling algo
Area filling algo
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
 
2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)2D Transformations(Computer Graphics)
2D Transformations(Computer Graphics)
 
2D Transformation in Computer Graphics
2D Transformation in Computer Graphics2D Transformation in Computer Graphics
2D Transformation in Computer Graphics
 
Clipping
ClippingClipping
Clipping
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithms
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 
Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)
 
BRESENHAM’S LINE DRAWING ALGORITHM
BRESENHAM’S  LINE DRAWING ALGORITHMBRESENHAM’S  LINE DRAWING ALGORITHM
BRESENHAM’S LINE DRAWING ALGORITHM
 
Depth Buffer Method
Depth Buffer MethodDepth Buffer Method
Depth Buffer Method
 
Unit 3
Unit 3Unit 3
Unit 3
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in Graphics
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
 

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

Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Sérgio Sacani
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learning
levieagacer
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virus
NazaninKarimi6
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
MohamedFarag457087
 
Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.
Cherry
 
biology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGYbiology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGY
1301aanya
 

Recently uploaded (20)

Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
 
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate ProfessorThyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
 
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRLGwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
 
Genome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptxGenome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptx
 
GBSN - Microbiology (Unit 3)Defense Mechanism of the body
GBSN - Microbiology (Unit 3)Defense Mechanism of the body GBSN - Microbiology (Unit 3)Defense Mechanism of the body
GBSN - Microbiology (Unit 3)Defense Mechanism of the body
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learning
 
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsTransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learning
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virus
 
Role of AI in seed science Predictive modelling and Beyond.pptx
Role of AI in seed science  Predictive modelling and  Beyond.pptxRole of AI in seed science  Predictive modelling and  Beyond.pptx
Role of AI in seed science Predictive modelling and Beyond.pptx
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
 
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptxClimate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
 
Cot curve, melting temperature, unique and repetitive DNA
Cot curve, melting temperature, unique and repetitive DNACot curve, melting temperature, unique and repetitive DNA
Cot curve, melting temperature, unique and repetitive DNA
 
Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.
 
biology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGYbiology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGY
 
Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.
 
Genome organization in virus,bacteria and eukaryotes.pptx
Genome organization in virus,bacteria and eukaryotes.pptxGenome organization in virus,bacteria and eukaryotes.pptx
Genome organization in virus,bacteria and eukaryotes.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)}