0% found this document useful (0 votes)
30 views67 pages

Clipping

Uploaded by

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

Clipping

Uploaded by

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

MODULE-3

PART 1
CGIP
C H A P T E R 6 Two-Dimensional
Viewing Donal D. Hearn and M.
Pauline
1. Baker
Windowing And Clipping: Viewing Pipeline
2. Viewing Transformations
3. 2-D Clipping Algorithms
1. Line Clipping Algorithms Cohen Sutherland Line Clipping Algorithm
2. Polygon Clipping
1. Sutherland Hodgeman Polygon Clipping
Windowing and
Clipping:
• It consider the formal mechanism
for displaying views of a picture on
an output device.
• For a two-dimensional picture, a
view is selected by specifying a
subarea of the total picture area.
Windowing and
Clipping:
• A user can select a single area for
display, or several areas could be
selected for simultaneous display.
• Transformations from world to
device coordinates involve
translation, rotation, and scaling
operations, as well as procedures for
deleting those parts of the picture
that are outside the limits of a
selected display area.(clipping)
Viewing
Pipeline
• Window
• A world-coordinate area selected
for display is called a window.
• Viewport
• An area on a display device to which a
window is mapped is called a
viewport.
• The window defines what is to be
viewed; the viewport defines where it
is to be displayed.
Viewing
Pipeline
• Viewing Transformation.
• The mapping of a part of a world-
coordinate scene to device
coordinates is referred to as a
viewing transformation.
Viewing
Pipeline
• Figure 6-1 illustrates the mapping of a picture section that
falls within a rectangular window onto a designated & angular
viewport.
Viewing
•Pipeline
It consist a sequence of steps used to perform two dimensional
viewing transformations
• The major steps are as follows
Viewing
Pipeline
1. We construct the scene in world coordinates
2. We then transform descriptions in world coordinates to viewing
coordinates.
3. We then define viewport in normalized coordinates (in the range
from 0 to 1)
4. At the final step, all parts of the picture that he outside the
viewport are clipped, and the contents of the viewport are
transformed to device coordinates.
6.3 WINDOW-TO-VIEWPORT
COORDINATE TRANSFORMATION
6.3 WINDOW-TO-VIEWPORT
COORDINATE TRANSFORMATION
• We maintain the same relative placement in the viewport as in
the window.
• If a coordinate position is at the center of the world window,
for instance, it will be displayed at the center of the viewport.
6.3 WINDOW-TO-VIEWPORT
COORDINATE TRANSFORMATION
• Apoint at position (xw,yw) in the window is mapped into
position
(xv,yv) in the associated viewport.
6.3 WINDOW-TO-VIEWPORT
COORDINATE TRANSFORMATION
• We maintain the same relative placement in the viewport as in the
window.
6.3 WINDOW-TO-VIEWPORT
COORDINATE TRANSFORMATION
2-D Clipping
Algorithms
2-D Clipping
Algorithms
• Clipping - Any procedure that identifies those portions of a picture
that are either inside or outside of a specified region of space is
referred to as a clipping algorithm, or simply clipping.
• The region against which an object is to clipped called a clip
is window.
Applications Of
Clipplng
Applications of clipping include
1. Drawing and painting operations that allow parts of a picture to be
selected for copying, moving, erasing, or duplicating.
2. Extracting part of a defined scene for viewing;
3. Identifying visible surfaces in three-dimensional vlews;
4. Antialiasing line segments or object boundaries;
5. Creating objects using solid-modeling procedures;
6. Displaying a multi window environment;
Types of
clipping
• We consider algorithms for clipping the following primitive types
1. Point Clipping
2. Line Clipping (straight-line segments)
3. Area Clipping (polygons)
4. Curve Clipping
5. Text Clipping
Point
Clipping
• we save a point P = (x, y) if
it is inside the clipping
window.
Point
Clipping
• Assuming that the clip window is a rectangle in standard position, we
save a point P = (x, y) for display if the following inequalities are
satisfied:

• where the edges of the clip window can


be either the world-coordinate window boundaries or viewport
boundaries. If any one of these four inequalities is not satisfied, the
point is clipped (not saved for display).
Line Clipping
Algorithms
Line Clipping
Algorithms
• A line clipping procedure involves several
parts.
1. First, we can test a given line segment to
determine whether it lies completely
inside the clipping window.
2. If it does not, we try to determine
whether it lies completely outside the
window.
3. Finally, we must perform intersection
calculations with one or more clipping
boundaries.
There are three possible cases
1. Completely inside the given rectangle:
• Bitwise OR of region of two end points of line is 0 (Both points
are inside the rectangle)

2. Completely outside the given rectangle:


• Both endpoints share at least one outside region which implies
that the line does not cross the visible region. (bitwise AND of
endpoints! = 0).
3. Partially inside the window:
• Both endpoints are in different regions.
• In this case, the algorithm finds one of the two points that is outside the
rectangular region.
• The intersection of the line from outside point and rectangular window
becomes new corner point and the algorithm repeats.
Curve
Clipping
• Areas with curved boundaries can be
clipped with methods similar to
discussedthose
in the previous sections.
• Curve-clipping procedures will
nonlinear equations, however, and this
involve
requires more processing than for objects
with linear boundaries.
Curve Clipping : Complete accept or
reject
• If the bounding rectangle for the object is
completely inside the window, we save the
object.
• If the rectangle is determined to be
completely outside the window, we discard
the object.
• But if the bounding rectangle test fails, we
can look for other computation-saving
approaches.
Curve Clipping : Complete accept or
reject
• For a circle,
• we can use the coordinate extents of
individual quadrants and then octants for
preliminary testing (outside or inside) and
then calculate curve-window intersections.
Text
Clipping
Text
Clipping
• Various techniques are used to provide text clipping in a
computer graphics.
• Itdepends on the methods used to generate characters and
the requirements of a particular application.
• There are three methods for text clipping which are listed below −
1. All or none string clipping
2. All or none character clipping
3. Text clipping
All or none string
clipping
• In all or none string clipping method, either we keep the entire string
or we reject entire string based on the clipping window.
All or none character
clipping
In this method if the string is partially outside the window, then −
1. You reject only the portion of the string being outside
2. If the character is on the boundary of the clipping window, then
we discard that entire character and keep the rest string.
Text
clipping
• If it is partially outside the window, then
1. You reject only the portion of string being outside.
2. If the character is on the boundary of the clipping window, then we
discard only that portion of character that is outside of the clipping
window.
C H A P T E R 6 Two-Dimensional
Viewing Donal D. Hearn and M.
Pauline
1. Baker
Windowing And Clipping: Viewing Pipeline
2. Viewing Transformations
3. 2-D Clipping Algorithms
1. Line Clipping Algorithms Cohen Sutherland Line Clipping Algorithm
2. Liang Barsky Algorithm
3. Line Clipping Against Non Rectangular Clip Windows
4. Polygon Clipping
1. Sutherland Hodgeman Polygon Clipping
2. Weiler And Atherton Polygon Clipping
5. Curve Clipping
6. Text Clipping
Polygon
Clipping
• For polygon clipping, we require an
algorithm that wiIl generate one or
more closed areas that are then scan
converted for the appropriate area fill.
• What we reaIly want to display is a
bounded area after clipping.
Sutherland Hodgeman Polygon
Clipping
• Beginning with the initial set of polygon vertices, we could first clip
the polygon against the left rectangle boundary to produce a new
sequence of vertices.
• The new set of vertices could then k successively passed to a right
boundary clipper, a bottom boundary clipper, and a top boundary
clipper.
Four Cases Out-In, In-In, In-out, Out-
out
Sutherland Hodgeman Polygon
Clipping
As each pair of adjacent polygon vertices is passed to a window boundary clipper,
we make the following tests:
(1)Out-In - If the first vertex is outside the window boundary and the second
vertex is inside, both the intersection point of the polygon edge with the window
boundary and the second vertex are added to the output vertex list.
(2)In-In If both input vertices are inside the window boundary, only the second
vertex is added to the output vertex list.
(3)In-Out- If the first vertex is inside the window boundary and second vertex is
outside the boundary, only the edge intersection with the window boundary is
added to the output vertex list.
(4)Out-Out- If both input vertices are outside the window boundary, nothing is
added to the output list.
Exampl
e
Weiler And Atherton Polygon
Clipping
References
• https://www.youtube.com/watch?v=RGSnlK4-BhI
• https://www.cs.helsinki.fi/group/goa/viewing/leikkaus/lineClip.html
For Liang Barsky Algorithm
• https://www.youtube.com/watch?v=N5Sxq3kuc_0 Weiler And
Atherton Polygon Clipping
• https://www.youtube.com/watch?v=LCMyWFxeuro&list=PLsyTslBOa4
NwekHdOyE1Dg8eV4lJsyyd7

You might also like