SlideShare a Scribd company logo
1 of 18
clipping
(Cohen-Sutherland
Algorithm)
JMHM Jayamaha
SEU/IS/10/PS/104
PS0372
Content
 What is Clipping ?.
 Point clipping
 Line clipping
 Cohen-Sutherland Algorithm
What is Clipping ?
 Any Procedure that identifies those portions of a picture that are either inside
or outside of a specified region of a space is referred to as a Clipping
algorithm or simply Clipping.
 The primary use of clipping in computer graphics is to remove objects, lines,
or line segments that are outside the viewing pane.
Point Clipping
 Clipping a point from a given window is very easy. Consider the following
figure, where the rectangle indicates the window. Point clipping tells us
whether the given point (X, Y) is within the given window or not; and decides
whether we will use the minimum and maximum coordinates of the window.
 The X-coordinate of the given point is inside the window, if X lies in between
Wx1 ≤ X ≤ Wx2. Same way, Y coordinate of the given point is inside the
window, if Y lies in between Wy1 ≤ Y ≤ Wy2.
Line Clipping
 The concept of line clipping is same as point clipping. In line clipping, we will
cut the portion of line which is outside of window and keep only the portion
that is inside the window.
Cohen-Sutherland Algorithm
 eliminate as many cases as possible without computing intersections
 Start with four lines that determine the sides of the clipping window
The Cases
 Case 1: both endpoints of line segment inside all four lines
 Draw (accept) line segment as is
 Case 2: both endpoints outside all lines and on same side of some line
 Discard (reject) the line segment
The Cases
 Case 3: One endpoint inside, one outside
 Must do at least one intersection
 Case 4: Both outside all lines but not on same side of any line
 May have part inside
 Must do at least one intersection
Defining Outcodes
 b0 b1 b2 b3
b0 = 1 if y > ymax, 0 otherwise
b1 = 1 if y < ymin, 0 otherwise
b2 = 1 if x > xmax, 0 otherwise
b3 = 1 if x < xmin, 0 otherwise
Defining Outcodes
 For each endpoint, define an outcode
 Outcodes divide space into 9 regions
Algorithm
Using Outcodes
 Consider the 5 cases below
 AB: outcode(A) = outcode(B) = 0
 Accept line segment
Using Outcodes
 CD: outcode (C)= 0, outcode(D)=0010≠ 0
 Compute intersection
 Location of 1 in outcode(D) determines which edge to intersect with
 Note if there were a segment from A to a point in a region with 2 ones in outcode,
we might have to do two interesections
Using Outcodes
 EF: outcode(E) logically AND ed with outcode(F) (bitwise) ≠ 0
 Both outcodes have a 1 bit in the same place
 Line segment is outside of corresponding side of clipping window
 reject
Using Outcodes
 GH and IJ: same outcodes, neither zero but logical AND yields zero
 Shorten line segment by intersecting with one of sides of window
 Compute outcode of intersection (new endpoint of shortened line segment)
 Reexecute algorithm
Efficiency
 In many applications, the clipping window is small relative to the size of the
whole data base
 Most line segments are outside one or more side of the window and can be
eliminated based on their outcodes
 Inefficiency when code has to be reexecuted for line segments that must be
shortened in more than one step
Summary
 Clipping is the method of cutting a graphics display to neatly fit a predefined
graphics region or view port.
 Cohen-Sutherland algorithm
References
 http://www.tutorialspoint.com/computer_graphics/viewing_and_clipping.ht
m
 http://www.cs.kent.edu/~farrell/cg05/lectures/cg25.pdf
 https://www.youtube.com/watch?v=dQNTyVLDP5Q

More Related Content

What's hot

The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
Mani Kanth
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
Ankit Garg
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unit
aravindangc
 
Clipping Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphics
student(MCA)
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
Mohd Arif
 
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithmPolygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Mani Kanth
 

What's hot (20)

The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
Scan line method
Scan line methodScan line method
Scan line method
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Output primitives computer graphics c version
Output primitives   computer graphics c versionOutput primitives   computer graphics c version
Output primitives computer graphics c version
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - Notes
 
Computer Graphics - clipping
Computer Graphics - clippingComputer Graphics - clipping
Computer Graphics - clipping
 
Clipping in Computer Graphics
Clipping in Computer Graphics Clipping in Computer Graphics
Clipping in Computer Graphics
 
2 d viewing computer graphics
2 d viewing computer graphics2 d viewing computer graphics
2 d viewing computer graphics
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithms
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unit
 
Clipping Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphics
 
Parallel projection
Parallel projectionParallel projection
Parallel projection
 
Depth Buffer Method
Depth Buffer MethodDepth Buffer Method
Depth Buffer Method
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithmPolygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
 

Viewers also liked

Security Patterns with WSO2 ESB
Security Patterns with WSO2 ESBSecurity Patterns with WSO2 ESB
Security Patterns with WSO2 ESB
WSO2
 

Viewers also liked (20)

Clipping
ClippingClipping
Clipping
 
Advance operator and technique in genetic algorithm
Advance operator and technique in genetic algorithmAdvance operator and technique in genetic algorithm
Advance operator and technique in genetic algorithm
 
Security Patterns with WSO2 ESB
Security Patterns with WSO2 ESBSecurity Patterns with WSO2 ESB
Security Patterns with WSO2 ESB
 
clipping
clippingclipping
clipping
 
Artificial Neural Network Topology
Artificial Neural Network TopologyArtificial Neural Network Topology
Artificial Neural Network Topology
 
Distributed System - Security
Distributed System - SecurityDistributed System - Security
Distributed System - Security
 
Wso2 esb-maintenance-guide
Wso2 esb-maintenance-guideWso2 esb-maintenance-guide
Wso2 esb-maintenance-guide
 
Cohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marksCohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marks
 
Windowing and clipping final1
Windowing and clipping final1Windowing and clipping final1
Windowing and clipping final1
 
06 clipping
06 clipping06 clipping
06 clipping
 
Wso2 esb-rest-integration
Wso2 esb-rest-integrationWso2 esb-rest-integration
Wso2 esb-rest-integration
 
Wso2 esb 5.0.0 product release webinar
Wso2 esb 5.0.0   product release webinarWso2 esb 5.0.0   product release webinar
Wso2 esb 5.0.0 product release webinar
 
Operating system critical section
Operating system   critical sectionOperating system   critical section
Operating system critical section
 
Cohen-sutherland & liang-basky line clipping algorithm
Cohen-sutherland & liang-basky line clipping algorithmCohen-sutherland & liang-basky line clipping algorithm
Cohen-sutherland & liang-basky line clipping algorithm
 
Clipping
ClippingClipping
Clipping
 
Handwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural networkHandwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural network
 
Computer Graphics HAND BOOK 2013
Computer Graphics HAND BOOK 2013Computer Graphics HAND BOOK 2013
Computer Graphics HAND BOOK 2013
 
Curve clipping
Curve clippingCurve clipping
Curve clipping
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 

Similar to Clipping ( Cohen-Sutherland 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
 

Similar to Clipping ( Cohen-Sutherland Algorithm ) (20)

lecture8 clipping
lecture8 clippinglecture8 clipping
lecture8 clipping
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
 
Clipping
ClippingClipping
Clipping
 
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
 
Clipping
ClippingClipping
Clipping
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
Unit2- line clipping.pptx
Unit2- line clipping.pptxUnit2- line clipping.pptx
Unit2- line clipping.pptx
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdf
 
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
 
Clipping
ClippingClipping
Clipping
 
line clipping
line clipping line clipping
line clipping
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Lcdf4 chap 03_p2
Lcdf4 chap 03_p2Lcdf4 chap 03_p2
Lcdf4 chap 03_p2
 
19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf
19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf
19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf
 
kgv.pptx
kgv.pptxkgv.pptx
kgv.pptx
 
ibuib.pptx
ibuib.pptxibuib.pptx
ibuib.pptx
 
Implementation
ImplementationImplementation
Implementation
 

Recently uploaded

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Recently uploaded (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Clipping ( Cohen-Sutherland Algorithm )

  • 2. Content  What is Clipping ?.  Point clipping  Line clipping  Cohen-Sutherland Algorithm
  • 3. What is Clipping ?  Any Procedure that identifies those portions of a picture that are either inside or outside of a specified region of a space is referred to as a Clipping algorithm or simply Clipping.  The primary use of clipping in computer graphics is to remove objects, lines, or line segments that are outside the viewing pane.
  • 4. Point Clipping  Clipping a point from a given window is very easy. Consider the following figure, where the rectangle indicates the window. Point clipping tells us whether the given point (X, Y) is within the given window or not; and decides whether we will use the minimum and maximum coordinates of the window.  The X-coordinate of the given point is inside the window, if X lies in between Wx1 ≤ X ≤ Wx2. Same way, Y coordinate of the given point is inside the window, if Y lies in between Wy1 ≤ Y ≤ Wy2.
  • 5. Line Clipping  The concept of line clipping is same as point clipping. In line clipping, we will cut the portion of line which is outside of window and keep only the portion that is inside the window.
  • 6. Cohen-Sutherland Algorithm  eliminate as many cases as possible without computing intersections  Start with four lines that determine the sides of the clipping window
  • 7. The Cases  Case 1: both endpoints of line segment inside all four lines  Draw (accept) line segment as is  Case 2: both endpoints outside all lines and on same side of some line  Discard (reject) the line segment
  • 8. The Cases  Case 3: One endpoint inside, one outside  Must do at least one intersection  Case 4: Both outside all lines but not on same side of any line  May have part inside  Must do at least one intersection
  • 9. Defining Outcodes  b0 b1 b2 b3 b0 = 1 if y > ymax, 0 otherwise b1 = 1 if y < ymin, 0 otherwise b2 = 1 if x > xmax, 0 otherwise b3 = 1 if x < xmin, 0 otherwise
  • 10. Defining Outcodes  For each endpoint, define an outcode  Outcodes divide space into 9 regions
  • 12. Using Outcodes  Consider the 5 cases below  AB: outcode(A) = outcode(B) = 0  Accept line segment
  • 13. Using Outcodes  CD: outcode (C)= 0, outcode(D)=0010≠ 0  Compute intersection  Location of 1 in outcode(D) determines which edge to intersect with  Note if there were a segment from A to a point in a region with 2 ones in outcode, we might have to do two interesections
  • 14. Using Outcodes  EF: outcode(E) logically AND ed with outcode(F) (bitwise) ≠ 0  Both outcodes have a 1 bit in the same place  Line segment is outside of corresponding side of clipping window  reject
  • 15. Using Outcodes  GH and IJ: same outcodes, neither zero but logical AND yields zero  Shorten line segment by intersecting with one of sides of window  Compute outcode of intersection (new endpoint of shortened line segment)  Reexecute algorithm
  • 16. Efficiency  In many applications, the clipping window is small relative to the size of the whole data base  Most line segments are outside one or more side of the window and can be eliminated based on their outcodes  Inefficiency when code has to be reexecuted for line segments that must be shortened in more than one step
  • 17. Summary  Clipping is the method of cutting a graphics display to neatly fit a predefined graphics region or view port.  Cohen-Sutherland algorithm