SlideShare ist ein Scribd-Unternehmen logo
1 von 15
POLYGON CLIPPING WITH
SUTHERLAND HODGEMAN
ALGORITHM
AND
SCAN LINE FILL ALGORITHM
Clipping
 The primary use of clipping in computer graphics is to remove
objects, lines, or line segments that are outside the viewing pane .
Clip Window: The region against which an object is to be clipped.
 Point Clipping
 Line Clipping (straight-line segments)
 Area Clipping (polygons)
 Text Clipping
Polygon Clipping
 Clipping a polygon fill area needs more than line-clipping of the
polygon edges
-would produce and unconnected set of lines
 Must generate one or more closed polylines, which can be filled with
the assigned colour or pattern
Sutherland–Hodgeman algorithm
 Each edge of the polygon must be tested against each edge of the clip
rectangle; new edges must be added, and existing edges must be
discarded, retained, or divided. Multiple polygons may result from
clipping a single polygon. We need an organized way to deal with all
these cases
FOUR POSSIBLE SCENARIOS AT EACH CLIPPER
Each edge goes through 4 clippers .The rule for each edge for each clipper is:
 If first input vertex is outside, and second is inside, output the intersection and
the second vertex
 If first both input vertices are inside, then just output second vertex
 If first input vertex is inside, and second is outside, output is the intersection
 If both vertices are outside, output is nothing
Steps of Sutherland-Hodgmans polygon
clipping algorithm
 Polygons can be clipped against each edge of the window one at a
time.
 Vertices which are kept after clipping against one window edge are
saved for clipping against the remaining edges .
 Note that the number of vertices usually changes and will often
increases.
SCAN LINE FILL ALGORITHM
Scan-Line
 A scan line is one line, or row, in a raster scanning
pattern, such as a line of video on a cathode ray
tube display of a television set or computer
monitor.
Scan-line Polygon Fill
For each scan-line :
 Locate the intersection of the scan-line with the edges (y=ys)
 Sort the intersection points from left to right.
 Draw the interiors intersection points pairwise. (a-b), (c-d)
Problem with corners. Same point counted twice or not?
 a,b,c and d are intersected by 2 line segments each.
 Count b,c twice but a and d once. Why?
Solution:
Make a clockwise or counter-clockwise traversal on edges.
Check if y is monotonically increasing or decreasing. If
direction changes, double intersection, otherwise single
intersection.
Scan Line Fill: What happens at edge
end-point?
 Edge endpoint is duplicated.
 In other words, when a scan line intersects an edge endpoint, it
intersects two edges.
 Two cases:
Case A: edges are monotonically increasing or decreasing
Case B: edges reverse direction at endpoint
 In Case A, we should consider this as only ONE edge
intersection
 In Case B, we should consider this as TWO edge intersections
Scan Line Fill Algorithm
Basic algorithm:
 Assume scan line start from the left and is outside the polygon.
 When intersect an edge of polygon, start to color each pixel (because
now we’re inside the polygon), when intersect another edge, stop
coloring …
 Odd number of edges: inside
 Even number of edges: outside
THANK YOU

Weitere ähnliche Inhalte

Was ist angesagt?

Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
Mohd Arif
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
Ankit Garg
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
anku2266
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
Mohd Arif
 
Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)
shalinikarunakaran1
 
Raster Scan and Raster Scan Displays
Raster Scan and Raster Scan DisplaysRaster Scan and Raster Scan Displays
Raster Scan and Raster Scan Displays
Saravana Priya
 

Was ist angesagt? (20)

Clipping
ClippingClipping
Clipping
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - Notes
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clipping
 
Sutherland hodgman polygon clipping algorithm
Sutherland hodgman polygon clipping algorithmSutherland hodgman polygon clipping algorithm
Sutherland hodgman polygon clipping algorithm
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
Random scan displays and raster scan displays
Random scan displays and raster scan displaysRandom scan displays and raster scan displays
Random scan displays and raster scan displays
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)Attributes of output primitives( curve attributes & area fill attributes)
Attributes of output primitives( curve attributes & area fill attributes)
 
COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"
 
Raster Scan and Raster Scan Displays
Raster Scan and Raster Scan DisplaysRaster Scan and Raster Scan Displays
Raster Scan and Raster Scan Displays
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping Algorithm
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
Illumination Models & Shading
Illumination Models & ShadingIllumination Models & Shading
Illumination Models & Shading
 
Clipping in Computer Graphics
Clipping in Computer Graphics Clipping in Computer Graphics
Clipping in Computer Graphics
 

Ähnlich wie Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm

Lecture 2d point,curve,text,line clipping
Lecture   2d point,curve,text,line clippingLecture   2d point,curve,text,line clipping
Lecture 2d point,curve,text,line clipping
avelraj
 

Ähnlich wie Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm (20)

lecture8 clipping
lecture8 clippinglecture8 clipping
lecture8 clipping
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & Rasterization
 
7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Lecture 2d point,curve,text,line clipping
Lecture   2d point,curve,text,line clippingLecture   2d point,curve,text,line clipping
Lecture 2d point,curve,text,line clipping
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Clipping
ClippingClipping
Clipping
 
UNIT2.pptx
UNIT2.pptxUNIT2.pptx
UNIT2.pptx
 
Clipping
ClippingClipping
Clipping
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
 
ibuib.pptx
ibuib.pptxibuib.pptx
ibuib.pptx
 
Clipping
ClippingClipping
Clipping
 
Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )
 
UNIT-III
UNIT-IIIUNIT-III
UNIT-III
 
Group 6 Presentation - Copy.pptx
Group 6 Presentation - Copy.pptxGroup 6 Presentation - Copy.pptx
Group 6 Presentation - Copy.pptx
 
Group 5 Presentation.pptx
Group 5 Presentation.pptxGroup 5 Presentation.pptx
Group 5 Presentation.pptx
 

Mehr von Mani Kanth

Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...
Mani Kanth
 
Raster and random scan display types of input devices
Raster and random scan display types of input devicesRaster and random scan display types of input devices
Raster and random scan display types of input devices
Mani Kanth
 

Mehr von Mani Kanth (20)

White box testing
White box testing White box testing
White box testing
 
Unit testing
Unit testing Unit testing
Unit testing
 
System testing
System testingSystem testing
System testing
 
management of maintainance
management of maintainancemanagement of maintainance
management of maintainance
 
Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)
 
Reverse engineering in software engineering vaibhav
Reverse engineering in software engineering vaibhavReverse engineering in software engineering vaibhav
Reverse engineering in software engineering vaibhav
 
Mutation testing 1
Mutation testing 1Mutation testing 1
Mutation testing 1
 
Mutation testing
Mutation testingMutation testing
Mutation testing
 
Guideline for euivalence class testing
Guideline for euivalence class testingGuideline for euivalence class testing
Guideline for euivalence class testing
 
Equivalence class testing
Equivalence  class testingEquivalence  class testing
Equivalence class testing
 
Deployment
DeploymentDeployment
Deployment
 
unit testing
unit testingunit testing
unit testing
 
Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...
 
Scaling and shearing
Scaling and shearingScaling and shearing
Scaling and shearing
 
Reflection transformation
Reflection transformationReflection transformation
Reflection transformation
 
Raster and random scan display types of input devices
Raster and random scan display types of input devicesRaster and random scan display types of input devices
Raster and random scan display types of input devices
 
Projection
ProjectionProjection
Projection
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Graphics software and standards
Graphics software and standardsGraphics software and standards
Graphics software and standards
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 

Kürzlich hochgeladen

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 

Kürzlich hochgeladen (20)

Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 

Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm

  • 1. POLYGON CLIPPING WITH SUTHERLAND HODGEMAN ALGORITHM AND SCAN LINE FILL ALGORITHM
  • 2. Clipping  The primary use of clipping in computer graphics is to remove objects, lines, or line segments that are outside the viewing pane . Clip Window: The region against which an object is to be clipped.  Point Clipping  Line Clipping (straight-line segments)  Area Clipping (polygons)  Text Clipping
  • 3. Polygon Clipping  Clipping a polygon fill area needs more than line-clipping of the polygon edges -would produce and unconnected set of lines  Must generate one or more closed polylines, which can be filled with the assigned colour or pattern
  • 4. Sutherland–Hodgeman algorithm  Each edge of the polygon must be tested against each edge of the clip rectangle; new edges must be added, and existing edges must be discarded, retained, or divided. Multiple polygons may result from clipping a single polygon. We need an organized way to deal with all these cases
  • 5. FOUR POSSIBLE SCENARIOS AT EACH CLIPPER Each edge goes through 4 clippers .The rule for each edge for each clipper is:  If first input vertex is outside, and second is inside, output the intersection and the second vertex  If first both input vertices are inside, then just output second vertex  If first input vertex is inside, and second is outside, output is the intersection  If both vertices are outside, output is nothing
  • 6. Steps of Sutherland-Hodgmans polygon clipping algorithm  Polygons can be clipped against each edge of the window one at a time.  Vertices which are kept after clipping against one window edge are saved for clipping against the remaining edges .  Note that the number of vertices usually changes and will often increases.
  • 7.
  • 8.
  • 9. SCAN LINE FILL ALGORITHM
  • 10. Scan-Line  A scan line is one line, or row, in a raster scanning pattern, such as a line of video on a cathode ray tube display of a television set or computer monitor.
  • 11. Scan-line Polygon Fill For each scan-line :  Locate the intersection of the scan-line with the edges (y=ys)  Sort the intersection points from left to right.  Draw the interiors intersection points pairwise. (a-b), (c-d)
  • 12. Problem with corners. Same point counted twice or not?  a,b,c and d are intersected by 2 line segments each.  Count b,c twice but a and d once. Why? Solution: Make a clockwise or counter-clockwise traversal on edges. Check if y is monotonically increasing or decreasing. If direction changes, double intersection, otherwise single intersection.
  • 13. Scan Line Fill: What happens at edge end-point?  Edge endpoint is duplicated.  In other words, when a scan line intersects an edge endpoint, it intersects two edges.  Two cases: Case A: edges are monotonically increasing or decreasing Case B: edges reverse direction at endpoint  In Case A, we should consider this as only ONE edge intersection  In Case B, we should consider this as TWO edge intersections
  • 14. Scan Line Fill Algorithm Basic algorithm:  Assume scan line start from the left and is outside the polygon.  When intersect an edge of polygon, start to color each pixel (because now we’re inside the polygon), when intersect another edge, stop coloring …  Odd number of edges: inside  Even number of edges: outside