SlideShare ist ein Scribd-Unternehmen logo
1 von 27
CS401 Computer Graphics
Module 2
Slide Set : 7
S7 CSE A
Solid Area Scan Conversion
Salitha K. K.
Computer Science and Engineering
November 2021
2
Quick revision
• Scan Conversion
• Frame buffers
• Solid area scan conversion
3
Contents
• Polygon filling algorithms
• Seed Fill Algorithm
• Boundary Fill Algorithm
• Flood Fill Algorithm
• Scan Line Algorithm
Introduction
Scan conversion
• One way to designing raster system is having separate display coprocessor(display
processor/ graphics controller).
• Purpose of display processor is to free CPU from graphics work.
• Display processors have their own separate memory for fast operation.
• Main work of display processor is digitalizing a picture definition given in an
application program into a set of pixel intensity values for storage in frame
buffer.
• This digitalization process is scan conversion.
• Graphics commands specifying straight lines and other geometric objects are
scan converted into a set of discrete intensity points.
4
Introduction
5
• Filling the polygon means highlighting all pixels which lie inside the polygon with
any color other than background color.
• There are two basic approaches used to fill the polygon.
• Seed Fill
• Scan-line algorithm
Polygon Filling
6
Seed Fill
• One way to fill a polygon is to start from a given “seed”, point known to
be inside the polygon and highlight outward from this point i.e.
neighboring pixels until we encounter the boundary pixels.
• This approach is known as seed fill because color flows from the seed pixel
until reaching the polygon boundary, like water flooding on the surface of
the container.
Polygon Filling
Scan-line algorithm
• Another approach to fill the polygon is to check whether the pixel is inside the
polygon or outside the polygon and then highlight pixels which lie inside the
polygon.
• This approach is known as scan-line algorithm.
• It avoids the need for a seed pixel but it requires some computation.
7
Seed fill algorithm
8
• In this method, we start with a given seed, point known to be inside the polygon
& highlight outward from this point i.e. neighboring pixels until we encounter the
boundary pixels.
• This approach is called seed fill.
• The seed fill algorithm is further classified as
• Boundary fill algorithm
• Flood fill algorithm
Seed fill algorithm
9
• Connectivity of graphs
4-connected graph 8-connected graph
• The region can be defined in terms of 4-connected or 8-connected, as shown in the figure.
• For a 4-coonected region every point is spanned by a combination of four moves left, right,
top and bottom respectively.
• For a 8-connected region, the same can be spanned using two horizontal, two vertical, and
four diagonal directions respectively.
Boundary fill algorithm
• This method begins with a starting point, called seed, inside the region, filling
that point with the specified fill color.
• Then examine the neighboring pixels to check whether the boundary pixel is
reached.
• If boundary pixels are not reached, pixels are highlighted and the process is
continued until boundary pixels are reached.
• This process involves checking of boundaries.
10
Boundary fill algorithm
11
Boundary fill algorithm
12
Boundary fill algorithm
13
Flood-Fill Algorithm
• Sometimes we want to fill in (or recolor) an area that is not defined within a
single color boundary.
• We can paint such areas by replacing a specified interior color instead of
searching for a boundary color value.
• This approach is called a flood-fill algorithm.
14
Flood-Fill Algorithm
• We start from a specified interior point (x, y) and reassign all pixel values that are
currently set to a given interior color with the desired fill color.
• If the area we want to paint has more than one interior color, we can first reassign pixel
values so that all interior points have the same color.
• Using either a 4-connected or 8-connected approach, we then step through pixel
positions until all interior points have been repainted.
• The following procedure flood fills a 4-connected region recursively, starting from the
input position.
15
Flood-Fill Algorithm
16
ScanLine Polygon Fill Algorithm
15
• For eachscanline crossing a polygon, this algorithm locates the
intersectionpointsof the scanline withthe polygon edges.
• These intersection points are then sorted from left to right and
the corresponding positionsbetween each intersection pair are
set to the specified fill color.
• The four pixel intersection positions with the polygon
boundaries define two stretches of interior pixels from x=10 to
x=14 and fromx=18 to x=24.
• The scan line algorithm first finds the largest and smallest y
valuesof the polygon.
• It then starts with the largest y value & works its down,
scanning fromleft to right.
ScanLine Polygon Fill Algorithm
16
• Theimportant task isto find the intersection pointsof the scanlinewith the polygonboundary.
• Whenintersectionpointsare even,theyare sortedfromleft toright, paired andpixelsbetweenpaired pointsare
setto the fill color.
• Whenscan lineintersectpolygonvertex,a specialhandling isrequired to find the exact intersection points.
• T
ohandlesuchcases,lookat theotherendpointof thetwo line segments of the polygon whichmeetat thisvertex.
• If thesepointslie onthesame(up& down)sideof thescan line,thenthispointinquestioncountsasanevennumberof
intersection.
• If they lie onopposite sidesof the scanline, thenthe pointis counted assingle intersection.
ScanLinePolygonFill Algorithm
• Each scan line intersects the vertex or
verticesof the polygon.
• For scan line 1,the other end points of the line
segment of the polygonare B& Dwhichlie on
the sameside of the scanline.
• Hence there are two intersections
resulting two pairs:1-2 & 3-4.
• Intersections points are 2 & 3 are actually
samepoints.
17
A C
D
E
F
G
H
J I
B
ScanLinePolygonFill Algorithm
18
• Forscanline 2,the other endpoints(D& F)of thetwo line segmentsof thepolygon lie onthe
oppositesides of the scanline.
• Hence,thereisa singleintersectionresultingtwopairs: 1-2 & 3-4.
• F
or scanline 3,two verticesare the intersection points.
• F
or vertex F
, the other end points E& G of the two line segmentsof the polygon lie onthe
sameside of the scanline.
• F
or vertex H, the other end points G & I of the two line segments of the polygon lie on the
opposite side of the scanline.
ScanLinePolygonFill Algorithm
• At vertex Fthere are two intersections& at vertex Hthere isonly one intersection.
• Thisresultstwo pairs:1-2 and 3-4 and points 2-3 are actually samepoints
• It isnecessaryto calculate x intersection points for scanline with every polygon side.
• Thesecalculations canbe simplified by using CoherenceProperty.
• A coherence property of a scene isa property of a sceneby which we can relate one part of a scene
withthe other parts of the scene.
• Slope of an edge isused asa coherenceproperty.
• By using this property we can determine the x intersection value on the lower scan line if the x
intersection value for current scan line isknown.
ScanLinePolygonFill Algorithm
20
• Thisisgivenas
• xi+1 = xi – 1/m
where misthe slope of the edge.
• As we move from top to bottom value of y coordinates between the two
scanline changesby 1.
• yi+1 = yi -1
• Many times it isnot necessary to compute the x intersection for scan line
with every polygon side.
• We need to consider only the polygon sides with endpoints straddling
the current scanline.
ScanLinePolygonFill Algorithm
21
• It will be easier to identify which polygon sides should be tested for x
intersection, if we first sortthesidesin order of theirmaximum y value.
• Oncethesidesare sorted wecanprocessthe scanlinesfrom top of the polygon to
its bottom producing an active edge list for eachscan line crossing the polygon
boundaries.
• Theactive edge list for a scanlinecontain all edgescrossed by that scanline.
ScanLinePolygonFill Algorithm
22
Sorted List of edges
A C
D
E
F
G
H
J I
B
BC BA DC DE AJ GF GH EF HI JI
TOP BOTTOM
25
Summary
• Polygon Filling
• Seed Fill - Boundary Fill, Flood Fill
• Scan Line Algorithm
26
On next lessons
• Two dimensional transformations
27
Thank You

Weitere ähnliche Inhalte

Ähnlich wie CS401_M2_L6_Solid Area Scan Conversion.pptx

Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
wahab13
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
Ankit Garg
 
Lecture filling algorithms
Lecture  filling algorithmsLecture  filling algorithms
Lecture filling algorithms
avelraj
 
Rapidly-Exploring Random Tree
Rapidly-Exploring Random TreeRapidly-Exploring Random Tree
Rapidly-Exploring Random Tree
Abhishek Bhandwaldar
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
Ankit Garg
 

Ähnlich wie CS401_M2_L6_Solid Area Scan Conversion.pptx (20)

cg mod2.pdf
cg mod2.pdfcg mod2.pdf
cg mod2.pdf
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Unit-2 PPT.ppt
Unit-2 PPT.pptUnit-2 PPT.ppt
Unit-2 PPT.ppt
 
UNIT-III
UNIT-IIIUNIT-III
UNIT-III
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
Lecture filling algorithms
Lecture  filling algorithmsLecture  filling algorithms
Lecture filling algorithms
 
Implementation
ImplementationImplementation
Implementation
 
Sutherland hodgman polygon clipping algorithm
Sutherland hodgman polygon clipping algorithmSutherland hodgman polygon clipping algorithm
Sutherland hodgman polygon clipping algorithm
 
14485616.ppt
14485616.ppt14485616.ppt
14485616.ppt
 
Implementation
ImplementationImplementation
Implementation
 
Unit 4 notes
Unit 4 notesUnit 4 notes
Unit 4 notes
 
Rapidly-Exploring Random Tree
Rapidly-Exploring Random TreeRapidly-Exploring Random Tree
Rapidly-Exploring Random Tree
 
attribute.pptx
attribute.pptxattribute.pptx
attribute.pptx
 
ch4.pptx
ch4.pptxch4.pptx
ch4.pptx
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
06 image features
06 image features06 image features
06 image features
 
Polygon drawing
Polygon drawingPolygon drawing
Polygon drawing
 
CSO PPT.pptx
CSO PPT.pptxCSO PPT.pptx
CSO PPT.pptx
 

KĂźrzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

KĂźrzlich hochgeladen (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

CS401_M2_L6_Solid Area Scan Conversion.pptx

  • 1. CS401 Computer Graphics Module 2 Slide Set : 7 S7 CSE A Solid Area Scan Conversion Salitha K. K. Computer Science and Engineering November 2021
  • 2. 2 Quick revision • Scan Conversion • Frame buffers • Solid area scan conversion
  • 3. 3 Contents • Polygon filling algorithms • Seed Fill Algorithm • Boundary Fill Algorithm • Flood Fill Algorithm • Scan Line Algorithm
  • 4. Introduction Scan conversion • One way to designing raster system is having separate display coprocessor(display processor/ graphics controller). • Purpose of display processor is to free CPU from graphics work. • Display processors have their own separate memory for fast operation. • Main work of display processor is digitalizing a picture definition given in an application program into a set of pixel intensity values for storage in frame buffer. • This digitalization process is scan conversion. • Graphics commands specifying straight lines and other geometric objects are scan converted into a set of discrete intensity points. 4
  • 5. Introduction 5 • Filling the polygon means highlighting all pixels which lie inside the polygon with any color other than background color. • There are two basic approaches used to fill the polygon. • Seed Fill • Scan-line algorithm
  • 6. Polygon Filling 6 Seed Fill • One way to fill a polygon is to start from a given “seed”, point known to be inside the polygon and highlight outward from this point i.e. neighboring pixels until we encounter the boundary pixels. • This approach is known as seed fill because color flows from the seed pixel until reaching the polygon boundary, like water flooding on the surface of the container.
  • 7. Polygon Filling Scan-line algorithm • Another approach to fill the polygon is to check whether the pixel is inside the polygon or outside the polygon and then highlight pixels which lie inside the polygon. • This approach is known as scan-line algorithm. • It avoids the need for a seed pixel but it requires some computation. 7
  • 8. Seed fill algorithm 8 • In this method, we start with a given seed, point known to be inside the polygon & highlight outward from this point i.e. neighboring pixels until we encounter the boundary pixels. • This approach is called seed fill. • The seed fill algorithm is further classified as • Boundary fill algorithm • Flood fill algorithm
  • 9. Seed fill algorithm 9 • Connectivity of graphs 4-connected graph 8-connected graph • The region can be defined in terms of 4-connected or 8-connected, as shown in the figure. • For a 4-coonected region every point is spanned by a combination of four moves left, right, top and bottom respectively. • For a 8-connected region, the same can be spanned using two horizontal, two vertical, and four diagonal directions respectively.
  • 10. Boundary fill algorithm • This method begins with a starting point, called seed, inside the region, filling that point with the specified fill color. • Then examine the neighboring pixels to check whether the boundary pixel is reached. • If boundary pixels are not reached, pixels are highlighted and the process is continued until boundary pixels are reached. • This process involves checking of boundaries. 10
  • 14. Flood-Fill Algorithm • Sometimes we want to fill in (or recolor) an area that is not defined within a single color boundary. • We can paint such areas by replacing a specified interior color instead of searching for a boundary color value. • This approach is called a flood-fill algorithm. 14
  • 15. Flood-Fill Algorithm • We start from a specified interior point (x, y) and reassign all pixel values that are currently set to a given interior color with the desired fill color. • If the area we want to paint has more than one interior color, we can first reassign pixel values so that all interior points have the same color. • Using either a 4-connected or 8-connected approach, we then step through pixel positions until all interior points have been repainted. • The following procedure flood fills a 4-connected region recursively, starting from the input position. 15
  • 17. ScanLine Polygon Fill Algorithm 15 • For eachscanline crossing a polygon, this algorithm locates the intersectionpointsof the scanline withthe polygon edges. • These intersection points are then sorted from left to right and the corresponding positionsbetween each intersection pair are set to the specified fill color. • The four pixel intersection positions with the polygon boundaries define two stretches of interior pixels from x=10 to x=14 and fromx=18 to x=24. • The scan line algorithm first finds the largest and smallest y valuesof the polygon. • It then starts with the largest y value & works its down, scanning fromleft to right.
  • 18. ScanLine Polygon Fill Algorithm 16 • Theimportant task isto find the intersection pointsof the scanlinewith the polygonboundary. • Whenintersectionpointsare even,theyare sortedfromleft toright, paired andpixelsbetweenpaired pointsare setto the fill color. • Whenscan lineintersectpolygonvertex,a specialhandling isrequired to find the exact intersection points. • T ohandlesuchcases,lookat theotherendpointof thetwo line segments of the polygon whichmeetat thisvertex. • If thesepointslie onthesame(up& down)sideof thescan line,thenthispointinquestioncountsasanevennumberof intersection. • If they lie onopposite sidesof the scanline, thenthe pointis counted assingle intersection.
  • 19. ScanLinePolygonFill Algorithm • Each scan line intersects the vertex or verticesof the polygon. • For scan line 1,the other end points of the line segment of the polygonare B& Dwhichlie on the sameside of the scanline. • Hence there are two intersections resulting two pairs:1-2 & 3-4. • Intersections points are 2 & 3 are actually samepoints. 17 A C D E F G H J I B
  • 20. ScanLinePolygonFill Algorithm 18 • Forscanline 2,the other endpoints(D& F)of thetwo line segmentsof thepolygon lie onthe oppositesides of the scanline. • Hence,thereisa singleintersectionresultingtwopairs: 1-2 & 3-4. • F or scanline 3,two verticesare the intersection points. • F or vertex F , the other end points E& G of the two line segmentsof the polygon lie onthe sameside of the scanline. • F or vertex H, the other end points G & I of the two line segments of the polygon lie on the opposite side of the scanline.
  • 21. ScanLinePolygonFill Algorithm • At vertex Fthere are two intersections& at vertex Hthere isonly one intersection. • Thisresultstwo pairs:1-2 and 3-4 and points 2-3 are actually samepoints • It isnecessaryto calculate x intersection points for scanline with every polygon side. • Thesecalculations canbe simplified by using CoherenceProperty. • A coherence property of a scene isa property of a sceneby which we can relate one part of a scene withthe other parts of the scene. • Slope of an edge isused asa coherenceproperty. • By using this property we can determine the x intersection value on the lower scan line if the x intersection value for current scan line isknown.
  • 22. ScanLinePolygonFill Algorithm 20 • Thisisgivenas • xi+1 = xi – 1/m where misthe slope of the edge. • As we move from top to bottom value of y coordinates between the two scanline changesby 1. • yi+1 = yi -1 • Many times it isnot necessary to compute the x intersection for scan line with every polygon side. • We need to consider only the polygon sides with endpoints straddling the current scanline.
  • 23. ScanLinePolygonFill Algorithm 21 • It will be easier to identify which polygon sides should be tested for x intersection, if we first sortthesidesin order of theirmaximum y value. • Oncethesidesare sorted wecanprocessthe scanlinesfrom top of the polygon to its bottom producing an active edge list for eachscan line crossing the polygon boundaries. • Theactive edge list for a scanlinecontain all edgescrossed by that scanline.
  • 24. ScanLinePolygonFill Algorithm 22 Sorted List of edges A C D E F G H J I B BC BA DC DE AJ GF GH EF HI JI TOP BOTTOM
  • 25. 25 Summary • Polygon Filling • Seed Fill - Boundary Fill, Flood Fill • Scan Line Algorithm
  • 26. 26 On next lessons • Two dimensional transformations