Your SlideShare is downloading. ×
Clipping
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Clipping

9,528
views

Published on


0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
9,528
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
428
Comments
0
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 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 region against which an object is to clipped is called a Clip Window.
  • 2. Clipping * Clipping algorithms are 2D-3D. * Clipping algorithm can be implemented in hardware or software. * When implemented in software, clipping algorithms are slower than required for real time applications. * For this reason both 2D & 3D clipping algorithm have been implemented in hardware or firmware. * The purpose of a clipping algorithm is to determine which points, lines or portions of lines lie with in the clipping window. * These points, lines or portions of lines are relative for display. * All other are discarded.
  • 3. * Application of clipping include extracting part of a defined scene for viewing. * Identifying visible surface in 3D views. * Antiliasing line segment or object boundaries. * Creating objects using solid-modeling procedures. * Displaying a multi window environment. * Drawing & painting operation that allow part of a picture to be selected for clipping, moving, erasing or duplicating.
  • 4.
    • * Depending on the application, the clip window can be a general polygon or it can even have curved boundaries. * For the viewing transformation, we want to display only those picture parts that are within the window area. Everything outside the window is discarded. * Clipping algorithm can be applied in World Coordinates, so that only the contents of the window interior are mapped to Device coordinates.
  • 5. Types of Clipping
    • Point Clipping
    • Line Clipping
    • Polygon Clipping
    • Curve Clipping
    • Text Clipping
  • 6. Point Clipping
    • We have a point P=(x, y) for display if the following inequalities are satisfied
    • Xwmin <= X <= Xwmax
    • Ywmin <= Y <= Ywmax
    • where the Xwmin, Ywmin, Xwmax, Ywmax are the edge of the Clip Window.
  • 7. Line Clipping
    • * A line clipping procedure involves several parts.
    • * In many cases the large majority of points or lines are either interior or exterior to the clipping window.
    • * Therefore it is important to be able to quickly accept a line which is completely interior to the window & reject a line which is exterior to the window.
  • 8. Line Clipping * Lines are interior to the clipping window & hence visible if both end points are interior to the window. * Points are interior to the clipping window provided that XL <= X <= XR YB <= Y <= YT
  • 9. I J G H E F A B C D K L Right Bottom Top Left Line Clipping
  • 10. Line Clipping * However, if both endpoints of a line are exterior to the window, the line is not necessarily completely exterior to the window. * If both end points of a lines are:-
    • # completely to the right of the window. # completely to the left of the window. # completely above the window. # completely bottom the window.
    • Then the line is completely exterior to the window & hence invisible
  • 11. Cohen & Sutherland Algorithm
    • The tests for totally visible lines and the region tests for totally invisible lines can be formalized using a technique i.e. Cohen & Sutherland Algorithm.
    • The technique uses a four digit (bit) code, known as “Region Code”, to indicate which of nine regions contains the end points of a line.
  • 12. Cohen & Sutherland Algorithm The rightmost bit is the first bit. The bits are set to 1 based on the following scheme. 1) First bit Set- If the end point is to the left of the window. 2) Second bit Set- If the end point is to the right of the window. 3) Third bit Set- If the end point is to the below the window. 4) Fourth bit Set- If the end point is to the above the window. Otherwise the bit is set to Zero. It is obvious that, if both end point codes are zero, then both ends of the line lie inside the window & the line is visible.
  • 13. Cohen & Sutherland Algorithm
    • For First bit:- X<XL
    • Second bit:- X>XR
    • Third bit:- Y<YB
    • Fourth bit:- Y>YT
    B L R T XL XR YT YB Window 0101 0100 0110 0001 0000 0010 1001 1000 1010
  • 14. Cohen & Sutherland Algorithm
    • If the bit by bit logical intersection of the two end points codes is not zero, then the line is totally invisible & may be trivially reject.
    • When the logical intersection is not zero, the line is in fact totally invisible.
    • When the logical intersection is zero, the line may be totally or partially visible or in fact totally invisible.
    • For this reason, it is necessary to check both end points codes separately to determine total visibility.
  • 15. Cohen & Sutherland Algorithm
    • Lines that can not be identified as completely inside or completely outside a clip window by there tests are checked for intersection with the window boundaries.
    • Such lines may or may not cross into the window interior.
    • We begin the clipping process for a line by comparing an outside endpoint to a clipping boundary to determine how much of line can be discarded.
  • 16. Cohen & Sutherland Algorithm
    • Then the remaining part of the line is checked against the other boundaries, and we continue until either the line is totally discarded or a section is found inside the window.
    • We set up our algorithm to check line end point against clipping boundaries in the order left, right, bottom, & top.
  • 17. Cohen & Sutherland Algorithm
    • The equation of the infinite line through P1(X1, Y1) & P2(X2, Y2) is
    • Y=m(X-X1)+Y1
    • Or
    • Y=m(X-X2)+Y2
    • m= Y2-Y1/X2-X1
    P4 P4’ P3’ P3 P1 P1’ P2” P2” P2
  • 18. Cohen & Sutherland Algorithm
    • The intersection with the window edges are given by
    • Left XL Y=m(XL-X1)+Y1
    • Right XR Y=m(XR-X1)+Y1
    • Top YT X=X1+1/m(YT-Y1)
    • Bottom YB X=X1+1/m(YB-Y1)
  • 19. Cohen & Sutherland Algorithm
    • To develop an efficient clipping algorithm some special cases must be considered
    • If the slope of line is infinite, it is parallel to the left & right, and only the top & bottom edges need to checked for intersection.
    • If the slope of the line is zero, the line is parallel to the top & bottom edges, and only the left & right edge need to checked for intersection.
  • 20. Mid Point Subdivision Algorithm
    • The Cohen-Sutherland algorithm requires the calculation of the intersection of the line with window edge.
    • This direct calculation can be avoided by performing a binary search for the intersection by always dividing the line at its mid point.
    • This algorithm is implemented in hardware.
  • 21. Mid Point Subdivision Algorithm
    • Implementation in hardware is fast & efficient because a parallel architecture can be used and hardware addition & division by 2 are very fast.
    • In hardware, division by 2 can be accomplished by shifting each bit to the right.
    • The algorithm uses the line end point codes & associated test to immediately identify totally visible lines, & trivially invisible lines.
  • 22. Mid Point Subdivision Algorithm
    • Lines which can not be immediately identified using there test are subdivided into 2 equal parts.
    • The test are then applied to each half until the intersection with the window edge is found or the length of the divided segment is infinitesimal i.e. 0 point.
    • The visibility of the point is then determined.
    • The result is to perform a logarithmic search for the intersection point.
  • 23. Mid Point Subdivision Algorithm P1 P2 Pm1 Pm2 Pm2 P1 P2 Pm1 Pm2