Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- Clipping Algorithm In Computer Grap... by student(MCA) 31508 views
- Clipping in Computer Graphics by Laxman Puri 4367 views
- Lecture 2d point,curve,text,line ... by avelraj 23132 views
- Polygon clipping by Mohd Arif 9221 views
- Clipping by Mohd Arif 3707 views
- Curve clipping by Mohamed El-Serngawy 12553 views

No Downloads

Total views

30,747

On SlideShare

0

From Embeds

0

Number of Embeds

4

Shares

0

Downloads

1,560

Comments

0

Likes

29

No embeds

No notes for slide

- 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. <ul><li>* 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. </li></ul>
- 5. Types of Clipping <ul><li>Point Clipping </li></ul><ul><li>Line Clipping </li></ul><ul><li>Polygon Clipping </li></ul><ul><li>Curve Clipping </li></ul><ul><li>Text Clipping </li></ul>
- 6. Point Clipping <ul><li>We have a point P=(x, y) for display if the following inequalities are satisfied </li></ul><ul><li>Xwmin <= X <= Xwmax </li></ul><ul><li> Ywmin <= Y <= Ywmax </li></ul><ul><li>where the Xwmin, Ywmin, Xwmax, Ywmax are the edge of the Clip Window. </li></ul>
- 7. Line Clipping <ul><li>* A line clipping procedure involves several parts. </li></ul><ul><li>* In many cases the large majority of points or lines are either interior or exterior to the clipping window. </li></ul><ul><li>* 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. </li></ul>
- 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:- <ul><li># completely to the right of the window. # completely to the left of the window. # completely above the window. # completely bottom the window. </li></ul><ul><li>Then the line is completely exterior to the window & hence invisible </li></ul>
- 11. Cohen & Sutherland Algorithm <ul><li>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. </li></ul><ul><li>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. </li></ul>
- 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 <ul><li>For First bit:- X<XL </li></ul><ul><li>Second bit:- X>XR </li></ul><ul><li>Third bit:- Y<YB </li></ul><ul><li>Fourth bit:- Y>YT </li></ul>B L R T XL XR YT YB Window 0101 0100 0110 0001 0000 0010 1001 1000 1010
- 14. Cohen & Sutherland Algorithm <ul><li>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. </li></ul><ul><li>When the logical intersection is not zero, the line is in fact totally invisible. </li></ul><ul><li>When the logical intersection is zero, the line may be totally or partially visible or in fact totally invisible. </li></ul><ul><li>For this reason, it is necessary to check both end points codes separately to determine total visibility. </li></ul>
- 15. Cohen & Sutherland Algorithm <ul><li>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. </li></ul><ul><li>Such lines may or may not cross into the window interior. </li></ul><ul><li>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. </li></ul>
- 16. Cohen & Sutherland Algorithm <ul><li>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. </li></ul><ul><li>We set up our algorithm to check line end point against clipping boundaries in the order left, right, bottom, & top. </li></ul>
- 17. Cohen & Sutherland Algorithm <ul><li>The equation of the infinite line through P1(X1, Y1) & P2(X2, Y2) is </li></ul><ul><li>Y=m(X-X1)+Y1 </li></ul><ul><li>Or </li></ul><ul><li>Y=m(X-X2)+Y2 </li></ul><ul><li>m= Y2-Y1/X2-X1 </li></ul>P4 P4’ P3’ P3 P1 P1’ P2” P2” P2
- 18. Cohen & Sutherland Algorithm <ul><li>The intersection with the window edges are given by </li></ul><ul><li>Left XL Y=m(XL-X1)+Y1 </li></ul><ul><li>Right XR Y=m(XR-X1)+Y1 </li></ul><ul><li>Top YT X=X1+1/m(YT-Y1) </li></ul><ul><li>Bottom YB X=X1+1/m(YB-Y1) </li></ul>
- 19. Cohen & Sutherland Algorithm <ul><li>To develop an efficient clipping algorithm some special cases must be considered </li></ul><ul><li>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. </li></ul><ul><li>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. </li></ul>
- 20. Mid Point Subdivision Algorithm <ul><li>The Cohen-Sutherland algorithm requires the calculation of the intersection of the line with window edge. </li></ul><ul><li>This direct calculation can be avoided by performing a binary search for the intersection by always dividing the line at its mid point. </li></ul><ul><li>This algorithm is implemented in hardware. </li></ul>
- 21. Mid Point Subdivision Algorithm <ul><li>Implementation in hardware is fast & efficient because a parallel architecture can be used and hardware addition & division by 2 are very fast. </li></ul><ul><li>In hardware, division by 2 can be accomplished by shifting each bit to the right. </li></ul><ul><li>The algorithm uses the line end point codes & associated test to immediately identify totally visible lines, & trivially invisible lines. </li></ul>
- 22. Mid Point Subdivision Algorithm <ul><li>Lines which can not be immediately identified using there test are subdivided into 2 equal parts. </li></ul><ul><li>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. </li></ul><ul><li>The visibility of the point is then determined. </li></ul><ul><li>The result is to perform a logarithmic search for the intersection point. </li></ul>
- 23. Mid Point Subdivision Algorithm P1 P2 Pm1 Pm2 Pm2 P1 P2 Pm1 Pm2

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment