SlideShare a Scribd company logo
Polygon is an ordered list of vertices as
shown in the above figure. For filling
polygons with particular colors, you need to
determine the pixels falling on the border of
polygon and those which fall inside the
polygon.
Now, we will see how we can fill
polygons using different techniques.
 ScanLineAlgorithm
This algorithm works by intersecting scanline with
polygon edges and fills the polygon between pairs of
intersections. The following steps depict how this
algorithm works.
ScanLine
 Step 1: Find out the Ymin and Ymax from the given
polygon.
 Step 2: ScanLine intersects with each edge of the
polygon from Ymin to Ymax. Name each intersection
point of the polygon. As per the figure shown above,
they are named as p0, p1, p2, p3.
 Step 3: Sort the intersection point in the increasing
order of X coordinate i.e. (p0, p1), (p1, p2), and (p2,
p3).
 Step 4: Fill all those pair of coordinates that are
inside polygons and ignore the alternate pairs.
 Sometimes we want to fill the area of
polygon and its boundary with different
colors.
 it relies on the fill color. In other words, it
replaces the interior color of the object with
the fill color. When no more pixels of the
original interior color exist, the algorithm is
completed.
 This algorithm relies on the Four-connect or
Eight-connect method of filling in the
pixels. But instead of looking for the
boundary color, it is looking for all adjacent
pixels that are a part of the interior.
 In this algorithm, we assume that color of
the boundary is same for the entire object.
The boundary fill algorithm can be
implemented by 4-connetected pixels or 8-
connected pixels.
 In this technique 4-
connected pixels are
used as shown in the
figure. We are putting
the pixels above, below,
to the right, and to the
left side of the current
pixels and this process
will continue until we find
a boundary with different
color.
Algorithm
Step 1: Initialize the value of seed point (seedx, seedy),
newcolor and ololdcol.
Step 2: Define the boundary values of the polygon.
Step 3: Check if the current seed point is of old color, then
repeat the steps 4 and 5 till the boundary pixels reached.
If getpixel(x, y) = ololdcol then repeat step
4 and 5
Step 4: Change the old color with the fill color at the seed
point.
setPixel(seedx, seedy, newcol)
step 5: Recursively follow the procedure with
four neighborhood points.
FloodFill (seedx – 1, seedy, newcol, oldcol)
FloodFill (seedx + 1, seedy, newcol, oldcol)
FloodFill (seedx, seedy - 1, newcol, oldcol)
FloodFill (seedx – 1, seedy + 1, newcol,
oldcol)
Step 6: Exit
There is a problem with
this technique.
Consider the case as
shown below where we
tried to fill the entire
region. Here, the image
is filled only partially. In
such cases, 4-
connected pixels
technique cannot be
used.
In this technique, 8-connected pixels are
used as shown in the figure. We are putting
pixels above, below, right and left side of the
current pixels as we were doing in 4-
connected technique.
 In addition to this, we are
also putting pixels in
diagonals so that entire
area of the current pixel
is covered. This process
will continue until we find
a boundary with different
color.
Recursively follow the procedure with eight
neighborhood points.
FloodFill (seedx – 1, seedy, newcol, oldcol)
FloodFill (seedx + 1, seedy, newcol, oldcol)
FloodFill (seedx, seedy - 1, newcol, oldcol)
FloodFill (seedx, seedy + 1, newcol, oldcol)
FloodFill (seedx – 1, seedy + 1, newcol, oldcol)
FloodFill (seedx + 1, seedy + 1, newcol, oldcol)
FloodFill (seedx + 1, seedy - 1, newcol, oldcol)
FloodFill (seedx – 1, seedy - 1, newcol, oldcol)
 This method is also known as counting
number method.
 While filling an object, we often need to
identify whether particular point is inside the
object or outside it.
 Odd-Even Rule method is used by which we
can identify whether particular point is inside
an object or outside.
 In this technique, we will count the edge
crossing along the line from any point (x,y) .
 If the number of interactions is odd, then the
point (x,y) is an interior point; and if the
number of interactions is even, then the point
(x,y) is an exterior point. The following
example depicts this concept.
(x, y)
20
Rotating About An Arbitrary Point
 What happens when you apply a rotation
transformation to an object that is not at
the origin?
 Solution:
◦ Translate the center of rotation to the origin
◦ Rotate the object
◦ Translate back to the original location
Rotating About An Arbitrary Point
x
y
x
y
x
y
x
y
 Thank you….
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon

More Related Content

Similar to Polygon

Polygon filling
Polygon fillingPolygon filling
Lecture filling algorithms
Lecture  filling algorithmsLecture  filling algorithms
Lecture filling algorithms
avelraj
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
Kuntal Bhowmick
 
3D Math Without Presenter Notes
3D Math Without Presenter Notes3D Math Without Presenter Notes
3D Math Without Presenter Notes
Janie Clayton
 
14485616.ppt
14485616.ppt14485616.ppt
14485616.ppt
ssuser80439c
 
Genetic operators
Genetic operatorsGenetic operators
Genetic operators
DEEPIKA T
 
D.E.V.
D.E.V.D.E.V.
Equations and tilings
Equations and tilingsEquations and tilings
Equations and tilings
navajomath
 
Bidirectional graph search techniques for finding shortest path in image base...
Bidirectional graph search techniques for finding shortest path in image base...Bidirectional graph search techniques for finding shortest path in image base...
Bidirectional graph search techniques for finding shortest path in image base...
Navin Kumar
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
Nanhen Verma
 
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- ButkarComputer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Vishal Butkar
 
Mit6 006 f11_quiz1
Mit6 006 f11_quiz1Mit6 006 f11_quiz1
Mit6 006 f11_quiz1
Sandeep Jindal
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
Fahim Ferdous
 
Back tracking
Back trackingBack tracking

Similar to Polygon (14)

Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Lecture filling algorithms
Lecture  filling algorithmsLecture  filling algorithms
Lecture filling algorithms
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
 
3D Math Without Presenter Notes
3D Math Without Presenter Notes3D Math Without Presenter Notes
3D Math Without Presenter Notes
 
14485616.ppt
14485616.ppt14485616.ppt
14485616.ppt
 
Genetic operators
Genetic operatorsGenetic operators
Genetic operators
 
D.E.V.
D.E.V.D.E.V.
D.E.V.
 
Equations and tilings
Equations and tilingsEquations and tilings
Equations and tilings
 
Bidirectional graph search techniques for finding shortest path in image base...
Bidirectional graph search techniques for finding shortest path in image base...Bidirectional graph search techniques for finding shortest path in image base...
Bidirectional graph search techniques for finding shortest path in image base...
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- ButkarComputer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
 
Mit6 006 f11_quiz1
Mit6 006 f11_quiz1Mit6 006 f11_quiz1
Mit6 006 f11_quiz1
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Back tracking
Back trackingBack tracking
Back tracking
 

Recently uploaded

一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
sydezfe
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
ijseajournal
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
aryanpankaj78
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
Lateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptxLateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptx
DebendraDevKhanal1
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
nedcocy
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
vmspraneeth
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
paraasingh12 #V08
 
Ericsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.pptEricsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.ppt
wafawafa52
 
comptia-security-sy0-701-exam-objectives-(5-0).pdf
comptia-security-sy0-701-exam-objectives-(5-0).pdfcomptia-security-sy0-701-exam-objectives-(5-0).pdf
comptia-security-sy0-701-exam-objectives-(5-0).pdf
foxlyon
 
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
DharmaBanothu
 
Determination of Equivalent Circuit parameters and performance characteristic...
Determination of Equivalent Circuit parameters and performance characteristic...Determination of Equivalent Circuit parameters and performance characteristic...
Determination of Equivalent Circuit parameters and performance characteristic...
pvpriya2
 
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdfSri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Balvir Singh
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
felixwold
 
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
GiselleginaGloria
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
paper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdfpaper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdf
ShurooqTaib
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
DharmaBanothu
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
upoux
 
Advancements in Automobile Engineering for Sustainable Development.pdf
Advancements in Automobile Engineering for Sustainable Development.pdfAdvancements in Automobile Engineering for Sustainable Development.pdf
Advancements in Automobile Engineering for Sustainable Development.pdf
JaveedKhan59
 

Recently uploaded (20)

一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
Lateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptxLateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptx
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
 
Ericsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.pptEricsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.ppt
 
comptia-security-sy0-701-exam-objectives-(5-0).pdf
comptia-security-sy0-701-exam-objectives-(5-0).pdfcomptia-security-sy0-701-exam-objectives-(5-0).pdf
comptia-security-sy0-701-exam-objectives-(5-0).pdf
 
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
A high-Speed Communication System is based on the Design of a Bi-NoC Router, ...
 
Determination of Equivalent Circuit parameters and performance characteristic...
Determination of Equivalent Circuit parameters and performance characteristic...Determination of Equivalent Circuit parameters and performance characteristic...
Determination of Equivalent Circuit parameters and performance characteristic...
 
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdfSri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
 
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
3rd International Conference on Artificial Intelligence Advances (AIAD 2024)
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
paper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdfpaper relate Chozhavendhan et al. 2020.pdf
paper relate Chozhavendhan et al. 2020.pdf
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
 
Advancements in Automobile Engineering for Sustainable Development.pdf
Advancements in Automobile Engineering for Sustainable Development.pdfAdvancements in Automobile Engineering for Sustainable Development.pdf
Advancements in Automobile Engineering for Sustainable Development.pdf
 

Polygon

  • 1.
  • 2.
  • 3. Polygon is an ordered list of vertices as shown in the above figure. For filling polygons with particular colors, you need to determine the pixels falling on the border of polygon and those which fall inside the polygon. Now, we will see how we can fill polygons using different techniques.
  • 4.  ScanLineAlgorithm This algorithm works by intersecting scanline with polygon edges and fills the polygon between pairs of intersections. The following steps depict how this algorithm works. ScanLine
  • 5.  Step 1: Find out the Ymin and Ymax from the given polygon.  Step 2: ScanLine intersects with each edge of the polygon from Ymin to Ymax. Name each intersection point of the polygon. As per the figure shown above, they are named as p0, p1, p2, p3.  Step 3: Sort the intersection point in the increasing order of X coordinate i.e. (p0, p1), (p1, p2), and (p2, p3).  Step 4: Fill all those pair of coordinates that are inside polygons and ignore the alternate pairs.
  • 6.  Sometimes we want to fill the area of polygon and its boundary with different colors.  it relies on the fill color. In other words, it replaces the interior color of the object with the fill color. When no more pixels of the original interior color exist, the algorithm is completed.
  • 7.  This algorithm relies on the Four-connect or Eight-connect method of filling in the pixels. But instead of looking for the boundary color, it is looking for all adjacent pixels that are a part of the interior.
  • 8.
  • 9.  In this algorithm, we assume that color of the boundary is same for the entire object. The boundary fill algorithm can be implemented by 4-connetected pixels or 8- connected pixels.
  • 10.  In this technique 4- connected pixels are used as shown in the figure. We are putting the pixels above, below, to the right, and to the left side of the current pixels and this process will continue until we find a boundary with different color.
  • 11. Algorithm Step 1: Initialize the value of seed point (seedx, seedy), newcolor and ololdcol. Step 2: Define the boundary values of the polygon. Step 3: Check if the current seed point is of old color, then repeat the steps 4 and 5 till the boundary pixels reached. If getpixel(x, y) = ololdcol then repeat step 4 and 5 Step 4: Change the old color with the fill color at the seed point. setPixel(seedx, seedy, newcol)
  • 12. step 5: Recursively follow the procedure with four neighborhood points. FloodFill (seedx – 1, seedy, newcol, oldcol) FloodFill (seedx + 1, seedy, newcol, oldcol) FloodFill (seedx, seedy - 1, newcol, oldcol) FloodFill (seedx – 1, seedy + 1, newcol, oldcol) Step 6: Exit
  • 13. There is a problem with this technique. Consider the case as shown below where we tried to fill the entire region. Here, the image is filled only partially. In such cases, 4- connected pixels technique cannot be used.
  • 14. In this technique, 8-connected pixels are used as shown in the figure. We are putting pixels above, below, right and left side of the current pixels as we were doing in 4- connected technique.
  • 15.  In addition to this, we are also putting pixels in diagonals so that entire area of the current pixel is covered. This process will continue until we find a boundary with different color.
  • 16. Recursively follow the procedure with eight neighborhood points. FloodFill (seedx – 1, seedy, newcol, oldcol) FloodFill (seedx + 1, seedy, newcol, oldcol) FloodFill (seedx, seedy - 1, newcol, oldcol) FloodFill (seedx, seedy + 1, newcol, oldcol) FloodFill (seedx – 1, seedy + 1, newcol, oldcol) FloodFill (seedx + 1, seedy + 1, newcol, oldcol) FloodFill (seedx + 1, seedy - 1, newcol, oldcol) FloodFill (seedx – 1, seedy - 1, newcol, oldcol)
  • 17.  This method is also known as counting number method.  While filling an object, we often need to identify whether particular point is inside the object or outside it.  Odd-Even Rule method is used by which we can identify whether particular point is inside an object or outside.
  • 18.  In this technique, we will count the edge crossing along the line from any point (x,y) .  If the number of interactions is odd, then the point (x,y) is an interior point; and if the number of interactions is even, then the point (x,y) is an exterior point. The following example depicts this concept.
  • 20. 20 Rotating About An Arbitrary Point
  • 21.  What happens when you apply a rotation transformation to an object that is not at the origin?  Solution: ◦ Translate the center of rotation to the origin ◦ Rotate the object ◦ Translate back to the original location
  • 22. Rotating About An Arbitrary Point x y x y x y x y