0% found this document useful (0 votes)
206 views18 pages

Computer Graphics: Module 1: Clipping Salim A. Diwani

Here are the region codes and clipping results: P1 - 0011 P2 - 0010 Line P1P2 is partially inside so calculate intersection with x=20 and x=90. The clipped line is (20,30) to (80,90). Q1 - 0001 Q2 - 0100 Line Q1Q2 is partially inside so calculate intersection with y=70. The clipped line is (10,10) to (70,60).

Uploaded by

Catherine Swila
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
206 views18 pages

Computer Graphics: Module 1: Clipping Salim A. Diwani

Here are the region codes and clipping results: P1 - 0011 P2 - 0010 Line P1P2 is partially inside so calculate intersection with x=20 and x=90. The clipped line is (20,30) to (80,90). Q1 - 0001 Q2 - 0100 Line Q1Q2 is partially inside so calculate intersection with y=70. The clipped line is (10,10) to (70,60).

Uploaded by

Catherine Swila
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

Computer Graphics

Module 1: Clipping

Salim A. Diwani
Clipping
Window: World coordinate area selected for
display. [Where is to be viewed]

Viewport: An area on a display device to which a


window is mapped [where is to be displayed?]
Clipping
Clipping
Clipping
Identifying the portion of a picture that is inside
the viewport and removing the portion that is
outside the viewport.
Types of Clipping
i. Point clipping
ii. Line clipping
iii. Area clipping (Polygon)
iv. Curve clipping
v. Text clipping
Point Clipping
Assume a point P( x, y) does not satisfy the
following conditions will be clipped away
Line Clipping
Line Clipping
•Line P3P4, P9P10 completely outside rejected
•Line P1P2 completely inside Accepted
•Line P5P6,P7P8 partially inside and partially
outside
Cohen-Sutherland Line Clipping Algorithm
•Every line End points is assigned a four digit Binary
Region code/Out code/Area code
b1 = 1 if the point is in the Left side of the window
b2 = 1 if the point is in the Right side of the window
b3 = 1 if the point is in the Bottom side of the window
b4 = 1 if the point is in the Top side of the window
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
Step 1: Get the two end Points of a line (x1, y1) and (x2, y2)
Step 2: Identify the Region Code for both the End points.
1)If Both the End point’s Region Code is 0000 then Line is
completely inside the Window. Line Accepted
2)Else If Both the End point have 1 in the same bit position in
the Region Code then line is completely outside the window
Or
Perform AND operation for both the region codes if
the result is not 0000 then also line is completely outside. So
Line Rejected
3) Else move to step 3
Step 3: If line crosses xwmin/xwmax then find
y = y1 + m(x – x1)
Cohen-Sutherland Line Clipping Algorithm
Here x = xwmin/xwmax
Else (line crosses ywmin/ywmax)

Here y=ywmin/ywmax

Step 4: If the calculated (x, y) does not satisfy the following


condition then repeat step 3
Cohen-Sutherland Line Clipping Algorithm
Consider the window size from 5 to 9. clip the following line:
i. (4, 12) (8,8)
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
Quiz
Let ABVD be a rectangle window with
A(20,20), B)90,90), C (90,70), D(20,70).
Find the region codes for the end points
and use Cohen Sutherland line Clipping
algorithm to clip the following lines
P1P2 with P1(10,30) and P2 (80,90) and
Q1Q2 with Q1(10,10) and Q2(70,60).

You might also like