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
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
Mohd Arif
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unit
aravindangc
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
Mohd Arif
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
anku2266
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
rajivagarwal23dei
 

What's hot (20)

Back face detection
Back face detectionBack face detection
Back face detection
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
Clipping
ClippingClipping
Clipping
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Z buffer
Z bufferZ buffer
Z buffer
 
Clipping in Computer Graphics
Clipping in Computer Graphics Clipping in Computer Graphics
Clipping in Computer Graphics
 
Line clipping
Line clippingLine clipping
Line clipping
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unit
 
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
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
2 d viewing computer graphics
2 d viewing computer graphics2 d viewing computer graphics
2 d viewing computer graphics
 
Unit 3
Unit 3Unit 3
Unit 3
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfaces
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
 

Viewers also liked

Clipping Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphics
student(MCA)
 
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 Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphics
 
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
 
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
 
Cohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmCohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithm
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing 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

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
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
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
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...
 
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
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
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
 
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
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
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 🔝✔️✔️
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 

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