Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Unit-2 B.Tech.

- V Semester Computer Graphics and Multimedia

Lecture 5
Points, lines, circles and ellipses as primitives, conversion
algorithms for primitives

Introduction
A picture is completely specified by the set of intensities for the pixel positions in the
display. Shapes and colors of the objects can be described internally with pixel arrays
into the frame buffer or with the set of the basic geometric structure such as straight
line segments and polygon color areas. To describe structure of basic object is referred
to as output primitives. Each output primitive is specified with input co-ordinate data
and other information about the way that objects is to be displayed. Additional output
primitives that can be used to constant a picture include circles and other conic sections,
quadric surfaces, Spline curves and surfaces, polygon floor areas and character string.
Points and Lines Point plotting
is accomplished by converting a single coordinate position furnished byan application
program into appropriate operations for the output device. With a CRTmonitor, for
example, the electron beam is turned on to illuminate the screen phosphor atthe
selected location
Line drawing
is accomplished by calculating intermediate positions along the line
path between two specified end points positions. An output device is then directed to fill
inthese positions between the end points Digital devices display a straight line segment
by plotting discrete points between the two end points. Discrete coordinate positions
along the line path are calculated from the equation of the line. For a raster video
display, the line color (intensity) is then loaded into the frame buffer at the
corresponding pixel coordinates. Reading from the frame buffer, the video controller
then plots “the screen pixels”. Pixel positions are referenced according to scan-line
number and column number (pixel position across a scan line). Scan lines are numbered
consecutively from 0, starting

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 11
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

at the bottom of the screen; and pixel columns are numbered from 0, left to right across
each scan line 2. Pixel Positions reference by scan line number and column number to
load an intensity value into the frame buffer at a position corresponding to column
xalong scan line y,setpixel (x, y) To retrieve the current frame buffer intensity setting for
a specified location we use a low level function getpixel (x, y)
Line Drawing Algorithms
Digital Differential Analyzer (DDA) Algorithm
Bresenham’s Line Algorithm
Parallel Line AlgorithmThe Cartesian

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 12
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Lecture 6
Digital Differential Analyzer Algorithm

Digital Differential Analyzer (DDA) algorithm is the simple line generation algorithm
which is explained step by step here.
Step 1 − Get the input of two end points (X0,Y0)(X0,Y0) and (X1,Y1)(X1,Y1).
Step 2 − Calculate the difference between two end points.

dx = X1 - X0
dy = Y1 - Y0

Step 3 − Based on the calculated difference in step-2, you need to identify the number
of steps to put pixel. If dx > dy, then you need more steps in x coordinate; otherwise in
y coordinate.

if (absolute(dx) > absolute(dy))


Steps = absolute(dx);
else
Steps = absolute(dy);

Step 4 − Calculate the increment in x coordinate and y coordinate.

Xincrement = dx / (float) steps;


Yincrement = dy / (float) steps;

Step 5 − Put the pixel by successfully incremen ng x and y coordinates accordingly and
complete the drawing of the line.

for(int v=0; v < Steps; v++)


{
x = x + Xincrement;
y = y + Yincrement;
putpixel(Round(x), Round(y));
}

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 13
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Lecture 7
Bresenham’s Line Drawing Algorithm
The Bresenham algorithm is another incremental scan conversion algorithm. The big
advantage of this algorithm is that, it uses only integer calculations. Moving across the x
axis in unit intervals and at each step choose between two different y coordinates.
For example, as shown in the following illustration, from position (2, 3) you need to
choose between (3, 3) and (3, 4). You would like the point that is closer to the original
line.

At sample position Xk+1,Xk+1, the vertical separations from the mathematical line are
labelled as dupperdupper and dlowerdlower.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 14
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

From the above illustration, the y coordinate on the mathematical line at xk+1xk+1 is −
Y = m(XkXk+1) + b
So, dupperdupper and dlowerdlower are given as follows −
dlower=y−ykdlower=y−yk
=m(Xk+1)+b−Yk=m(Xk+1)+b−Yk
and
dupper=(yk+1)−ydupper=(yk+1)−y
=Yk+1−m(Xk+1)−b=Yk+1−m(Xk+1)−b
You can use these to make a simple decision about which pixel is closer to the
mathematical line. This simple decision is based on the difference between the two
pixel positions.
dlower−dupper=2m(xk+1)−2yk+2b−1dlower−dupper=2m(xk+1)−2yk+2b−1
Let us substitute m with dy/dx where dx and dy are the differences between the end-
points.
dx(dlower−dupper)=dx(2dydx(xk+1)−2yk+2b−1)dx(dlower−dupper)=dx(2dydx(xk+1)−2yk
+2b−1)
=2dy.xk−2dx.yk+2dy+2dx(2b−1)=2dy.xk−2dx.yk+2dy+2dx(2b−1)
=2dy.xk−2dx.yk+C=2dy.xk−2dx.yk+C
So, a decision parameter PkPk for the kth step along a line is given by −
pk=dx(dlower−dupper)pk=dx(dlower−dupper)
=2dy.xk−2dx.yk+C=2dy.xk−2dx.yk+C
Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 15
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

The sign of the decision parameter PkPk is the same as that


of dlower−dupperdlower−dupper.
If pkpk is negative, then choose the lower pixel, otherwise choose the upper pixel.
Remember, the coordinate changes occur along the x axis in unit steps, so you can do
everything with integer calculations. At step k+1, the decision parameter is given as −
pk+1=2dy.xk+1−2dx.yk+1+Cpk+1=2dy.xk+1−2dx.yk+1+C
Subtracting pkpk from this we get −
pk+1−pk=2dy(xk+1−xk)−2dx(yk+1−yk)pk+1−pk=2dy(xk+1−xk)−2dx(yk+1−yk)
But, xk+1xk+1 is the same as (xk)+1(xk)+1. So −
pk+1=pk+2dy−2dx(yk+1−yk)pk+1=pk+2dy−2dx(yk+1−yk)
Where, Yk+1–YkYk+1–Yk is either 0 or 1 depending on the sign of PkPk.
The first decision parameter p0p0 is evaluated at (x0,y0)(x0,y0) is given as −
p0=2dy−dxp0=2dy−dx
Now, keeping in mind all the above points and calculations, here is the Bresenham
algorithm for slope m < 1 −
Step 1 − Input the two end-points of line, storing the left end-point in (x0,y0)(x0,y0).
Step 2 − Plot the point (x0,y0)(x0,y0).
Step 3 − Calculate the constants dx, dy, 2dy, and (2dy – 2dx) and get the first value for
the decision parameter as −
p0=2dy−dxp0=2dy−dx
Step 4 − At each XkXk along the line, starting at k = 0, perform the following test −
If pkpk < 0, the next point to plot is (xk+1,yk)(xk+1,yk) and
pk+1=pk+2dypk+1=pk+2dy
Otherwise,
(xk,yk+1)(xk,yk+1)
pk+1=pk+2dy−2dxpk+1=pk+2dy−2dx
Step 5 − Repeat step 4 (dx – 1) times.
For m > 1, find out whether you need to increment x while incrementing y each time.
After solving, the equation for decision parameter PkPk will be very similar, just the x
and y in the equation gets interchanged.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 16
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Lecture 8
Mid-Point Circle Drawing Algorithm

Step 1 − Input radius r and circle center (xc,yc)(xc,yc) and obtain the first point on the
circumference of the circle centered on the origin as

(x0, y0) = (0, r)

Step 2 − Calculate the ini al value of decision parameter as


P0P0 = 5/4 – r (See the following description for simplification of this equation.)

f(x, y) = x2 + y2 - r2 = 0

f(xi - 1/2 + e, yi + 1)
= (xi - 1/2 + e)2 + (yi + 1)2 - r2
= (xi- 1/2)2 + (yi + 1)2 - r2 + 2(xi - 1/2)e + e2
= f(xi - 1/2, yi + 1) + 2(xi - 1/2)e + e2 = 0

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 17
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Let di = f(xi - 1/2, yi + 1) = -2(xi - 1/2)e - e2


Thus,

If e < 0 then di > 0 so choose point S = (xi - 1, yi + 1).


di+1 = f(xi - 1 - 1/2, yi + 1 + 1) = ((xi - 1/2) - 1)2 + ((yi + 1) + 1)2 - r2
= di - 2(xi - 1) + 2(yi + 1) + 1
= di + 2(yi + 1 - xi + 1) + 1

If e >= 0 then di <= 0 so choose point T = (xi, yi + 1)


di+1 = f(xi - 1/2, yi + 1 + 1)
= di + 2yi+1 + 1

The initial value of di is


d0 = f(r - 1/2, 0 + 1) = (r - 1/2)2 + 12 - r2

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 18
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

= 5/4 - r {1-r can be used if r is an integer}

When point S = (xi - 1, yi + 1) is chosen then


di+1 = di + -2xi+1 + 2yi+1 + 1

When point T = (xi, yi + 1) is chosen then


di+1 = di + 2yi+1 + 1

Step 3 − At each XKXK position starting at K=0, perform the following test −

If PK < 0 then next point on circle (0,0) is (XK+1,YK) and


PK+1 = PK + 2XK+1 + 1
Else
PK+1 = PK + 2XK+1 + 1 – 2YK+1

Where, 2XK+1 = 2XK+2 and 2YK+1 = 2YK-2.

Step 4 − Determine the symmetry points in other seven octants.


Step 5 − Move each calculate pixel posi on (X, Y) onto the circular path centered
on (XC,YC)(XC,YC) and plot the coordinate values.

X = X + XC, Y = Y + YC

Step 6 − Repeat step-3 through 5 until X >= Y.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 19
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Lecture 9
Mid-Point Ellipse Drawing Algorithm

Mid-point Ellipse algorithm is used to draw an ellipse in computer graphics.

Midpoint ellipse algorithm plots(finds) points of an ellipse on the first quadrant by


dividing the quadrant into two regions.
Each point(x, y) is then projected into other three quadrants (-x, y), (x, -y), (-x, -y) i.e. it
uses 4-way symmetry.
Function of ellipse:
fellipse(x, y)=ry2x2+rx2y2-rx2ry2
fellipse(x, y)<0 then (x, y) is inside the ellipse.
fellipse(x, y)>0 then (x, y) is outside the ellipse.
fellipse(x, y)=0 then (x, y) is on the ellipse.
Decision parameter:
Initially, we have two decision parameters p10 in region 1 and p20 in region 2.
These parameters are defined as : p10 in region 1 is given as :
p10=ry2+1/4rx2-rx2ry
Mid-Point Ellipse Algorithm :

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 20
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

1. Take input radius along x axis and y axis and obtain center of ellipse.
2. Initially, we assume ellipse to be centered at origin and the first point as : (x, y 0)=
(0, ry).
3. Obtain the initial decision parameter for region 1 as: p1 0=ry2+1/4rx2-rx 2ry
4. For every xk position in region 1 :
If p1k<0 then the next point along the is (xk+1 , yk) and p1k+1=p1k+2ry2xk+1+ry2
Else, the next point is (xk+1, yk-1 )
And p1k+1=p1k+2ry2xk+1 – 2rx2yk+1+ry2
5. Obtain the initial value in region 2 using the last point (x 0, y0) of region 1 as:
p20=ry2(x0+1/2)2+rx2 (y0-1)2-rx2ry2
6. At each yk in region 2 starting at k =0 perform the following task.
If p2k<0 the next point is (xk, yk+1) and p2k+1=p2k-2rx2yk+1+rx2
7. Else, the next point is (xk+1, yk -1) and p2k+1=p2k+2ry2xk+1 -2rx2yk+1+rx2
8. Now obtain the symmetric points in the three quadrants and plot the coordinate
value as: x=x+xc, y=y+yc
9. Repeat the steps for region 1 until 2ry2x&gt=2rx2y

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 21
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Lecture 10
Fill area primitives including scan line polygon filling inside-outside
test, boundary and flood-fill

Polygon is an ordered list of vertices as shown in the following figure. For filling
polygons with particular colors, you need to determine the pixels falling on the border
of the polygon and those which fall inside the polygon. In this chapter, we will see how
we can fill polygons using different techniques.

Scan Line Algorithm


This algorithm works by intersecting scanline with polygon edges and fills the polygon
between pairs of intersections. The following steps depict how this algorithm works.
Step 1 − Find out the Ymin and Ymax from the given polygon.

Step 2 − ScanLine intersects with each edge of the polygon from Ymin to Ymax. Name
each intersection point of the polygon. As per the figure shown above, they are named
as p0, p1, p2, p3.
Step 3 − Sort the intersection point in the increasing order of X coordinate i.e. (p0, p1),
(p1, p2), and (p2, p3).
Step 4 − Fill all those pair of coordinates that are inside polygons and ignore the
alternate pairs.
Flood Fill Algorithm

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 22
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Sometimes we come across an object where we want to fill the area and its boundary
with different colors. We can paint such objects with a specified interior color instead
of searching for particular boundary color as in boundary filling algorithm.
Instead of relying on the boundary of the object, it relies on the fill color. In other
words, it replaces the interior color of the object with the fill color. When no more
pixels of the original interior color exist, the algorithm is completed.
Once again, this algorithm relies on the Four-connect or Eight-connect method of filling
in the pixels. But instead of looking for the boundary color, it is looking for all adjacent
pixels that are a part of the interior.

Boundary Fill Algorithm


The boundary fill algorithm works as its name. This algorithm picks a point inside an
object and starts to fill until it hits the boundary of the object. The color of the
boundary and the color that we fill should be different for this algorithm to work.
In this algorithm, we assume that color of the boundary is same for the entire object.
The boundary fill algorithm can be implemented by 4-connected pixels or 8-connected
pixels.
4-Connected Polygon
In this technique 4-connected pixels are used as shown in the figure. We are putting the
pixels above, below, to the right, and to the left side of the current pixels and this
process will continue until we find a boundary with different color.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 23
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Algorithm
Step 1 − Ini alize the value of seed point (seedx, seedy), fcolor and dcol.
Step 2 − Define the boundary values of the polygon.
Step 3 − Check if the current seed point is of default color, then repeat the steps 4 and
5 till the boundary pixels reached.

If getpixel(x, y) = dcol then repeat step 4 and 5

Step 4 − Change the default color with the fill color at the seed point.
setPixel(seedx, seedy, fcol)
Step 5 − Recursively follow the procedure with four neighborhood points.
FloodFill (seedx – 1, seedy, fcol, dcol)
FloodFill (seedx + 1, seedy, fcol, dcol)
FloodFill (seedx, seedy - 1, fcol, dcol)
FloodFill (seedx – 1, seedy + 1, fcol, dcol)
Step 6 − Exit
There is a problem with this technique. Consider the case as shown below where we
tried to fill the entire region. Here, the image is filled only partially. In such cases, 4-
connected pixels technique cannot be used.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 24
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

8-Connected Polygon
In this technique 8-connected pixels are used as shown in the figure. We are putting
pixels above, below, right and left side of the current pixels as we were doing in 4-
connected technique.
In addition to this, we are also putting pixels in diagonals so that entire area of the
current pixel is covered. This process will continue until we find a boundary with
different color.

Algorithm
Step 1 − Ini alize the value of seed point (seedx, seedy), fcolor and dcol.
Step 2 − Define the boundary values of the polygon.
Step 3 − Check if the current seed point is of default color then repeat the steps 4 and 5
till the boundary pixels reached

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 25
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

If getpixel(x,y) = dcol then repeat step 4 and 5


Step 4 − Change the default color with the fill color at the seed point.
setPixel(seedx, seedy, fcol)
Step 5 − Recursively follow the procedure with four neighbourhood points
FloodFill (seedx – 1, seedy, fcol, dcol)
FloodFill (seedx + 1, seedy, fcol, dcol)
FloodFill (seedx, seedy - 1, fcol, dcol)
FloodFill (seedx, seedy + 1, fcol, dcol)
FloodFill (seedx – 1, seedy + 1, fcol, dcol)
FloodFill (seedx + 1, seedy + 1, fcol, dcol)
FloodFill (seedx + 1, seedy - 1, fcol, dcol)
FloodFill (seedx – 1, seedy - 1, fcol, dcol)
Step 6 − Exit
The 4-connected pixel technique failed to fill the area as marked in the following figure
which won’t happen with the 8-connected technique.

Inside-outside Test
This method is also known as counting number method. While filling an object, we
often need to identify whether particular point is inside the object or outside it. There
are two methods by which we can identify whether particular point is inside an object
or outside.
 Odd-Even Rule

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 26
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

 Nonzero winding number rule


Odd-Even Rule
In this technique, we will count the edge crossing along the line from any point (x,y) to
infinity. If the number of interactions is odd, then the point (x,y) is an interior point; and
if the number of interactions is even, then the point (x,y) is an exterior point. The
following example depicts this concept.

From the above figure, we can see that from the point (x,y), the number of interactions
point on the left side is 5 and on the right side is 3. From both ends, the number of
interaction points is odd, so the point is considered within the object.
Nonzero Winding Number Rule
This method is also used with the simple polygons to test the given point is interior or
not. It can be simply understood with the help of a pin and a rubber band. Fix up the
pin on one of the edge of the polygon and tie-up the rubber band in it and then stretch
the rubber band along the edges of the polygon.
When all the edges of the polygon are covered by the rubber band, check out the pin
which has been fixed up at the point to be test. If we find at least one wind at the point
consider it within the polygon, else we can say that the point is not inside the polygon.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 27
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

In another alternative method, give directions to all the edges of the polygon. Draw a
scan line from the point to be test towards the left most of X direction.
 Give the value 1 to all the edges which are going to upward direction and all other
-1 as direction values.
 Check the edge direction values from which the scan line is passing and sum up
them.
 If the total sum of this direction value is non-zero, then this point to be tested is
an interior point, otherwise it is an exterior point.
 In the above figure, we sum up the direction values from which the scan line is
passing then the total is 1 – 1 + 1 = 1; which is non-zero. So the point is said to be
an interior point.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 28
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Lecture 11
Character generation, character attributers, line attributes, area-fill
attributes
Basic attributes of a straight line segment are its type, its width, and its color. In some
graphics packages, lines can also be displayed using selected pen or brush options.
ATTRIBUTES

LINE ATTRIBUTES

Basic attributes of a straight line segment are its type, its width, and its color. In some
graphics packages, lines can also be displayed using selected pen or brush options.

Line Type

line-type attribute - solid lines, dashed lines, and dotted lines.

We modify a line drawing algorithm to generate such lines by setting the length and
spacing of displayed solid sections along the line path.

A dashed line could be displayed by generating an interdash spacing that is equalto the
length of the solid sections. Both the length of the dashes and the interdashspacing are
often specified as user options. A dotted line can be displayed bygenerating very short
dashes with the spacing equal to or greater than the dash size. Similar methods are used
to produce other line-type variations.

To set line type attributes in a PHICS application program, a user invokes the function

setLinetype (It)

where parameter I t is assigned a positive integer value of 1,2,3, or 4 to generate lines


that are, respectively, solid, dashed, dotted, or dash-dotted.

Line Width

We set the line-width attribute with the command: Line-width parameter lr. is assigned
a positive number to indicate the relative width of the line to be displayed. A value of 1
specifies a standard-width line. On.

For lines with slope magnitude greater than 1, we can plot thick lines withhorizontal
spans, alternately picking up pixels to the right and left of the linepath.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 29
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Problem with implementing width options using horizontal or vertical pixel spans is that
the method produces lines whose ends are horizontal or vertical regardless of the slope
of the line. This effect is more noticeable with very thick lines. We can adjust the shape
of the line ends to give them a better appearance by adding line caps

One kind of line cap is the butt cap obtained by adjusting the end positions of the
component parallel lines so that the thick line is displayed with square ends that are
perpendicular to the line path. If the specified line has slope m, the square end of the
thick line has slope - l / m .

Another line cap is the round cap obtained by adding a filled semicircle to eachbutt cap.
The circular arcs are centered on the line endpoints and have a diameterequal to the
line thickness.

A third type of line cap is the projecting square cap.Here, we simply extend the line and
add butt caps that are positioned one-half ofthe line width beyond the specified
endpoints.

We can generate thick polylines that are smoothly joined at the cost of additional
processing at the segment endpoints. A miter join is accomplished by extending the
outer boundaries of each of the two linesuntil they meet. A round join is produced by
capping the connection between the two segments with a circular boundary whose
diameter is equal to the line width.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 30
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

And a bevel join is generated by displaying the line segments with butt caps and filling in
the triangular gap where the segments meet.

We can generate thick polylines that are smoothly joined at the cost of additional
processing at the segment endpoints.
A miter join is accomplished by extending the outer boundaries of each of the two
linesuntil they meet.
A round join is produced by capping the connection between the two segments with a
circular boundary whose diameter is equal to the line width. And a bevel join is
generated by displaying the line segments with butt caps and filling in the triangular gap

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 31
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

where the segments meet.

We can generate thick polylines that are smoothly joined at the cost of additional
processing at the segment endpoints.
A miter join is accomplished by extending the outer boundaries of each of the two
linesuntil they meet.
A round join is produced by capping the connection between the two segments with a
circular boundary whose diameter is equal to the linewidth. And a bevel join is
generated by displaying the line segments with butt caps and filling in the triangular gap

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 32
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

where the segments meet.

We can generate thick polylines that are smoothly joined at the cost of additional
processing at the segment endpoints.
A miter join is accomplished by extending the outer boundaries of each of the two lines
until they meet.
A round join is produced by capping the connection between the two segments with a
circular boundary whose diameter is equal to the line width.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 33
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

And a bevel join is generated by displaying the line segments with butt caps and filling in
the triangular gap where the segments meet.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 34
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Lecture 12
Aliasing and introduction to Anti-Aliasing (No anti-aliasing
algorithm)

Antialiasing is a technique used in digital imaging to reduce the visual defects that occur
when high-resolution images are presented in a lower resolution. Aliasing manifests
itself as jagged or stair-stepped lines (otherwise known as jaggies) on edges and objects
that should otherwise be smooth.
Antialiasing makes these curved or slanting lines smooth again by adding a slight
discoloration to the edges of the line or object, causing the jagged edges to blur and
melt together. If the image is zoomed out a bit, the human eye can no longer notice the
slight discoloration that antialiasing creates.
Jaggies appear when an output device does not have a high enough resolution to
represent a smooth line correctly. This is also an inherent problem on a computer
monitor. The pixels that make up the screen of the monitor are all shaped in rectangles
or squares. Because lighting up only half of one of these square pixels is not possible, the
result is a jagged line.
The jagged line effect can be minimized by increasing the resolution of the monitor,
making the pixels small enough that the human eye cannot distinguish them individually.
This is not a good solution, however, because images are displayed based on their
resolution. A single image pixel may take up many monitor pixels, making it impossible
for a higher resolution monitor to mask the jagged edges. This is where antialiasing is
required.
Antialiasing removes jagged edges by adding subtle color changes around the lines,
tricking the human eye into thinking that the lines are not jagged. The slight changes in
color around the edges of an image help the line blend around curves, giving the
impression that the line is true. These color changes are made on a very small scale that
the human eye cannot detect under normal circumstances. In order to be able to see
that an image has been antialiased, it would have to be magnified.

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 35
Unit-2 B.Tech. - V Semester Computer Graphics and Multimedia

Antialiasing is often implemented by graphics cards and computer games. Depending on


the application, different methods of antialiasing may be applied. This technique is also
used in digital photography and digital audio.
Displayed primitives generated by the raster algorithms have a jagged, or stairstep,
appearance because the sampling process digitizes coordinatepoints on an object to
discrete integer pixel positions. This distortion of information due to low-frequency
sampling (undersampling) is called aliasing.
We can improve the appearance of displayed raster lines by applying
antialiasingmethods that compensate for the undersampling process.To avoid losing
information from such periodic objects, we need to set the sampling frequency to at
least twice that of the highest frequency occurring in the object, referredto as the
Nyquist sampling frequency (or Nyquist sampling rate) fs:

Another way to state this is that the sampling interval should be no larger than one-half
the cycle interval (called the Nyquist sampling interval). For x-interval sampling, the
Nyquist sampling interval Ax, is

Notes By: - Arvind Sharma (Head, Department of Computer Science and Engineering) Page 36

You might also like