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

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
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)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
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)
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
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
 
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.
 
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
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
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
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
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Ữ Â...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

#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