SlideShare uma empresa Scribd logo
1 de 18
Arvin Bera
(Lecturer CST KPC)
 Types of fill Algorithm
 Scan Line Algorithm
 Flood Fill Algorithm
 Boundary fill Algorithm
 4 connected Polygon
 8 Connected Polygon
 Difference between Floodfill and Boundary fill
Algorithm.
Scan Line Algorithm
Flood Fill Algorithm
Boundary Fill Algorithm
 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.
 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,p1p0,p1, p1,p2p1,p2, and p2,p3p2,p3.
 Step 4 − Fill all those pair of coordinates that are
inside polygons and ignore the alternate pairs.
 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,seedyseedx,seedy,
fcolor and dcol.
 Step 2 − Define the boundary values of the polygon.
 Step 3 − Check if the current seed point is of default color, then repeat
the steps 4 and 5 till the boundary pixels reached.
 If getpixel(x, y) = dcol then repeat step 4 and 5
 Step 4 − Change the default color with the fill color at the seed point.
setPixel(seedx, seedy, fcol)
 Step 5 − Recursively follow the procedure with four neighborhood
points.
 FloodFill (seedx – 1, seedy, fcol, dcol)
 FloodFill (seedx + 1, seedy, fcol, dcol)
 FloodFill (seedx, seedy - 1, fcol, dcol)
 FloodFill (seedx – 1, seedy + 1, fcol, dcol)
 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.
 Algorithm
 Step 1 − Initialize the value of seed point seedx,seedyseedx,seedy, fcolor and
dcol.
 Step 2 − Define the boundary values of the polygon.
 Step 3 − Check if the current seed point is of default color then repeat the steps 4
and 5 till the boundary pixels reached
 If getpixel(x,y) = dcol then repeat step 4 and 5
 Step 4 − Change the default color with the fill color at the seed
point.setPixel(seedx, seedy, fcol)
 Step 5 − Recursively follow the procedure with four neighbourhood points
 FloodFill (seedx – 1, seedy, fcol, dcol)
 FloodFill (seedx + 1, seedy, fcol, dcol)
 FloodFill (seedx, seedy - 1, fcol, dcol)
 FloodFill (seedx, seedy + 1, fcol, dcol)
 FloodFill (seedx – 1, seedy + 1, fcol, dcol)
 FloodFill (seedx + 1, seedy + 1, fcol, dcol)
 FloodFill (seedx + 1, seedy - 1, fcol, dcol)
 FloodFill (seedx – 1, seedy - 1, fcol, dcol)
 Step 6 − Exit
 https://youtu.be/WmXKII8Dobw
 https://youtu.be/KuthvFzt6p4
 https://youtu.be/y5XX94Ar5NA
 https://youtu.be/U-DxsSjc3KQ
 https://youtu.be/qcTk6hWp6Qc
Thank you

Mais conteúdo relacionado

Mais procurados (11)

Lesson 10 2 area 2012
Lesson 10 2 area 2012Lesson 10 2 area 2012
Lesson 10 2 area 2012
 
8th Alg - L7.3--Feb9
8th Alg - L7.3--Feb98th Alg - L7.3--Feb9
8th Alg - L7.3--Feb9
 
Mathematics 3 lesson plan
Mathematics 3 lesson planMathematics 3 lesson plan
Mathematics 3 lesson plan
 
LP formulation and solution
LP formulation and solutionLP formulation and solution
LP formulation and solution
 
Ch 7 Review March 18
Ch  7 Review March 18Ch  7 Review March 18
Ch 7 Review March 18
 
Chapter%201%20 examples 2 2
Chapter%201%20 examples 2 2Chapter%201%20 examples 2 2
Chapter%201%20 examples 2 2
 
10.1 area of polygons 1
10.1 area of polygons   110.1 area of polygons   1
10.1 area of polygons 1
 
6th Math (C2) - L51--Jan27
6th Math (C2) - L51--Jan276th Math (C2) - L51--Jan27
6th Math (C2) - L51--Jan27
 
Lesson 10 2 area
Lesson 10 2 areaLesson 10 2 area
Lesson 10 2 area
 
DCF - K map
DCF - K mapDCF - K map
DCF - K map
 
Sequence
SequenceSequence
Sequence
 

Semelhante a #KPC #CST #Polygon Fill

Semelhante a #KPC #CST #Polygon Fill (20)

Polygon
PolygonPolygon
Polygon
 
CG_U2_M2.pptx
CG_U2_M2.pptxCG_U2_M2.pptx
CG_U2_M2.pptx
 
Unit-2 PPT.ppt
Unit-2 PPT.pptUnit-2 PPT.ppt
Unit-2 PPT.ppt
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION By Sintiak Haque
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION  By Sintiak Haque4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION  By Sintiak Haque
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION By Sintiak Haque
 
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
 
UNIT2.pptx
UNIT2.pptxUNIT2.pptx
UNIT2.pptx
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
designanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxdesignanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptx
 
Transportation model and assignment model
Transportation model and assignment modelTransportation model and assignment model
Transportation model and assignment model
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
 
This quiz is open book and open notes/tutorialoutlet
This quiz is open book and open notes/tutorialoutletThis quiz is open book and open notes/tutorialoutlet
This quiz is open book and open notes/tutorialoutlet
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
 
The1
The1The1
The1
 
region-filling
region-fillingregion-filling
region-filling
 
Transportation model
Transportation modelTransportation model
Transportation model
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdf
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 

Mais de KEIKolkata (9)

#KPC #ETCE & EE #Dgital Signature
#KPC #ETCE & EE  #Dgital Signature #KPC #ETCE & EE  #Dgital Signature
#KPC #ETCE & EE #Dgital Signature
 
#KPC #EE & ETCE #Cryptography
#KPC #EE & ETCE  #Cryptography#KPC #EE & ETCE  #Cryptography
#KPC #EE & ETCE #Cryptography
 
#KPC #CST #Relational Decomposition
#KPC #CST #Relational Decomposition #KPC #CST #Relational Decomposition
#KPC #CST #Relational Decomposition
 
#KPC #CST #Protocols
#KPC #CST #Protocols #KPC #CST #Protocols
#KPC #CST #Protocols
 
#KPC #CST #Projection
#KPC #CST #Projection #KPC #CST #Projection
#KPC #CST #Projection
 
#KPC #CST #Polygon fill
#KPC #CST #Polygon fill #KPC #CST #Polygon fill
#KPC #CST #Polygon fill
 
#KPC #CST #DBMS(BCNF)
#KPC #CST #DBMS(BCNF) #KPC #CST #DBMS(BCNF)
#KPC #CST #DBMS(BCNF)
 
#KPC #CST #Curves
#KPC #CST #Curves #KPC #CST #Curves
#KPC #CST #Curves
 
#KPC #CST #Clipping
#KPC #CST #Clipping #KPC #CST #Clipping
#KPC #CST #Clipping
 

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 

#KPC #CST #Polygon Fill

  • 2.
  • 3.  Types of fill Algorithm  Scan Line Algorithm  Flood Fill Algorithm  Boundary fill Algorithm  4 connected Polygon  8 Connected Polygon  Difference between Floodfill and Boundary fill Algorithm.
  • 4. Scan Line Algorithm Flood Fill Algorithm Boundary Fill Algorithm
  • 5.  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.
  • 6.  Step 1 − Find out the Ymin and Ymax from the given polygon.
  • 7.  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,p1p0,p1, p1,p2p1,p2, and p2,p3p2,p3.  Step 4 − Fill all those pair of coordinates that are inside polygons and ignore the alternate pairs.
  • 8.
  • 9.
  • 10.
  • 11.  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.
  • 12.  Algorithm  Step 1 − Initialize the value of seed point seedx,seedyseedx,seedy, fcolor and dcol.  Step 2 − Define the boundary values of the polygon.  Step 3 − Check if the current seed point is of default color, then repeat the steps 4 and 5 till the boundary pixels reached.  If getpixel(x, y) = dcol then repeat step 4 and 5  Step 4 − Change the default color with the fill color at the seed point. setPixel(seedx, seedy, fcol)  Step 5 − Recursively follow the procedure with four neighborhood points.  FloodFill (seedx – 1, seedy, fcol, dcol)  FloodFill (seedx + 1, seedy, fcol, dcol)  FloodFill (seedx, seedy - 1, fcol, dcol)  FloodFill (seedx – 1, seedy + 1, fcol, dcol)  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.  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.
  • 15.  Algorithm  Step 1 − Initialize the value of seed point seedx,seedyseedx,seedy, fcolor and dcol.  Step 2 − Define the boundary values of the polygon.  Step 3 − Check if the current seed point is of default color then repeat the steps 4 and 5 till the boundary pixels reached  If getpixel(x,y) = dcol then repeat step 4 and 5  Step 4 − Change the default color with the fill color at the seed point.setPixel(seedx, seedy, fcol)  Step 5 − Recursively follow the procedure with four neighbourhood points  FloodFill (seedx – 1, seedy, fcol, dcol)  FloodFill (seedx + 1, seedy, fcol, dcol)  FloodFill (seedx, seedy - 1, fcol, dcol)  FloodFill (seedx, seedy + 1, fcol, dcol)  FloodFill (seedx – 1, seedy + 1, fcol, dcol)  FloodFill (seedx + 1, seedy + 1, fcol, dcol)  FloodFill (seedx + 1, seedy - 1, fcol, dcol)  FloodFill (seedx – 1, seedy - 1, fcol, dcol)  Step 6 − Exit
  • 16.
  • 17.  https://youtu.be/WmXKII8Dobw  https://youtu.be/KuthvFzt6p4  https://youtu.be/y5XX94Ar5NA  https://youtu.be/U-DxsSjc3KQ  https://youtu.be/qcTk6hWp6Qc