SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Computer Graphics
Line Clipping
• Cohen Sutherland Algorithm (Line)
( x min
, y min
)
( x max
, y max
)
x = x min
x = x max
y = y min
y = y max
( x 1
, y 1
)
clip
rectangle
maxmin
maxmin
yyy
xxx
≤≤
≤≤
For a pointFor a point ((x,yx,y)) to be inside the clip rectangleto be inside the clip rectangle::
Point Clipping
clip
rectangle
( x a , y a )( x b , y b )
( x c , y c ) ( x d , y d )
( x 0
, y 0
)
( x 1
, y 1
)
( x , y )
clip
rectangle
( x a , y a )( x b , y b )
( x c , y c ) ( x d , y d )
( x 0
, y 0
)
( x 1
, y 1
)
( x , y )
( )
( )
1 1 1 1
1 1 1 1
1
: , 0, : ( ) ,
1
: , 0, : ( ) ,
T L
B R
Top x x y y m Left y m x x y m
m
Bottom x x y y m Right y m x x y m
m
= + − ≠ = − + ≠∞
= + − ≠ = − + ≠∞
Line Clipping
0000
1000
0100
1001 1010
0001 0010
0101 0110
clip
rectangle
Region outcodesRegion outcodes
min
max
yy
yy
<
>
:1bit
:0bit
min
max
xx
xx
<
>
:3bit
:2bit
Cohen-Sutherland Algorithm
The Cohen-Sutherland Line-Clipping
Algorithm performs initial tests on a line to
determine whether intersection calculations
can be avoided.
1. First, end-point pairs are checked for trivial
Acceptance.
2. If the line cannot be trivially accepted, region
checks are done for Trivial Rejection.
3. If the line segment can be neither trivially
accepted or rejected, it is divided into two
segments at a clip edge, so that one segment
can be trivially rejected.
These three steps are performed iteratively until
what remains can be trivially accepted or rejected.
Cohen-Sutherland Algorithm
Cohen-Sutherland Algorithm
Algorithm
1-Compute the codes for the Two end points
2-Enter in loop, check if both region codes are
zero(0000 and 0000) put line in display file
for display and exit loop, return
3-If both region codes are not zero then take
logical AND of both codes, check result for
nonzero if so reject line exit loop, return
4-If result is zero then subdivide the line from
intersection point of line and clipping
boundary and repeat step 2,3,4.
5. Special Case when test 4 fails.
clip
rectangle
A
B
C
D
E
An ExampleAn Example
Cohen-Sutherland Algorithm
An ExampleAn Example
clip
rectangle
B
C
D
E
Cohen-Sutherland Algorithm
An ExampleAn Example
clip
rectangle
B
C
D
Cohen-Sutherland Algorithm
An ExampleAn Example
clip
rectangle
B
C
Cohen-Sutherland Algorithm
Q1. Use Cohen Sutherland Algorithm to
clip line p1(70,20) and P2 (100,10)
against window lower left hand corner
(50,10) and upper right hand corner
(80,40).
Q2. Given a clipping window A(20,20),
B(60,20), C(60,40), D(20,40). Using
sutherland cohen algorithm find the
visible portion of line segment joining
the points p(40,80),Q(120,30).
Thank You

More Related Content

PPT
Composite transformations
PPTX
Cohen sutherland line clipping
PPTX
Introduction TO Finite Automata
PDF
Unit 3
PPTX
2 d viewing computer graphics
PPTX
Input of graphical data
PPTX
Circle generation algorithm
Composite transformations
Cohen sutherland line clipping
Introduction TO Finite Automata
Unit 3
2 d viewing computer graphics
Input of graphical data
Circle generation algorithm

What's hot (20)

PPTX
Clipping
PPTX
Attributes of output primitive(line attributes)
PPT
Polygon clipping
PPTX
Mid point circle algorithm
PPTX
3D transformation in computer graphics
PDF
mid point algorithm.pdf
PPT
Polygon filling
PPTX
Back face detection
PPTX
Cohen sutherland line clipping algorithm
PPTX
Hill climbing algorithm
PDF
4. THREE DIMENSIONAL DISPLAY METHODS
PPTX
Video display devices
PPTX
Cohen-Sutherland Line Clipping Algorithm
PPTX
BRESENHAM’S LINE DRAWING ALGORITHM
PPTX
LR(1) and SLR(1) parsing
PPTX
Hidden surface removal algorithm
DOC
COMPUTER GRAPHICS LAB MANUAL
PPTX
Segments in Graphics
PPTX
Halftoning in Computer Graphics
PPTX
Dda algorithm
Clipping
Attributes of output primitive(line attributes)
Polygon clipping
Mid point circle algorithm
3D transformation in computer graphics
mid point algorithm.pdf
Polygon filling
Back face detection
Cohen sutherland line clipping algorithm
Hill climbing algorithm
4. THREE DIMENSIONAL DISPLAY METHODS
Video display devices
Cohen-Sutherland Line Clipping Algorithm
BRESENHAM’S LINE DRAWING ALGORITHM
LR(1) and SLR(1) parsing
Hidden surface removal algorithm
COMPUTER GRAPHICS LAB MANUAL
Segments in Graphics
Halftoning in Computer Graphics
Dda algorithm
Ad

Viewers also liked (6)

PPTX
Digital image processing &amp; computer graphics
DOCX
Curve clipping
PPT
Projection ppt
PPT
3 d transformations
PPT
Line drawing algorithm and antialiasing techniques
PPT
Character generation
Digital image processing &amp; computer graphics
Curve clipping
Projection ppt
3 d transformations
Line drawing algorithm and antialiasing techniques
Character generation
Ad

Similar to Line clipping (20)

PPT
06 clipping
PPTX
Computer Graphics Unit 1
PPTX
Clipping computer graphics
PPTX
Clipping & Rasterization
PDF
Computer graphics 2
DOCX
Cohen sutherland algorithm
PDF
raster algorithm.pdf
PPTX
clippiNG COMPUTER GRAPHICS A NEW ERA.pptx
PPTX
Computer Graphic - Clipping
PPTX
PPT
99995327.ppt
PPTX
PPTX
2D viewing & clipping
PPT
Bresenham circlesandpolygons
PPT
Bresenham circles and polygons derication
PDF
Regresion logistica-modelo de clasificacion
PDF
10CSL67 CG LAB PROGRAM 5
PPTX
Clipping 22
PPTX
Clipping 22
PPTX
MATLABgraphPlotting.pptx
06 clipping
Computer Graphics Unit 1
Clipping computer graphics
Clipping & Rasterization
Computer graphics 2
Cohen sutherland algorithm
raster algorithm.pdf
clippiNG COMPUTER GRAPHICS A NEW ERA.pptx
Computer Graphic - Clipping
99995327.ppt
2D viewing & clipping
Bresenham circlesandpolygons
Bresenham circles and polygons derication
Regresion logistica-modelo de clasificacion
10CSL67 CG LAB PROGRAM 5
Clipping 22
Clipping 22
MATLABgraphPlotting.pptx

More from Ankit Garg (11)

PPT
Introduction to computer graphics part 2
PPT
Introduction to computer graphics part 1
PPT
Window to viewport transformation
PPT
Unit 1
PPTX
Numerical unit 1
PPTX
Hidden surface removal
PPTX
Graphics software standards
PPTX
Fractal introduction and applications modified version
PPTX
Concept of basic illumination model
PPT
Applications of cg
PPT
2 d transformation
Introduction to computer graphics part 2
Introduction to computer graphics part 1
Window to viewport transformation
Unit 1
Numerical unit 1
Hidden surface removal
Graphics software standards
Fractal introduction and applications modified version
Concept of basic illumination model
Applications of cg
2 d transformation

Recently uploaded (20)

PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PPT
Mechanical Engineering MATERIALS Selection
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Construction Project Organization Group 2.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
DOCX
573137875-Attendance-Management-System-original
PDF
737-MAX_SRG.pdf student reference guides
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Geodesy 1.pptx...............................................
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Artificial Intelligence
PPTX
Current and future trends in Computer Vision.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Mechanical Engineering MATERIALS Selection
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Safety Seminar civil to be ensured for safe working.
Construction Project Organization Group 2.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
573137875-Attendance-Management-System-original
737-MAX_SRG.pdf student reference guides
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Geodesy 1.pptx...............................................
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Artificial Intelligence
Current and future trends in Computer Vision.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Categorization of Factors Affecting Classification Algorithms Selection
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems

Line clipping

  • 1. Computer Graphics Line Clipping • Cohen Sutherland Algorithm (Line)
  • 2. ( x min , y min ) ( x max , y max ) x = x min x = x max y = y min y = y max ( x 1 , y 1 ) clip rectangle maxmin maxmin yyy xxx ≤≤ ≤≤ For a pointFor a point ((x,yx,y)) to be inside the clip rectangleto be inside the clip rectangle:: Point Clipping
  • 3. clip rectangle ( x a , y a )( x b , y b ) ( x c , y c ) ( x d , y d ) ( x 0 , y 0 ) ( x 1 , y 1 ) ( x , y ) clip rectangle ( x a , y a )( x b , y b ) ( x c , y c ) ( x d , y d ) ( x 0 , y 0 ) ( x 1 , y 1 ) ( x , y ) ( ) ( ) 1 1 1 1 1 1 1 1 1 : , 0, : ( ) , 1 : , 0, : ( ) , T L B R Top x x y y m Left y m x x y m m Bottom x x y y m Right y m x x y m m = + − ≠ = − + ≠∞ = + − ≠ = − + ≠∞ Line Clipping
  • 4. 0000 1000 0100 1001 1010 0001 0010 0101 0110 clip rectangle Region outcodesRegion outcodes min max yy yy < > :1bit :0bit min max xx xx < > :3bit :2bit Cohen-Sutherland Algorithm
  • 5. The Cohen-Sutherland Line-Clipping Algorithm performs initial tests on a line to determine whether intersection calculations can be avoided. 1. First, end-point pairs are checked for trivial Acceptance. 2. If the line cannot be trivially accepted, region checks are done for Trivial Rejection. 3. If the line segment can be neither trivially accepted or rejected, it is divided into two segments at a clip edge, so that one segment can be trivially rejected. These three steps are performed iteratively until what remains can be trivially accepted or rejected. Cohen-Sutherland Algorithm
  • 6. Cohen-Sutherland Algorithm Algorithm 1-Compute the codes for the Two end points 2-Enter in loop, check if both region codes are zero(0000 and 0000) put line in display file for display and exit loop, return 3-If both region codes are not zero then take logical AND of both codes, check result for nonzero if so reject line exit loop, return 4-If result is zero then subdivide the line from intersection point of line and clipping boundary and repeat step 2,3,4. 5. Special Case when test 4 fails.
  • 11. Q1. Use Cohen Sutherland Algorithm to clip line p1(70,20) and P2 (100,10) against window lower left hand corner (50,10) and upper right hand corner (80,40). Q2. Given a clipping window A(20,20), B(60,20), C(60,40), D(20,40). Using sutherland cohen algorithm find the visible portion of line segment joining the points p(40,80),Q(120,30).