Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

CGPage: 1 We can define a window as a rectangular region of the world coordinate space, and the viewport as a rectangular region of the device coordinate.
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 30, D Clipping 1/14 Clipping (pages , )
Computer Graphics CLIPPING.
Objectives Define Clipping Various clipping methods. Line clipping methods.
Line clipping: Line clipping algorithm is method of eliminate lines of outside area of the object,so outside of object viewing is Removed. Typically, any.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)
Course Website: Computer Graphics 4: Viewing In 2D.
Computer Graphics : Clipping
Computer Graphics Viewing.
Clipping CSE 403 Computer Graphics Cohen Sutherland Algorithm (Line)
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
2D Viewing and Projection
2 D viewing Prepared by Elizabeth Isaac DCS, RSET.
CHAPTER 7 2D VIEWING CGMB214: Introduction to Computer Graphics.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
Computer Graphics Clipping Cohen Sutherland Algorithm (Line) Cyrus-Back Algorithm (Line) Sutherland-Hodgeman Algorithm (Polygon) Cohen Sutherland Algorithm.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
University College Dublin1 Clipping u Clipping is the removal of all objects or part of objects in a modelled scene that are outside the real-world window.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
1 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
2-Dimension Viewing and Clipping
Windowing and clipping
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Two-Dimensional Viewing
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
Unit – IV 2D Viewing. 2 of 30 Contents Windowing Concepts The viewing pipeline viewing coordinate reference frame, window to view-port coordinate transformation,
EEL Introduction to Computer Graphics
1 Computer Graphics Clipping Fall FCC Line Clipping What happens when one or both endpoints of a line segment are not inside the specified drawing.
Computer Graphics Lecture 20 Fasih ur Rehman. Last Class Clipping – What is clipping – Why we do clipping – How clipping is done.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 3 1.
Clipping Primitives. Clipping line Clipping rectangle: – x min to x max – y min to y max A point (x,y) lies within a clip rectangle and thus displayed.
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
A.Aruna/Assistant Professor/SNSCE
Clipping. Before clipping… After clipping… Point Clipping Display P = (x, y) if xw min
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
Introduction to Computer Graphics with WebGL
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
Computer Graphics Shading in OpenGL
Concepts, Algorithms for line clipping
2D Viewing & Clipping 한신대 류승택
Concepts, algorithms for clipping
Implementation I Ed Angel
Graphics Pipeline Clipping
WINDOWING AND CLIPPING
Computer Graphics : Viewing In 2D
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
Two Dimensional Viewing and Clipping.
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
Clipping Clipping Sutherland-Hodgman Clipping
Implementation I Ed Angel Professor Emeritus of Computer Science
COMPUTER GRAPHICS Clipping
Presentation transcript:

Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1

2 CLIPPING OPERATIONS  Procedures that identifies those portions of a picture that are either inside or outside a specified region of a space is referred to as clipping algorithm or clipping  The region against which an object is to clipped is called clip window. before after

3 Clipping Operation Note: different graphic elements may require different clipping techniques. Character, need to include all or completely omit depending on whether or not its center lies within the window.

4 Clipping Application of clipping include: Extracting part of defined scene for viewing. Identifying visible surfaces in three-dimensional views. Anti-aliasing line segments or object boundaries. Creating objects using solid-modeling procedures. Displaying a multiwindow environment. Drawing and painting operations that allow parts of picture to be selected for copying, moving, erasing, or duplication.

5 Clipping Clipping algorithm can be applied in both world coordinate and normalized device coordinates In world coordinate: only the contents of the window interior are mapped to device coordinates world coordinate clipping removes those primitives outside the window from further consideration. Eliminating the unnecessary processing to transform In normalized device coordinate: mapping is fully done from world to normalized device. clipping will reduce calculations by allowing concatenation of viewing and geometric transformation matrices.

6 Clipping Algorithms Algorithms have been developed for clipping for the following primitives types: 1. Point Clipping. 2. Line Clipping (straight-line segments) 3. Area Clipping (polygons) 4. Curve Clipping 5. Text Clipping.

7 Point Clipping Assuming clip window is standard rectangle position, point P-(x,y) will be save for display if its satisfied: xw min <= x <= xw max yw min <= y <= yw max where the edges of the clip window (xw min, xw max, yw min, yw max ) can be either the world coordinate window boundaries or viewport boundaries.

8 Line Clipping Cohen-Sutherland Outcode Algorithm This algorithm quickly removes lines which entirely to one side of the clipping where both endpoints above, below, right or left. The advantage of the algorithm is, it uses bit operations for testing.

9 Cohen Sutherland A B C D E G F I K L M J S T H

10 Cohen Sutherland Bit convention 1 First bity > ymax Second bity < ymin Third bitx > xmax Fourth bitx < xmin Bit convention 2 (1 through 4 from right to left) bit 1 : left bit 2 : right bit 3 : below bit 4 : above

11 Cohen Sutherland Segment endpoints are each given 4-bit binary codes. The high order bit is set to 1 if the point above window The next bit set to 1 if point is below window The third and fourth indicate right or left of window. Testing result: 0000 if both endpoints are inside window. if the line segment lies entirely on one side of the window, then both endpoints will have a 1 in the outcode bit position for that side. How?: By taking AND operation. If NONZERO then line segment may be rejected. Ex: AB and CD

12 Cohen Sutherland (Problem?) Certain lines cannot be identified as completely inside or outside a clip window by doing AND test. Lines which completely outside the clip window can also produce AND So, process of discarding is required and intersection with boundary must be calculated (divide and conquer). Difficulty is when a line crossed one or more of the lines which contain the clipping boundary. Ex: EF and DJ

13 Cohen Sutherland (Solution) The point of intersection between the line segment and clipping lines may be used to break up the line segment. Intersection points with a clipping boundary can be calculated using the slope-intercept form of the line equation.

14 Cohen Sutherland (Solution) For a line with endpoint (x 1,y 1 ) to (x 2,y 2 ) Y coordinate of the intersection point with vertical boundary is obtained with y = y 1 + m(x-x 1 ) where x value is set either xw min or xw max and the slope of the line is m = ( y 2 – y 1 ) / ( x 2 – x 1 ) X coordinate of the intersection point with horizontal boundary is calculated by x = x 1 + (y-y 1 )/m where y is set either to yw min or to yw max

15 Cohen Sutherland (Pseudocode) Brief outline of the algorithm. First compute the outcodes for the two endpoints (p1 and p2). Enter the loop, check whether both outcodes are zero Both zero, then enter segment in display list. If not both zero, perform the AND function. If nonzero, reject the line. If zero, subdivide the line segment. Repeat the loop.

16 Liang Barsky Line Clipping Parametric equation of a line segment (x 1,y 1 ) and (x 2,y 2 ) x = x 1 + u∆x y = y 1 + u∆y Where 0 <= u <=1 ∆x = x 2 – x 1 ∆y = y 2 –y 1 From point clipping, we have xw min < = x <= xw max Yw min <= y <= yw max For line clipping, we derived xw min < = x1 + u∆x <= xw max yw min <= y1 + u∆y <= yw max

17 Liang-Barsky Line Clipping Based on these four equations, the following rules are introduced up k <= q k where k = 1 (left boundary) 2 (right boundary) 3 (bottom boundary) 4 (top boundary) parameters p and q are defined as: p 1 = -∆x,q 1 = x 1 - xw min p 2 = ∆x,q 2 = xw max – x 1 p 3 = - ∆y,q 3 = y 1 - yw min p 4 =∆y,q 4 = yw max – y 1

18 Liang-Barsky Line Clipping If any line that is parallel to one of the clipping boundaries, p k = 0. If q k < 0 then line is completely outside the boundary. When p k < 0, the infinite extension of the line proceeds from the outside to the inside. If p k > 0, the line proceeds from the inside to the outside. For nonzero value of p k, we can calculate the value of u corresponds to the point where infinitely extended line intersects the extension boundary k as u = q k / p k u 1 (outside to inside) where its value ranges from 0 to r u 2 (inside to outside) where its value ranges from 1 to r. If u 1 > u 2, the line is completely outside the clip window and can be rejected

19 L.B vs C.S Liang-Barsky algorithm is more efficient than Cohen since intersection calculations are reduced. Liang-Barsky require only one division and window intersections of the line are computed only once. Cohen required repeated calculation even though the line may be completely outside the clip window.