What is Clipping in Computer Graphics

Clipping is the process of drawing pixels only to a selected region or well-defined window. In this, pixels that lie outside the window or clip region get removed by using various clipping algorithms. It is mainly used for artistic purposes.

Technically, it can be viewed as a method or procedure that determines whether a pixel is outside or inside of a specified region. The method is termed as clipping or clipping algorithm.


There are various applications ranging from surface visibility identification in three-dimensional view, drawing operation, to object creation using solid modeling method.

Based on application, clipping window boundaries is identified i.e. polygon.

A portion of two-dimensional scene that is chosen for display is termed as clipping window.

A region to which an object inside the clipping window is mapped is called viewport.

Read : What is window and viewport?

A line or an object can be partially or completely inside in a window.

If the given line or object is partially inside the clip region, then the portion which is outside the window would be removed.

Point Clipping:

In point clipping, a point (x,y) is checked whether it falls within the window or not.

Clipping windowPoint clipping in C graphics

Considering a rectangular window, as mentioned similar to above diagram,  suppose we have a point , P = (x,y) if it doesn’t meet below condition, then it would not be visible for display.
  • A point that lies inside the clipping window is considered as visible and no clipping is required for such case
  •  If it lies outside the window, then it would be considered as  invisible
Further, point clipping is not often used when it’s compared to polygon clipping or line clipping.

 Line Clipping:

A line clipping comes into play, where the extra portion of a given line that lies outside the window is cut off from the clip region. There is a popular line clipping algorithm named Cohen Sutherland algorithm.

Clipping window

Line Clipping in C graphics

  • If a line intersects the clipping window, then the line is required to be clipped as it is considered as partially visible
  • If a line falls inside the clipping window, then it is considered as visible
  • Otherwise, invisible
In line clipping, a line segment is first validated whether it is entirely inside or outside clipping window. It is also possible to have a line lies partially inside. In such case, it requires to be clipped out the portion of line segment that falls outside the clipping window.
 

 Polygon clipping:

A polygon is two dimensional shape that is made up of more than two straight lines. For example. triangle, quadrilateral.
 
 

Ploygon clipping also follows the same concept, it cuts out vertices of the polygon that is outside the windows. Sutherland–Hodgman algorithm and Weiler-Atherton polygon clipping algorithm techniques are used for clipping a polygon.

Clipping a polygon is a complex procedure, unlike line clipping where only two points need to map one another. In polygon clipping, a method may generate a sequence of vertices as output that can be represented as clipping boundaries.

Clipping window

Polygon Clipping

  • If a part of polygon intersects the clipping window, then a particular portion that lies outside the window is needed to be removed

Text Clipping:

It can be defined as a process where a string (a sequence of character) that falls outside the window is removed. 

There are various text clipping methods and its usage depends on character generation mechanisms. all-or-none clipping is the simplest method for clipping text corresponding to a window.

Clipping window

Text clipping

 
  • If string falls outside the clip window, then don’t consider it
  • If string falls partially inside the window, then discard it completely
  • Otherwise. consider it
 
Exterior Clipping
 
Normally, the clipping is performed to save the portion of the picture that lies within a clipping window. Oppose to this, exterior clipping is a type of clipping used to cut off pixels that fall inside the window and save the pixel that come outside the window. One of its application is Multiple Windows in Display Screen.
 
Interior Clipping
 
As name suggest, it is a clipping type that is used for removing pixels that falls outside the window and save the pixel that is inside the window.

Leave a Reply