/
Computer Graphics Computer Graphics

Computer Graphics - PowerPoint Presentation

alexa-scheidler
alexa-scheidler . @alexa-scheidler
Follow
420 views
Uploaded On 2015-11-08

Computer Graphics - PPT Presentation

CLIPPING To be discussed Clipping Types of Clipping Point Clipping Line Clipping Line Clipping Algorithm Cohen Sutherland line clipping algo Clipping Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portio ID: 187152

clipping line point bit line clipping bit point sutherland cohen algorithm algorithm

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Computer Graphics" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Computer Graphics

CLIPPINGSlide2

To be discussed…

Clipping

Types of Clipping

- Point Clipping

- Line Clipping

Line Clipping Algorithm

Cohen Sutherland line clipping

algo

Slide3

Clipping:

Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible portion.

Generally we have clipping algorithms for the following primitive types.

Point clipping

Line clipping

Area clipping (Polygon)Curve clippingText clipping

BACKSlide4

Point clipping algorithm or Simple visibility algorithm:

If

xleft

,

xright

, ybottom, and ytop denote the boundaries of a rectangle clipping window into a point (x, y) lies inside the window including the boundary if

xleft

≤ x ≤ xright ybottom ≤ y ≤ ytop.Slide5

Line clipping:

The below figure shows a number of different attitudes that a straight line segment may take with respect to the screen.

The visible segment of a straight line can be determined simply by computing its two endpoints.

BACKSlide6

Line clipping Algorithm:

1. If a, b are the end points of the line, check if the line is totally visible by checking whether the endpoints are totally inside the boundary.

2. If both end points left, right are above and below the window then the line is trivially invisible and hence reject

.Slide7

Line clipping Algorithm:

If one point is inside and one point is outside

then a portion of a line is invisible and a portion of a line is visible. This can be achieved by finding intersection of the line with corresponding boundaries such that the line segment outside the window is discarded, and the line segment inside the boundary is displayed

.Slide8

Line clipping Algorithm:

If the two points are outside such that the line is diagonally passing the window then the intersection with the two boundaries are calculated and the position of the line from one boundary to other is displayed and the remaining two portions of the line are discarded.

BACKSlide9

Cohen-Sutherland line clipping algorithm:

This is one of the most popular line clipping algorithms.

This was introduced by Dan Cohen and Ivan Sutherland.

It was designed not only to find the endpoints very rapidly but also to reject even more rapidly any line that is clearly invisible.

This makes it a very good algorithm.

For clipping pictures that are much larger than the screen. Slide10

Cohen-Sutherland line clipping algorithm…

Assign a four bit code to all regions as shown in the figure. Every line end point in a picture is assigned a 4-bit binary code known as region code, that identifies the location of the point relative to the boundaries of the clipping rectangle.

Each bit position in the region code is used to indicate one of the 4 rectangle coordinates positions of the point with respected to clipping window to the left, right, below and top. Slide11

Cohen-Sutherland line clipping algorithm…

Bit 1 – left

Bit 2 – right

Bit 3 – below

Bit 4 – top

A value of 1 in any bit position indicates that the point is in the relative position otherwise the bit position is set to zero. If a point is within the clipping the region code is 0000.Slide12

Cohen-Sutherland line clipping algorithm…

If the code of both the endpoints are 0000 then the line is totally visible and hence draw the line.

Bit values in the region codes are determined by comparing endpoint co-ordinate values (x, y) to the clip boundaries. Slide13

Cohen-Sutherland line clipping algorithm…

Bit 1 is set to 1 if x < wmin . The other three bit values can be determined using similar comparison or calculating differences between endpoint co-ordinates and clipping boundaries.

Use the resultant sign of each differences calculation to set the corresponding value in the region code.Slide14

Cohen-Sutherland line clipping algorithm…

Bit 1 is the sign bit of x-xw

min

Bit 2 is the sign bit of xw

max

-xBit 3 is the sign bit of y-ywminBit 4 is the sign bit of yw

max

-y

If any line have 1 in the same bit position in the region codes for each endpoint are completely outside the clipping rectangle, so we discard the line Slide15

Cohen-Sutherland line clipping algorithm…

For a line with end points co-ordinates (x1, y1) and (x2, y2) then the y coordinate of the intersection point with a vertical boundary can be obtained with the calculation

y=y1 + m(x-x1)

(1), where the x value is set either to xleft or xright. Slide16

Cohen-Sutherland line clipping algorithm…

Similarly if we are looking for the intersection with a horizontal boundary, the x co-ordinate can be calculated as

x = x1 + 1/m (y-y1)

(2)

where y set either ybottom or ytop. Slide17

Cohen-Sutherland line clipping algorithm…

So the points are given by

left: (xleft, y=m(xleft-x1) + y1)

right:(xright, y=m(xright-x1) +y1)

top: (x=1/m (ytop-y1) + x1,ytop)

bottom: (x=1/m (ybottom-y1) + x1,ybottom)where (x1, y1) and (x2, y2) are the points and xleft, xright, ytop and ybottom are the boundaries of the window and m is the slope which is given by

m = y2-y1 / x2-x1

(3).BACKSlide18

Thankyou

BACK