SlideShare a Scribd company logo
1 of 21
168 471 Computer Graphics, KKU. Lecture 8 1
Clipping on a Raster Display
168 471 Computer Graphics, KKU. Lecture 8 2
Approaches to Clipping
168 471 Computer Graphics, KKU. Lecture 8 3
Analytical Clipping
168 471 Computer Graphics, KKU. Lecture 8 4
Clipping Lines Against Rectangles
168 471 Computer Graphics, KKU. Lecture 8 5
Clipping Rules
168 471 Computer Graphics, KKU. Lecture 8 6
Computing Intersections
168 471 Computer Graphics, KKU. Lecture 8 7
Cohen-Sutherland Algorithm
168 471 Computer Graphics, KKU. Lecture 8 8
Outcodes
168 471 Computer Graphics, KKU. Lecture 8 9
Outcode Computation
typedef unsigned int outcode;
enum {TOP = 0x1, BOTTOM = 0x2, RIGHT = 0x4, LEFT = 0x8}
outcode CompOutCode(
double x, double y, double xmin, double xmax, double ymin, double ymax)
{
outcode code = 0;
if ( y > ymax )
code |= TOP;
else if ( y < ymin )
code |= BOTTOM;
if ( x > xmax )
code |= RIGHT;
else if ( x < xmin )
code |= LEFT;
return code;
}
168 471 Computer Graphics, KKU. Lecture 8 10
Cohen-Sutherland Procedures
168 471 Computer Graphics, KKU. Lecture 8 11
Cohen-Sutherland Procedures
168 471 Computer Graphics, KKU. Lecture 8 12
Cohen-Sutherland Algorithm
168 471 Computer Graphics, KKU. Lecture 8 13
Cohen-Sutherland Algorithm (cont.)
168 471 Computer Graphics, KKU. Lecture 8 14
Cohen-Sutherland Procedures
168 471 Computer Graphics, KKU. Lecture 8 15
Parametric Line-Clipping Algorithm
0 1 0
0 1 0
0
1 0
[ ( ) ] 0
[ ( ) ] 0
[ ] [ ] 0
[ ]
( )
i Ei
i Ei
i Ei i
i Ei
i
N P t P
N P P P t P
N P P N P P t
N P P
t
N D
where D P P
 
   
   

 
 
• Introduced by Cyrud and Beck in 1978
• Efficiently improved by Liang and Barsky
• Essentially find the parameter t from P(t) = P0 + (P1-P0)t
168 471 Computer Graphics, KKU. Lecture 8 16
Parametric Line-Clipping Algorithm
(cont.)
• Formally, intersections can be classified as PE (potentially entering)
and PL (potentially leaving) on the basis of the angle between P0P1
and Ni
•Determine tE or tL for each intersection
• Select the line segment that has maximum tE and minimum tL
•If tE > tL, then trivially rejected
0 ( 90)
0 ( 90)
i
i
N D PE angle
N D PL angle
  
  
168 471 Computer Graphics, KKU. Lecture 8 17
Parametric Line-Clipping Algorithm
(cont.)
168 471 Computer Graphics, KKU. Lecture 8 18
Cyrus-Beck Algorithm (Pseudocode)
168 471 Computer Graphics, KKU. Lecture 8 19
Clipping Circles and Ellipses
• Firstly, do a trivial accept/reject test by intersecting
the circle’s/elleipse’s extent with the clip rectengle.
• If intersection occurs, divide it into and do the trivial
accept/reject test for each.
• If scan conversion is fast or if the circle is not too
large, scissoring on a pixel-by-pixel basis would be
more efficient.
168 471 Computer Graphics, KKU. Lecture 8 20
Clipping Polygons
Example of polygon clipping, (a) Multiple components.
(b) Simple convex case. (c) Concave case.
168 471 Computer Graphics, KKU. Lecture 8 21
Clipping Polygons (cont.)
Polygon clipping, edge by edge. (a) Before clipping. (b) Clip on right.
(c) Clip on bottom. (d) Clip on left. (e) Clip on top; polygon is fully
clipped

More Related Content

What's hot

Alg II 2-7 Transformations
Alg II 2-7 TransformationsAlg II 2-7 Transformations
Alg II 2-7 Transformations
jtentinger
 

What's hot (18)

Final year presentation Mg charm - Anuragsaxena
Final year presentation Mg charm  - AnuragsaxenaFinal year presentation Mg charm  - Anuragsaxena
Final year presentation Mg charm - Anuragsaxena
 
Test
TestTest
Test
 
Lab 4 Three-Bit Binary Adder
Lab 4 Three-Bit Binary AdderLab 4 Three-Bit Binary Adder
Lab 4 Three-Bit Binary Adder
 
Application of Non-linear Electronics in Digital Communication
Application of Non-linear Electronics in Digital CommunicationApplication of Non-linear Electronics in Digital Communication
Application of Non-linear Electronics in Digital Communication
 
aip shape detection and tracking using contours
aip shape detection and tracking using contoursaip shape detection and tracking using contours
aip shape detection and tracking using contours
 
Dip 5 mathematical preliminaries
Dip 5 mathematical preliminariesDip 5 mathematical preliminaries
Dip 5 mathematical preliminaries
 
35th 36th Lecture
35th 36th Lecture35th 36th Lecture
35th 36th Lecture
 
Group p
Group pGroup p
Group p
 
Ripple Carry Adder
Ripple Carry AdderRipple Carry Adder
Ripple Carry Adder
 
Comparison among Different Adders
Comparison among Different Adders Comparison among Different Adders
Comparison among Different Adders
 
Alg II 2-7 Transformations
Alg II 2-7 TransformationsAlg II 2-7 Transformations
Alg II 2-7 Transformations
 
Tiap
TiapTiap
Tiap
 
Parallel Adder
Parallel Adder Parallel Adder
Parallel Adder
 
Matlab Nn Intro
Matlab Nn IntroMatlab Nn Intro
Matlab Nn Intro
 
Half adder layout design
Half adder layout designHalf adder layout design
Half adder layout design
 
Implementation
ImplementationImplementation
Implementation
 
Yasar University Linear Algebra Calculator
Yasar University Linear Algebra CalculatorYasar University Linear Algebra Calculator
Yasar University Linear Algebra Calculator
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 

Similar to Cg471 08

Materi_05_CG_2223_2_.pdf
Materi_05_CG_2223_2_.pdfMateri_05_CG_2223_2_.pdf
Materi_05_CG_2223_2_.pdf
ichsan6
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Thirunavukarasu Mani
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Ketan Jani
 

Similar to Cg471 08 (20)

Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygonsLiang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
 
lecture 1.pptx
lecture 1.pptxlecture 1.pptx
lecture 1.pptx
 
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by OraclesEfficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
06 clipping
06 clipping06 clipping
06 clipping
 
Introduction_to_Mechatronics_Chapter5.pdf
Introduction_to_Mechatronics_Chapter5.pdfIntroduction_to_Mechatronics_Chapter5.pdf
Introduction_to_Mechatronics_Chapter5.pdf
 
Chapter1
Chapter1Chapter1
Chapter1
 
Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Cl...
Theoretical and Practical Bounds on the Initial Value of  Skew-Compensated Cl...Theoretical and Practical Bounds on the Initial Value of  Skew-Compensated Cl...
Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Cl...
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Comparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for ImprovementComparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for Improvement
 
Materi_05_CG_2223_2_.pdf
Materi_05_CG_2223_2_.pdfMateri_05_CG_2223_2_.pdf
Materi_05_CG_2223_2_.pdf
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
lecture8 clipping
lecture8 clippinglecture8 clipping
lecture8 clipping
 
Chapter1.ppt
Chapter1.pptChapter1.ppt
Chapter1.ppt
 
computer logic and digital design chapter 1
computer logic and digital design chapter 1computer logic and digital design chapter 1
computer logic and digital design chapter 1
 
Pid En Un Pic16 F684
Pid En Un Pic16 F684Pid En Un Pic16 F684
Pid En Un Pic16 F684
 
Pid En Un Pic16 F684
Pid En Un Pic16 F684Pid En Un Pic16 F684
Pid En Un Pic16 F684
 
microprocessors
microprocessorsmicroprocessors
microprocessors
 

Recently uploaded

تقرير منظمة الصحة العالمية الخاص بالغذاء د حاتم البيطار.pdf
تقرير منظمة الصحة العالمية الخاص بالغذاء د حاتم البيطار.pdfتقرير منظمة الصحة العالمية الخاص بالغذاء د حاتم البيطار.pdf
تقرير منظمة الصحة العالمية الخاص بالغذاء د حاتم البيطار.pdf
د حاتم البيطار
 
Healthcare Market Overview, May 2024: Funding, Financing and M&A, from Oppenh...
Healthcare Market Overview, May 2024: Funding, Financing and M&A, from Oppenh...Healthcare Market Overview, May 2024: Funding, Financing and M&A, from Oppenh...
Healthcare Market Overview, May 2024: Funding, Financing and M&A, from Oppenh...
Levi Shapiro
 

Recently uploaded (20)

Organisation and Management of Eye Care Programme Service Delivery Models
Organisation and Management of Eye Care Programme Service Delivery ModelsOrganisation and Management of Eye Care Programme Service Delivery Models
Organisation and Management of Eye Care Programme Service Delivery Models
 
تقرير منظمة الصحة العالمية الخاص بالغذاء د حاتم البيطار.pdf
تقرير منظمة الصحة العالمية الخاص بالغذاء د حاتم البيطار.pdfتقرير منظمة الصحة العالمية الخاص بالغذاء د حاتم البيطار.pdf
تقرير منظمة الصحة العالمية الخاص بالغذاء د حاتم البيطار.pdf
 
Healthcare Market Overview, May 2024: Funding, Financing and M&A, from Oppenh...
Healthcare Market Overview, May 2024: Funding, Financing and M&A, from Oppenh...Healthcare Market Overview, May 2024: Funding, Financing and M&A, from Oppenh...
Healthcare Market Overview, May 2024: Funding, Financing and M&A, from Oppenh...
 
VIP ℂall Girls Sushant Lok 9873777170 WhatsApp: Me All Time Serviℂe Available
VIP ℂall Girls Sushant Lok 9873777170 WhatsApp: Me All Time Serviℂe AvailableVIP ℂall Girls Sushant Lok 9873777170 WhatsApp: Me All Time Serviℂe Available
VIP ℂall Girls Sushant Lok 9873777170 WhatsApp: Me All Time Serviℂe Available
 
Australia,USA,UK #Online psychic ,"£ +27834335081 Canada Lost Love Spell Cast...
Australia,USA,UK #Online psychic ,"£ +27834335081 Canada Lost Love Spell Cast...Australia,USA,UK #Online psychic ,"£ +27834335081 Canada Lost Love Spell Cast...
Australia,USA,UK #Online psychic ,"£ +27834335081 Canada Lost Love Spell Cast...
 
ℂall Girls South Delhi ℂall Now Chhaya ☎ 9899900591 WhatsApp Number 24/7
ℂall Girls South Delhi ℂall Now Chhaya ☎ 9899900591 WhatsApp  Number 24/7ℂall Girls South Delhi ℂall Now Chhaya ☎ 9899900591 WhatsApp  Number 24/7
ℂall Girls South Delhi ℂall Now Chhaya ☎ 9899900591 WhatsApp Number 24/7
 
Top^Clinic ^%[+27785538335__Safe*Abortion Pills For Sale In Soweto
Top^Clinic ^%[+27785538335__Safe*Abortion Pills For Sale In SowetoTop^Clinic ^%[+27785538335__Safe*Abortion Pills For Sale In Soweto
Top^Clinic ^%[+27785538335__Safe*Abortion Pills For Sale In Soweto
 
Session-1-MBFHI-A-part-of-the-Global-Strategy.ppt
Session-1-MBFHI-A-part-of-the-Global-Strategy.pptSession-1-MBFHI-A-part-of-the-Global-Strategy.ppt
Session-1-MBFHI-A-part-of-the-Global-Strategy.ppt
 
Session-3-Promoting-Breastfeeding-During-Pregnancy.ppt
Session-3-Promoting-Breastfeeding-During-Pregnancy.pptSession-3-Promoting-Breastfeeding-During-Pregnancy.ppt
Session-3-Promoting-Breastfeeding-During-Pregnancy.ppt
 
Lactation Mraining Management Session-2-Comm-Building-Conf.ppt
Lactation Mraining Management  Session-2-Comm-Building-Conf.pptLactation Mraining Management  Session-2-Comm-Building-Conf.ppt
Lactation Mraining Management Session-2-Comm-Building-Conf.ppt
 
Technology transfer documentation and strategies
Technology transfer documentation and strategiesTechnology transfer documentation and strategies
Technology transfer documentation and strategies
 
clostridiumbotulinum- BY Muzammil Ahmed Siddiqui.pptx
clostridiumbotulinum- BY Muzammil Ahmed Siddiqui.pptxclostridiumbotulinum- BY Muzammil Ahmed Siddiqui.pptx
clostridiumbotulinum- BY Muzammil Ahmed Siddiqui.pptx
 
Leadership Style - Code and Rapid Response Workshop
Leadership Style - Code and Rapid Response WorkshopLeadership Style - Code and Rapid Response Workshop
Leadership Style - Code and Rapid Response Workshop
 
Anthony Edwards We Want Dallas T-shirtsAnthony Edwards We Want Dallas T-shirts
Anthony Edwards We Want Dallas T-shirtsAnthony Edwards We Want Dallas T-shirtsAnthony Edwards We Want Dallas T-shirtsAnthony Edwards We Want Dallas T-shirts
Anthony Edwards We Want Dallas T-shirtsAnthony Edwards We Want Dallas T-shirts
 
An overview of Muir Wood Adolescent and Family Services teen treatment programs.
An overview of Muir Wood Adolescent and Family Services teen treatment programs.An overview of Muir Wood Adolescent and Family Services teen treatment programs.
An overview of Muir Wood Adolescent and Family Services teen treatment programs.
 
Communication disorder and it's management
Communication disorder and it's managementCommunication disorder and it's management
Communication disorder and it's management
 
GOUT and it's Management with All the catagories like; Defination, Type, Sym...
GOUT and it's Management with All the catagories like;  Defination, Type, Sym...GOUT and it's Management with All the catagories like;  Defination, Type, Sym...
GOUT and it's Management with All the catagories like; Defination, Type, Sym...
 
Mike Lowe’s cancer fight lowe strong shirt
Mike Lowe’s cancer fight lowe strong shirtMike Lowe’s cancer fight lowe strong shirt
Mike Lowe’s cancer fight lowe strong shirt
 
POSHAN ABHIYAAN-Poshan 2.0 will concentrate on Maternal Nutrition, Infant and...
POSHAN ABHIYAAN-Poshan 2.0 will concentrate on Maternal Nutrition, Infant and...POSHAN ABHIYAAN-Poshan 2.0 will concentrate on Maternal Nutrition, Infant and...
POSHAN ABHIYAAN-Poshan 2.0 will concentrate on Maternal Nutrition, Infant and...
 
Pulse Check Decisions - RRT and Code Blue Workshop
Pulse Check Decisions - RRT and Code Blue WorkshopPulse Check Decisions - RRT and Code Blue Workshop
Pulse Check Decisions - RRT and Code Blue Workshop
 

Cg471 08

  • 1. 168 471 Computer Graphics, KKU. Lecture 8 1 Clipping on a Raster Display
  • 2. 168 471 Computer Graphics, KKU. Lecture 8 2 Approaches to Clipping
  • 3. 168 471 Computer Graphics, KKU. Lecture 8 3 Analytical Clipping
  • 4. 168 471 Computer Graphics, KKU. Lecture 8 4 Clipping Lines Against Rectangles
  • 5. 168 471 Computer Graphics, KKU. Lecture 8 5 Clipping Rules
  • 6. 168 471 Computer Graphics, KKU. Lecture 8 6 Computing Intersections
  • 7. 168 471 Computer Graphics, KKU. Lecture 8 7 Cohen-Sutherland Algorithm
  • 8. 168 471 Computer Graphics, KKU. Lecture 8 8 Outcodes
  • 9. 168 471 Computer Graphics, KKU. Lecture 8 9 Outcode Computation typedef unsigned int outcode; enum {TOP = 0x1, BOTTOM = 0x2, RIGHT = 0x4, LEFT = 0x8} outcode CompOutCode( double x, double y, double xmin, double xmax, double ymin, double ymax) { outcode code = 0; if ( y > ymax ) code |= TOP; else if ( y < ymin ) code |= BOTTOM; if ( x > xmax ) code |= RIGHT; else if ( x < xmin ) code |= LEFT; return code; }
  • 10. 168 471 Computer Graphics, KKU. Lecture 8 10 Cohen-Sutherland Procedures
  • 11. 168 471 Computer Graphics, KKU. Lecture 8 11 Cohen-Sutherland Procedures
  • 12. 168 471 Computer Graphics, KKU. Lecture 8 12 Cohen-Sutherland Algorithm
  • 13. 168 471 Computer Graphics, KKU. Lecture 8 13 Cohen-Sutherland Algorithm (cont.)
  • 14. 168 471 Computer Graphics, KKU. Lecture 8 14 Cohen-Sutherland Procedures
  • 15. 168 471 Computer Graphics, KKU. Lecture 8 15 Parametric Line-Clipping Algorithm 0 1 0 0 1 0 0 1 0 [ ( ) ] 0 [ ( ) ] 0 [ ] [ ] 0 [ ] ( ) i Ei i Ei i Ei i i Ei i N P t P N P P P t P N P P N P P t N P P t N D where D P P                • Introduced by Cyrud and Beck in 1978 • Efficiently improved by Liang and Barsky • Essentially find the parameter t from P(t) = P0 + (P1-P0)t
  • 16. 168 471 Computer Graphics, KKU. Lecture 8 16 Parametric Line-Clipping Algorithm (cont.) • Formally, intersections can be classified as PE (potentially entering) and PL (potentially leaving) on the basis of the angle between P0P1 and Ni •Determine tE or tL for each intersection • Select the line segment that has maximum tE and minimum tL •If tE > tL, then trivially rejected 0 ( 90) 0 ( 90) i i N D PE angle N D PL angle      
  • 17. 168 471 Computer Graphics, KKU. Lecture 8 17 Parametric Line-Clipping Algorithm (cont.)
  • 18. 168 471 Computer Graphics, KKU. Lecture 8 18 Cyrus-Beck Algorithm (Pseudocode)
  • 19. 168 471 Computer Graphics, KKU. Lecture 8 19 Clipping Circles and Ellipses • Firstly, do a trivial accept/reject test by intersecting the circle’s/elleipse’s extent with the clip rectengle. • If intersection occurs, divide it into and do the trivial accept/reject test for each. • If scan conversion is fast or if the circle is not too large, scissoring on a pixel-by-pixel basis would be more efficient.
  • 20. 168 471 Computer Graphics, KKU. Lecture 8 20 Clipping Polygons Example of polygon clipping, (a) Multiple components. (b) Simple convex case. (c) Concave case.
  • 21. 168 471 Computer Graphics, KKU. Lecture 8 21 Clipping Polygons (cont.) Polygon clipping, edge by edge. (a) Before clipping. (b) Clip on right. (c) Clip on bottom. (d) Clip on left. (e) Clip on top; polygon is fully clipped