You are on page 1of 22

IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I

INTRODUCTION TO SCAN CONVERSION


Line drawing is accomplished by calculating all the intermediate points along a line path between two
given end points. It is called as Rasterization or scan conversion. Whole screen can be divided into
smaller units known as PIXEL which can be referred by an integer value (x, y) in 2D coordinate system.
A pixel (picture element) is a tiny dot that makes up the representation of a picture in a Computer's
memory. This element is not a dot, nor a square, but an abstract sample. We can calculate intermediate
points/pixels value between two end points which are to be intensified i.e., which lies very close to the
line path if not exactly on line path on the basis of an algorithm.

DDA (DIGITAL DIFFENRTIAL ANALYSER) ALGORITHM


DDA algorithm provides us mechanism of construction of lines on the basis of slope of the line.
Equation of line: Y=𝑚𝑥 + 𝑏
𝑑𝑦
Where, m is slope of the line calculated as: 𝑚 =
𝑑𝑥
Three types of line:-
1. perfectly horizontal
2. perfectly vertical
3. Slanting line (special case: line at 45° )

DDA algorithm provides us mechanism of construction of lines lying in either m<1 region or m>=1
region. So, slope of the line is an important factor. On the basis of it we will follow two cases:-

Case 1: When slope of line is less than one Case 2: When slope of line is greater than one
(m<1) i.e. (X1-X0 >Y1-Y0) and X1-X0 >0 (m>1) i.e. (Y1-Y0 > X1-X0) and X1-X0 >0
In this we assume that x is increased by unit one In this we assume that y is increased by unit one
every time and we calculate the value of y for every time and we calculate the value of x for
every next pixel. every next pixel.
𝑑𝑦 𝑑𝑦
𝑚 = 𝑑𝑥 𝑚 = 𝑑𝑥
𝑚 = y1-y0/x1-x0 𝑑𝑦
𝑚 = 𝑌i+1 − 𝑌i / 𝑋i+1 𝑋i 𝑑𝑥 =
𝑚
𝑚 × ∆𝑥 = 𝑌i+1 − 𝑌i ∆𝑌
𝑌i+1 = 𝑚 + 𝑌i Xi+1 − 𝑋i =
𝑚
∆Y
𝑋i+1 = 𝑚 + 𝑋i
Note: For m<1 (horizontal span is more than 1
vertical span). Change in X-direction is more than 𝑋i+1 = + 𝑋i ⟦∴ ∆𝑦 = 1⟧
𝑚
the change in Y-direction.
Note: For m>1 (vertical span is more than
horizontal span). Change in Y-direction is more
than the change in X-direction.

DDA PSEUDO-CODE

DDA(float x0, float x1, float y0, float y1)


{
float x, y;
float xinc, yinc;
Prepared By: Shilpa Taneja
IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
int numsteps;
numsteps = Round(x1) – Round(x0);
xinc = (x1 – x0) / numsteps;
yinc = (y1 – y0) / numsteps;
x = x0;
y = y0;
ColorPixel(Round(x),Round(y));

for (int i=0; i<numsteps; i++) {


x += xinc;
y += yinc;
ColorPixel(Round(x),Round(y));
}
}
Example: Suppose we want to draw a line starting at pixel (2, 3) and ending at pixel (12,8).
 numsteps = 12 – 2 = 10
 xinc = 10/10 = 1.0
 yinc = 5/10 = 0.5
t x y R(x) R(y)
0 2 3 2 3
1 3 3.5 3 4
2 4 4 4 4
3 5 4.5 5 5
4 6 5 6 5
5 7 5.5 7 6
6 8 6 8 6
7 9 6.5 9 7
8 10 7 10 7
9 11 7.5 11 8
10 12 8 12 8

DISADVANTAGE OF ALGORITHM

1. Accumulation of round-off errors can make the pixelated line drift away from what was intended.
2. The rounding operations and floating point arithmetic involved are time consuming.

MID POINT LINE DRAWING ALGORITHM

Equation of line Y=𝑚𝑥 + 𝑏 ------------1

𝑑𝑦
𝑚 = 𝑑𝑥 -----------------------------2

Putting equation 2 in 1

𝑑𝑦
Y=𝑑𝑥 𝑥 + 𝑏

Y 𝑑𝑥 =𝑑𝑦𝑥 + 𝑏 𝑑𝑥

F x, y   𝑑𝑦𝑥 -Y 𝑑𝑥 +𝑏 𝑑𝑥 =0

On simplifying above equation we get following


f(x,y)=ax+by+c
Where

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
𝑎 = 𝑑𝑦
b = −𝑑𝑥
𝑐 = 𝑏 𝑑𝑥

𝑑 = 𝑎𝑥 + 𝑏𝑦 + 𝑐

This algorithm assumes three situations:-


a) Mid point on the line :- 𝐹(𝑥, 𝑦) = 0
b) Mid point below the line: - 𝐹(𝑥, 𝑦) > 0 In this case east point will be closer to the line. So we will
select east point.
c) Mid point above the line: - 𝐹(𝑥, 𝑦) < 0 In this case north-east point will be closer to the line. So will
select north-east point.

Case 1: when east point is chosen after plotting Case 2: when north-east point is chosen after
east pixel (if the midpoint is above the line) plotting east pixel (if the midpoint is below the
line)

Midpoint Above Line Midpoint Below Line


1
𝑑old=a(xp+1) + b(yp + ) + 𝑐
2 1
1 𝑑old=a(xp+1) + b(yp + ) + 𝑐
𝑑new=a(xp+2) + b(yp + ) + 𝑐 2
2 3
𝑑old=𝑑new − 𝑑old 𝑑new=a(xp+2) + b(yp + ) + 𝑐
1 1 2
𝑑E=a(xp+2) + b(yp + ) + 𝑐 − [a(xp+1) + b(yp + ) + 𝑐] 𝑑NE=𝑑new − 𝑑old
2 2 3 1
b b 𝑑NE=a(xp+2) + b(yp + ) + 𝑐 − [a(xp+1) + b(yp + ) + 𝑐]
𝑑E=axp+2a + 𝑏𝑦p + + 𝑐 − 𝑎𝑥p-a - 𝑏𝑦p + − 𝑐 2 2
2 2 3b b
𝑑E=a 𝑑NE=axp+2a + 𝑏𝑦p + + 𝑐 − 𝑎𝑥p-a - 𝑏𝑦p + − 𝑐
𝑑E=𝑑y 2 2
3𝑏 𝑏
𝑑NE=2a-a+ −
2 2
𝑑NE=𝑎 + 𝑏
𝑑NE=𝑑y-𝑑x

Let us assume that starting coordinate are (X0, Y0)


1
So, 𝑑start=a(x0+1) + b(y0 + 2 ) + 𝑐 𝑑start =2𝑑y-𝑑x
𝑑E=2𝑑y
b
𝑑start=ax0+a + by0 + + 𝑐 𝑑NE=2(𝑑y-𝑑x)
2
b
𝑑start=a + [∴ax0 + by0 +𝑐 ]
2
2[𝑑start ]=2a + b
2[𝑑start ]=2𝑑y-𝑑x

ALGORITHM/FUNCTION
Void midline (int x0, int y0, int x1, int y1, int value)
{
Int x=x0;
Int y=y0;
Int 𝑑𝑥 = x1-x0;
Prepared By: Shilpa Taneja
IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
Int 𝑑𝑦 = y1-y0;
Int 𝑑 = 2𝑑𝑥 − 𝑑𝑦;
𝑑E=2𝑑y;
𝑑NE=2(𝑑y-𝑑x);
Putpixel(x,y,value);
While(x<=x1)
{
If (d<=0)
{
d=d+ 𝑑E;
}
Else
{
d=d+𝑑NE;
Y++;
}
X++;
Putpixel(x,y,value);
}

Example: Suppose we want to draw a line starting at pixel (20, 10) and ending at pixel (30,
18)
– Δx: 10 K Pk (xk +1, yk +1)
– Δy: 8 0 6 (21,11)
– 2Δy: 16 1 2 (22,12)
– 2Δy - 2Δx: -4 2 -2 (23,12)
– p0 = 2Δy – Δx = 6 3 14 (24,13)
4 10 (25,14)
5 6 (26,15)
6 2 (27,16)
7 -2 (28,16)
8 14 (29,17)
9 10 (30,18)

WHAT IS THE ADVANTAGE OF MIDPOINT LINE DRAWING ALGORITHM?

1. High accuracy: Comparing to Basic Incremental algorithm (especially if the slope were > 1.)
2. High speed: Comparing to Digital Differential algorithm.

BRESENHAM'S LINE DRAWING ALGORITM

• Uses only integer calculations.


• Uses distance between ideal y-coordinate and the upper and lower pixel (assuming gentle slope).

𝑠 = 𝑦 − 𝑦𝑖 //s is distance
𝑡 = (𝑦𝑖 + 1) − 𝑦 //t is distance

𝑖𝑓 (𝑠 − 𝑡) < 0 𝑠𝑒𝑙𝑒𝑐𝑡 𝑆 pixel


𝑖𝑓(𝑠 − 𝑡) > 0 𝑠𝑒𝑙𝑒𝑐𝑡 𝑇 pixel
𝑖𝑓 (𝑠 − 𝑡) = 0 𝑠𝑒𝑙𝑒𝑐𝑡 𝑎𝑛𝑦 pixel

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
(𝑠 − 𝑡) = (𝑦 − 𝑦𝑖) − [(𝑦𝑖 + 1) − 𝑦]
= 2𝑦 − 2𝑦𝑖 − 1
= 2𝑚(𝑥𝑖 + 1) + 2𝐵 − 2𝑦𝑖 − 1
𝑑𝑖 = 𝑑𝑥 (𝑠 − 𝑡)
= 𝑑𝑥(2𝑚(𝑥𝑖 + 1) + 2𝐵 − 2𝑦𝑖 − 1)
𝑑𝑖 = 2𝑑𝑦 ∗ 𝑥𝑖 − 2𝑑𝑥 ∗ 𝑦𝑖 + 𝑐 𝑤ℎ𝑒𝑟𝑒 𝑐 = 2𝑑𝑦 + 𝑑𝑥(2𝐵 − 1)
𝑑𝑖 + 1 = 2𝑑𝑦 ∗ 𝑥𝑖 + 1 − 2𝑑𝑥 ∗ 𝑦𝑖 + 1 + 𝑐

On subtracting 2 from 1
𝑑𝑖 + 1 − 𝑑𝑖 = 2𝑑𝑦(𝑥𝑖 + 1 − 𝑥𝑖) − 2𝑑𝑥(𝑦𝑖 + 1 − 𝑦𝑖) [∴ 𝑥𝑖 + 1 = 𝑥𝑖 + 1]
𝑥𝑖 + 1 − 𝑥𝑖 = 1 [∴ 𝑑𝑖 + 1 = 𝑑𝑖 + 2𝑑𝑦 − 2𝑑𝑥(𝑦𝑖 + 1 − 𝑦𝑖)]

𝒄𝒂𝒔𝒆 𝟏: 𝒇𝒐𝒓 𝒔𝒆𝒍𝒆𝒄𝒕𝒊𝒏𝒈 𝑺 𝑷𝒊𝒙𝒆𝒍 𝒄𝒂𝒔𝒆 𝟐: 𝒇𝒐𝒓 𝒔𝒆𝒍𝒆𝒄𝒕𝒊𝒏𝒈 𝑻𝑷𝒊𝒙𝒆𝒍


𝑦𝑖 + 1 − 𝑦𝑖 = 0 𝑦𝑖 + 1 − 𝑦𝑖 = 1 [∴ 𝑑𝑖 + 1 = 𝑑𝑖 + 2𝑑𝑦 − 2𝑑𝑥]
𝑥𝑖 + 1 − 𝑥𝑖 = 1 [∴ 𝑑𝑖 + 1 = 𝑑𝑖 + 2𝑑𝑦] 𝑑𝑖 + 1 − 𝑑𝑖 = 2𝑑𝑦 − 2𝑑𝑥
𝑑𝑖 + 1 − 𝑑𝑖 = 2𝑑𝑦 𝑑𝑡 = 2(𝑑𝑦 − 𝑑𝑥)
𝑑𝑠 = 2𝑑𝑦

𝐹𝑜𝑟 𝑠𝑒𝑙𝑒𝑐𝑡𝑖𝑛𝑔 𝑝𝑜𝑖𝑛𝑡 (𝑥0, 𝑦0) 𝑑1 = 𝑑𝑥(𝑠 − 𝑡)


= 𝑑𝑥[(2𝑚(𝑥0 + 1) + 2𝐵 − 2𝑦0 − 1)
= 𝑑𝑥[(2𝑚𝑥0 + 2𝑚 + 2𝐵 − 2𝑦0 − 1)
= 𝑑𝑥[(2(𝑚𝑥0 + 𝐵 − 𝑦0) − (2𝑚 − 1)]
= 𝑑𝑥(2𝑚 − 1) [∴ 𝑦0 = 𝑚𝑥0 + 𝑏]
[𝑚𝑥0 + 𝑏 − 𝑦0 = 0]
𝑑1 = 2𝑑𝑦 − 𝑑𝑥

ADVANTAGE OF ALGORITHM
1. The Bresenham algorithm is fast incremental scan conversion algorithm
2. It uses only integer calculations

BRESENHAM’S LINE DRAWING Example: Suppose we want to draw a line


ALGORITHM (for |m| < 1) starting at pixel (2, 3) and ending at pixel
(12,8).
1. Input the two line end-points, storing the left end-
point in (x0, y0)
2. Plot the point (x0, y0) dx = 12 – 2 = 10 2dy = 10
3. Calculate the constants Δx, Δy, 2Δy, and (2Δy - dy = 8 – 3 = 5 2dy – 2dx = -10
2Δx) and get the first value for the decision p0 = 2dy – dx = 15
parameter as: p0  2y  x

4. At each xk along the line, starting at k = 0, perform the t p P(x) P(y)


following test. If pk < 0, the next point to plot is 0 0 2 3
(xk+1, yk) and: p k  1  p k  2  y 1 -10 3 4
2 0 4 4
3 -10 5 5
Otherwise, the next point to plot is (xk+1, yk+1) and: 4 0 6 5
p k 1  p k  2  y  2  x
5 -10 7 6
5. Repeat step 4 (Δx – 1) times
6 0 8 6
Note: For m>1, we will find whether we will 7 -10 9 7
increment x while incrementing y each time. After 8 0 10 7
solving, the equation for decision parameter pk will 9 -10 11 8
be very similar, just the x and y in the equation will 10 0 12 8
get interchanged.

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
POLYNOMIAL METHOD FOR CIRCLE
DRAWING ALGORITM Void Circlepoint (int x, int y, int h, int k, int v)
{ putpixel(h+x,k+y,12);
𝑥2 + 𝑦2 = 𝑟2 putpixel(h-x,k+y,12);
𝑦 = √𝑟 2 − 𝑥 2 putpixel(h+x,k-y,12);
putpixel(h-x,k-y,12);
Void polycircle (int r, int h, int k, int value) putpixel(h+y,k+x,12);
{ putpixel(h-y,k+x,12);
Int x=0; putpixel(h+y,k-x,12);
Int y=r; putpixel(h-y,k-x,12);
circlePlotPoints(x, y, h, k, v); }
While(x<=y)
{
X++;
𝑦 = 𝑠𝑞𝑟𝑡(𝑟 2 − 𝑥 2 );
circlePlotPoints(x, y, h, k, v);
}
TRIGONOMETRIC METHOD FOR CIRCLE }
DRAWING ALGORITM Void Circlepoint (int x, int y, int h, int k, int v)
{ putpixel(h+x,k+y,12);
Void trigonocircle (int r, int h, int k, int value) putpixel(h-x,k+y,12);
{ putpixel(h+x,k-y,12);
Int theta=90; putpixel(h-x,k-y,12);
double x,y; putpixel(h+y,k+x,12);
While(theta >45) putpixel(h-y,k+x,12);
{ putpixel(h+y,k-x,12);
X=rcos(𝑡ℎ𝑒𝑡𝑎); putpixel(h-y,k-x,12);
𝑦 = 𝑟 sin(𝑡ℎ𝑒𝑡𝑎); }
Theta= theta-1;
Circlepoint(x+h, y+k, value);

MID POINT CIRCLE DRAWING ALGORITM

𝑥2 + 𝑦2 = 𝑟2
d = 𝑥2 + 𝑦2 − 𝑟2
𝐼𝑓 𝑑 > 0, 𝑡ℎ𝑒𝑛 𝑚𝑖𝑑𝑝𝑜𝑖𝑛𝑡 𝑙𝑖𝑒𝑠 𝑜𝑢𝑡𝑠𝑖𝑑𝑒 𝑡ℎ𝑒 𝑐𝑖𝑟𝑐𝑙𝑒
𝒔𝒐, 𝒔𝒆𝒍𝒆𝒄𝒕 𝑺𝑬 Pixel
𝐼𝑓 𝑑 < 0, 𝑡ℎ𝑒𝑛 𝑚𝑖𝑑𝑝𝑜𝑖𝑛𝑡 𝑙𝑖𝑒𝑠 𝑖𝑛𝑠𝑖𝑑𝑒 𝑡ℎ𝑒 𝑐𝑖𝑟𝑐𝑙𝑒
𝒔𝒐, 𝒔𝒆𝒍𝒆𝒄𝒕 𝑬 Pixel
𝐼𝑓 𝑑𝑖 = 0, 𝑡ℎ𝑒𝑛 𝑚𝑖𝑑𝑝𝑜𝑖𝑛𝑡 𝑙𝑖𝑒𝑠 𝑜𝑛 𝑡ℎ𝑒 𝑐𝑖𝑟𝑐𝑙𝑒
𝒔𝒐, 𝒔𝒆𝒍𝒆𝒄𝒕 𝑨𝑵𝒀 Pixel

CASE 1: 𝑰𝒇 𝒅 < 𝟎 𝒂𝒏𝒅 𝒘𝒆 𝒏𝒆𝒆𝒅 𝒕𝒐 𝒔𝒆𝒍𝒆𝒄𝒕 −


𝑬𝒂𝒔𝒕 𝒑𝒊𝒙𝒆𝒍 𝒇𝒐𝒓 𝒔𝒉𝒂𝒅𝒊𝒏𝒈 𝒏𝒆𝒙𝒕 𝒕𝒘𝒐 𝒑𝒊𝒙𝒆𝒍𝒔

yk
midpoint

yk-1
1
First Midpoint is (𝑥𝑝 + 1, 𝑦𝑝 − )
2
1
Second Midpoint is (𝑥𝑝 + 2, 𝑦𝑝 − )
2

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
1 2
so, dold = (𝑥𝑝 + 1)2 + (𝑦𝑝 − ) − 𝑟 2
2
1 2
so, dnew = (𝑥𝑝 + 2)2 + (𝑦𝑝 − ) − 𝑟 2
2
1 2 1 2
dE = (𝑥𝑝 + 2) + (𝑦𝑝 − ) − 𝑟 2 − [(𝑥𝑝 + 1)2 + (𝑦𝑝 − ) − 𝑟 2 ]
2
2 2

𝐝𝐄 = 𝟐𝒙𝒑 + 𝟑

CASE 2: 𝑰𝒇 𝒅 > 𝟎 𝒂𝒏𝒅 𝒘𝒆 𝒏𝒆𝒆𝒅 𝒕𝒐 𝒔𝒆𝒍𝒆𝒄𝒕 𝐒𝐨𝐮𝐭𝐡 − 𝑬𝒂𝒔𝒕 𝒑𝒊𝒙𝒆𝒍 𝒂𝒇𝒕𝒆𝒓 𝒔𝒆𝒍𝒆𝒄𝒕𝒊𝒏𝒈 𝑬𝒂𝒔𝒕 𝒑𝒊𝒙𝒆𝒍

yk
midpoint

yk-1
1
First Midpoint is (𝑥𝑝 + 1, 𝑦𝑝 − 2)
3
Second Midpoint is (𝑥𝑝 + 2, 𝑦𝑝 − 2)
1 2
so, dold = (𝑥𝑝 + 1)2 + (𝑦𝑝 − ) − 𝑟 2
2
3 2
so, dnew = (𝑥𝑝 + 2) + (𝑦𝑝 − ) − 𝑟 2
2

2
2
3 1 2
dSE = (𝑥𝑝 + 2)2 + (𝑦𝑝 − ) − 𝑟 2 − [(𝑥𝑝 + 1)2 + (𝑦𝑝 − ) − 𝑟 2 ]
2 2

𝐝𝐒𝐄 = 𝟐𝒙𝒑 − 𝟐𝒚𝒑 + 𝟓

1
If the starting point for drawing the circle is (0,r) the coordinate for first midpoint will be (1, 𝑟 − 2)
1 2
So, dstart = (1)2 + (𝑟 − 2) − 𝑟 2
5
dstart = − r
4
𝐝𝐬𝐭𝐚𝐫𝐭 = 𝟏 − 𝐫

𝒅𝒔𝒕𝒂𝒓𝒕 = 𝟏 − 𝒓
𝐝𝐄 = 𝟐𝒙𝒑 + 𝟑
𝐝𝐒𝐄 = 𝟐𝒙𝒑 − 𝟐𝒚𝒑 + 𝟓

MID POINT CIRCLE DRAWING ALGORITM


Void midpointcircle (int r, int h, int k, int value)
{Int x=0, y=r, d=1-r;
circlePlotPoints(x, y, h, k, v);
While(x <y)
{If(d<0)
{
d=d+(2x+3);
}
Else
{
d=d + (2x-2y+5);
𝑦 − −;
}

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
𝑥 + +;
}
circlePlotPoints(x, y, h, k, v); }
Void Circlepoint (int x, int y, int h, int k, int v)
{ putpixel(h+x,k+y,12);
putpixel(h-x,k+y,12);
putpixel(h+x,k-y,12);
putpixel(h-x,k-y,12);
putpixel(h+y,k+x,12);
putpixel(h-y,k+x,12);
putpixel(h+y,k-x,12);
putpixel(h-y,k-x,12);
}

BRESENHAM'S CIRCLE DRAWING ALGORITM

POINT E is (𝑥𝑝 + 1, 𝑦𝑝)


POINT SE is (𝑥𝑝 + 1, 𝑦𝑝 − 1)

𝑫𝒊𝒔𝒕𝒂𝒏𝒄𝒆 𝒊𝒏 𝒃𝒆𝒕𝒘𝒆𝒆𝒏 𝒐𝒓𝒊𝒈𝒊𝒏 𝒂𝒏𝒅 𝐄 𝐏𝐨𝐢𝐧𝐭 =


√(𝑥𝑝 + 1 − 0)2 + (𝑦𝑝 − 0)2
Taking square on both sides
= (𝑥𝑝 + 1)2 + (𝑦𝑝)2
𝑫𝒊𝒔𝒕𝒂𝒏𝒄𝒆 𝒊𝒏 𝒃𝒆𝒕𝒘𝒆𝒆𝒏 𝒐𝒓𝒊𝒈𝒊𝒏 𝒂𝒏𝒅 𝐒𝐄 𝐏𝐨𝐢𝐧𝐭 =
√(𝑥𝑝 + 1 − 0)2 + (𝑦𝑝 − 1 − 0)2
Taking square on both sides
(𝑥𝑝 + 1)2 + (𝑦𝑝 − 1)2

𝒔𝒐, 𝑫(𝑬) = 𝐝𝐢𝐬𝐭𝐚𝐧𝐜𝐞 𝐛𝐞𝐭𝐰𝐞𝐞𝐧 𝐄 and origin


−𝐝𝐢𝐬𝐭𝐚𝐧𝐜𝐞 𝐨𝐟 𝐭𝐫𝐮𝐞 𝐯𝐚𝐥𝐮𝐞 (𝐑)𝐚𝐧𝐝 𝐨𝐫𝐢𝐠𝐢𝐧
𝑫(𝑬) = (𝒙𝒑 + 𝟏)𝟐 + (𝒚𝒑)𝟐 − 𝒓𝟐

𝒔𝒐, 𝑫(𝑺𝑬) = 𝐝𝐢𝐬𝐭𝐚𝐧𝐜𝐞 𝐛𝐞𝐭𝐰𝐞𝐞𝐧 𝐒𝐄 𝐚𝐧𝐝 𝐨𝐫𝐢𝐠𝐢𝐧


−𝐝𝐢𝐬𝐭𝐚𝐧𝐜𝐞 𝐨𝐟 𝐭𝐫𝐮𝐞 𝐯𝐚𝐥𝐮𝐞(𝐑) 𝐚𝐧𝐝 𝐨𝐫𝐢𝐠𝐢𝐧
𝑫(𝑺𝑬) = (𝒙𝒑 + 𝟏)𝟐 + (𝒚𝒑 − 𝟏)𝟐 − 𝒓𝟐

𝒅𝒊 = 𝑫(𝑺𝑬) + 𝑫(𝑬)

𝑰𝒇 𝒅𝒊 > 0, 𝒔𝒆𝒍𝒆𝒄𝒕 𝑺𝑬 Pixel


𝑰𝒇 𝒅𝒊 < 0, 𝒔𝒆𝒍𝒆𝒄𝒕 𝑬 Pixel
𝑰𝒇 𝒅𝒊 = 𝟎, 𝒔𝒆𝒍𝒆𝒄𝒕 𝑨𝑵𝒀 𝐏𝐢𝐱𝐞𝐥

𝑑𝑖 = 𝐷(𝑆𝐸) + 𝐷(𝐸)
𝑑𝑖 = (𝑥𝑝 + 1)2 + (𝑦𝑝)2 − 𝑟 2 +
(𝑥𝑝 + 1)2 + (𝑦𝑝 − 1)2 − 𝑟 2
𝑑𝑖 + 1 = (𝑥𝑝 + 2)2 + (𝑦𝑝)2 − 𝑟 2 +
(𝑥𝑝 + 2)2 + (𝑦𝑝 − 1)2 − 𝑟 2
𝐸𝐴𝑆𝑇 = 𝑑𝑖 + 1 − 𝑑𝑖
𝑬𝑨𝑺𝑻 = 𝟒𝐗𝐏 + 𝟔

𝑑𝑖 = 𝐷(𝑆𝐸) + 𝐷(𝐸)
𝑑𝑖 = (𝑥𝑝 + 1)2 + (𝑦𝑝)2 − 𝑟 2 +
(𝑥𝑝 + 1)2 + (𝑦𝑝 − 1)2 − 𝑟 2
𝑑𝑖 + 1 = (𝑥𝑝 + 2)2 + (𝑦𝑝 − 1)2 − 𝑟 2 +
(𝑥𝑝 + 2)2 + (𝑦𝑝 − 2)2 − 𝑟 2
𝑆𝑂𝑈𝑇𝐻𝐸𝐴𝑆𝑇 = 𝑑𝑖 + 1 − 𝑑𝑖
𝑺𝑶𝑼𝑻𝑯𝑬𝑨𝑺𝑻 = 𝟒(𝐗𝐏 − 𝐘𝐏) + 𝟏𝟎

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
If Starting Coordinate is (0, r)
𝑑𝑠𝑡𝑎𝑟𝑡 = [(0 + 1)2 + 𝑟 2 − 𝑟 2 ] +
[(0 + 1)2 + (𝑟 − 1)2 − 𝑟 2 ]
𝑑𝑠𝑡𝑎𝑟𝑡 = 1 + 1 + (𝑟 − 1)2 − 𝑟 2
𝑑𝑠𝑡𝑎𝑟𝑡 = 2 + 𝑟 2 + 1 − 2𝑟 − 𝑟 2
𝒅𝒔𝒕𝒂𝒓𝒕 = 𝟑 − 𝟐𝒓

Consider case 1:
E (6,5) Consider case 2:
SE (6,4) E (6,5)
R (6,3.9) SE (6,4)
R (6,4.8)

BRESENHAM CIRCLE DRAWING ALGORITM


void circleMidpoint (int x, int y, int h, int k int r)
{
int x = 0;
Int y = r;
int d = 3 – 2(r);
circlePlotPoints(x, y, h, k, v);
while (x < y)
{
x++;
if (d < 0)
f += 4*x+6;
else
{ y--;
f += 4*(x-y)+10;
}
} circlePlotPoints(x, y, h, k, v);
}
Void Circlepoint (int x, int y, int h, int k, int v)
{ putpixel(h+x,k+y,12);
putpixel(h-x,k+y,12);
putpixel(h+x,k-y,12);
putpixel(h-x,k-y,12);
putpixel(h+y,k+x,12);
putpixel(h-y,k+x,12);
putpixel(h+y,k-x,12);
putpixel(h-y,k-x,12);
}

PROGRAM TO DRAW AN ELLIPSE USING POLYNOMIAL METHOD


#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
int midx,midy;
void plot4points(int,int);
void main()
{
int gdriver=DETECT,gmode,errorcode;
float r1,r2,xo,yo,i,x,xe,y;
initgraph(&gdriver,&gmode,” “);
printf”\n Enter the length of both axis : “;
cin>>r1>>r2;
cout<<”\n Enter the center of ellipse : “;
cin>>xo>>yo;
cout<<”\n Enter the step size : “;
cin>>i;
midx=getmaxx()/2;
midy=getmaxy()/2;
x=0;
xe=r1;
//putpixel(xo,yo,RED);
while(x<=xe)
{
y=r2*(sqrt(1-(x*x)/(r1*r1)));
plot4points(x,y);
x=x+i;
}
getch();
closegraph();
}
void plot4points(int x,int y)
{
putpixel(midx+(x),midy-(y),RED);
putpixel(midx+(-x),midy-(y),RED);
putpixel(midx+(-x),midy-(-y),RED);
putpixel(midx+(x),midy-(-y),RED);
}

PROGRAM TO DRAW ELLIPSE USING MID POINT ALGORITHM

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void disp();
float x,y;
int xc,yc;
void main()
{
int gd=DETECT,gm;
int a,b;
float p1,p2;
clrscr();
initgraph(&gd,&gm,"");
scanf("%d%d",&xc,&yc);
scanf("%d%d",&a,&b);
x=0;y=b;
disp();
p1=(b*b)-(a*a*b)+(a*a)/4;
while((2.0*b*b*x)<=(2.0*a*a*y))
{

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
x++;
if(p1<=0)
p1=p1+(2.0*b*b*x)+(b*b);
else
{
y--;
p1=p1+(2.0*b*b*x)+(b*b)-(2.0*a*a*y);
}
disp();
x=-x;
disp();
x=-x;
}
x=a;
y=0;
disp();
p2=(a*a)+2.0*(b*b*a)+(b*b)/4;
while((2.0*b*b*x)>(2.0*a*a*y))
{
y++;
if(p2>0)
p2=p2+(a*a)-(2.0*a*a*y);
else
{
x--;
p2=p2+(2.0*b*b*x)-(2.0*a*a*y)+(a*a);
}
disp();
y=-y;
disp();
y=-y;
}
getch();
closegraph();
}
void disp()
{
putpixel(xc+x,yc+y,10);
putpixel(xc-x,yc+y,10);
putpixel(xc+x,yc-y,10);
putpixel(xc+x,yc-y,10);
}

CLIPPING

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
Clipping is a process of cutting those primitives which do not fit in clip rectangle. Clip rectangle is a
rectangular area or canvas where picture is to be drawn and by cutting we mean calculating
intersection point on edge of clip rectangle.
Any procedure that identifies those portions of picture that are either inside or outside of a specified
region is referred to as clipping algorithm.
It involves following parts:-
1. We can test a given line segment to determine whether it lies completely inside the clip window.
2. If it does not we try to determine whether it lies completely outside the window.
3. If we cannot identify a line as completely inside or outside we must perform intersection
calculations with one or more clipping boundaries.

APPLICATIONS OF CLIPPING
1. Extracting part of a defined scene for viewing.
2. Identifying visible surface in 3D views.
3. Analyzing line segments or object boundaries.
4. Creating object using solid modeling procedures.
5. Drawing and painting operations that allow part of picture to be selected foe copying, moving,
erasing or duplicating.
Available algorithms for clipping on following Cohen primitives are:
1. Point clipping
2. Line clipping
3. Area clipping
4. Curve clipping
5. Text clipping

COHEN SUTHERLAND LINE CLIPPING ALGORITHM


The Cohen Sutherland algorithms uses four bits area code or region code to determine whether line is
inside clipping area or outside clipping rectangle or partially inside and partially outside clipping
rectangle.
If a line is partially inside and outside clipping rectangle then such line is basically referred to as
clipping candidate. Total area is divided into nine parts. Each region or area has a unique area code.
The above mentioned 4-bit code is assigned on the basis of the following
1. If y > 𝑦𝑚𝑎𝑥 then 1bit is on
2. If y < 𝑦𝑚𝑖𝑛 then 2bit is on
3. If x > 𝑥𝑚𝑎𝑥 then 3bit is on
4. If x<min then 4bit is on
A line is said to be inside clipping rectangle if it satisfy all following inequalities:-
𝑥𝑚𝑖𝑛 <= 𝑥 <= 𝑥𝑚𝑎𝑥
𝑦𝑚𝑖𝑛 <= 𝑦 <= 𝑦𝑚𝑎𝑥

The following is Cohen Sutherland algorithm which performs line clipping


1. Calculate region code for both end points I.e., code 0 for starting point and code 1 for ending point
2. If both region codes i.e., code 0 and code1 are zero 0000, print line is inside clipping rectangle.
3. If code0 and code1 I.e., bitwise AND of code0 and code1 is non-zero, print line is outside clipping
rectangle
Else
1. Select non-zero region code, if both are non-zero select code0 first.
2. If region code's 1st bit is on
𝑦 = 𝑦𝑚𝑎𝑥
𝑥 = 𝑥0 + (𝑥1 − 𝑥0) ∗ (𝑦𝑚𝑎𝑥 − 𝑦0)/(𝑦1 − 𝑦0)
3. If region code's 2nd bit is on
𝑦 = 𝑦𝑚𝑖𝑛
𝑥 = 𝑥0 + (𝑥1 − 𝑥0) ∗ (𝑦𝑚𝑖𝑛 − 𝑦0)/(𝑦1 − 𝑦0)

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
4. If region code's 3rd bit is on
𝑥 = 𝑥𝑚𝑎𝑥
𝑦 = 𝑦0 + (𝑦1 − 𝑦0) ∗ (𝑥𝑚𝑎𝑥 − 𝑥0)/(𝑥1 − 𝑥0)
5. If region code's 4th bit is on
𝑥 = 𝑥𝑚𝑖𝑛
𝑦 = 𝑦0 + (𝑦1 − 𝑦0) ∗ (𝑥𝑚𝑖𝑛 − 𝑥0)/(𝑥1 − 𝑥0)
4. If code0 is selected then
𝑥0 = 𝑥
𝑦0 = 𝑦
𝐸𝑙𝑠𝑒
𝑥1 = 𝑥
𝑦1 = 𝑦
5. Repeat steps 2 to 4 till the line either comes inside clipping rectangle or totally outside clipping
rectangle.
6. Exit

Midpoint Subdivision Algorithm


1. Check whether the line P1 P2 can be trivially included. i.e. when both P1 and P2 are visible. If so
exit. Else
2. Check the point P1, which is visible, and the other point P2, which is invisible.
3. Divide the segment P1 P2 at P 11 check if P11 is visible if so, the farthest point is beyond P11, so
proceed by dividing P11 P2 else divide the segment P1 and P11.
4. Repeat step (3) until the segment to be divided reduces to a single point. The segment to be
displayed is bound by P1 and this point.

(Note: if in step2, both P1 and P2 are invisible, we have to first divide the line, take a visible point and
then repeat the algorithm twice for both the segments)

Parametric Line Equation


• Equation is defined by two points, P0 and P1
• P(t) = P0 + (P1 - P0) t, where P is a vector [x, y]T
– x(t) = x0 + (x1 - x0) t
– y(t) = x0 + (y1 - y0) t
• 0 <=t <= 1
– Defines line between P0 and P1
– t<0
– Defines line before P0
– t>1
– Defines line after P1
Cyrus-Beck Algorithm
• Start with parametric equation of line: PL
P(t) = P0 + (P1 - P0) t
• And a point and normal for each
edge
• PL, NL
P(t)
• Find t such that NL [P(t) - PL] = 0 Inside
• Substitute line equation for P(t)
• Solve for t NL
t = NL [PL – P0] / -NL [P1 - P0]

• Compute t for line intersection with all four edges


• Discard all (t < 0) and (t > 1)
• Classify each remaining intersection as

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
– Potentially Entering (PE)
– Potentially Leaving (PL)
– NL [P1 - P0] > 0 implies PL
• NL [P1 - P0] < 0 implies PE
– Note that we computed this term when computing t
• Compute PE with largest t
• Compute PL with smallest t
• Clip to these two points

PL P1
PL

PE
PE
P0
• Because of horizontal and vertical clip lines:
– Many computations reduce
– Normals: (-1, 0), (1, 0), (0, -1), (0, 1)
• Pick constant points on edges
• solution for t:
– -(x0 - xleft) / (x1 - x0)
– (x0 - xright) / -(x1 - x0)
– -(y0 - ybottom) / (y1 - y0)
– (y0 - ytop) / -(y1 - y0)

Comparison
• Cohen-Sutherland
– Repeated clipping is expensive
– Best used when trivial acceptance and rejection is possible for most lines
• Cyrus-Beck
– Computation of t-intersections is cheap
– Computation of (x,y) clip points is only done once
– Algorithm doesn’t consider trivial accepts/rejects
Best when many lines must be clipped

INTRODUCTION TO CG
It is system software which is concerned with representing real and imaginary objects in the form of pictures.
This implies that CG is related to generation of pictures, defining it, storing it and presenting with the help of
algorithms. It performs conversion, transformation, projection, illumination, shading etc.

Computer Graphics allows communication through pictures, charts and diagrams. In today’s world person
does not have time to read huge number of pages; for e.g., to know the performance of business over a time
period. This problem can be solved using CG. A huge database can be represented by pictures; like bars, pie
charts which enables a person to understand the concept just at a glance.

IMAGE PROCESSING
This term is often related with CG but it is quite different from it. Image processing is concerned with
enhancing the quality of an image i.e. adjusting color, brightness, contrast etc.

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
REPRESENTATIVE USES OF COMPUTER GRAPHICS
1. User interfaces: Graphic system provides attractive and easy interaction between user and
computers. Graphic system provides user interfaces such as button, menus, icons, scroll bar etc.,
which allows user to interact with computer only by mouse click.
2. Plotting graphs and charts: CG is most commonly used in business, industry, government and in
educational organization to create 2-D and 3-D graphs of mathematical, physical and economic
function in form of histograms, bars and pie charts. This helps in decision making.
3. Office automation and desktop publishing: Desktop publishing allows creation and
dissemination of information. It allows users to create a document which helps in automation of
office.
4. Simulation and Animation: - Simulation permits expensive and complex phenomenon and
processes to be modeled in computer. Using it astronauts, aircrafts and ship-
pilots can be trained to perfection in a complex and expensive piece of equipment without
risking life or property. Animation helps in production of animated movies and cartoons films.
5. Cartography: - CG helps to produce accurate and schematic representation of graphical and
other natural phenomena from measurement data for e.g., geographic maps, relief maps, weather
maps, oceanographic maps.
6. Building design and construction: - CG is useful in generating architect’s drawing and
visualizing structures. Architect can walk through building looking at images on computer.
7. Electronic design: - Engineers work on video screen and design the PCB (Printed Circuit). This
copy can be used to design system.
8. Mechanical Design: - With the help of constructive solid geometry we can design different parts
of machine on computer.

CLASSIFICATION OF COMPUTER GRAPHICS


CG can be broadly divided into two categories:-
1. INTERACTIVE: - In this kind of graphic system, users can interact with it to change the view or perform
an action. This mean that graphic system generate picture with user intervention for e.g., on clicking OK or
CANCEL on a dialog box in MS-Windows we can perform some action. Interactive graphics is
interchangeably used with computer graphics.
2. NON-INTERACTIVE:- In this kind of system user cannot interact with the system to change the view or
perform some action for e.g., TV. We can change the channel but cannot change the actual picture.
APPLICATIONS OF CG
1. CAD (Computer Aided Design): - It is best known and biggest application of computer graphics.
This refers particularly to engineering application such as building and other structural design,
mechanical and industrial design. It is also concerned with design of manufacturing processes
such as automobiles, aircraft, ships and spacecraft. This process involves modeling which is
concerned with conceptual model of process or geometrical model of an object on which analysis,
modification, estimation of material or cost can be carried out.

Advantages: -
a) It eliminates more expensive mistakes.
b) User is able to view object in various forms such as wire-frame (skeleton view), or over all
view.
2. GIS (Geographic Information System): - It is a technique used for assembly, integration and
analysis of text, tabular data about natural and man-made feature and facilities for purpose of
better understanding, efficient analysis and faster decision making.

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
3. Presentation and business graphics: - CG has raised presentation level using brochure, posters,
transparencies etc for publicity and training purpose. A special part of presentation graphics,
graphs, charts and model of other facts and figures related to business, industry can be developed
easily.
4. CAL (Computer Aided Learning):- CG is quite useful in teaching learning processes especially in
complex training areas. Tools such as Microsoft PowerPoint are very heavily used in seminar and
conferences.
5. Medical Application: - CG has given a very powerful tool of diagnosis and treatment in hands of
doctors, surgeons for e.g., with the help of CAT (Computerized Axial Tomography) Scan we can
get 2-D images of cross-sectional view of human body or a specific organ of human body. It is
useful in surgeries also. A surgeon can rehearse operation on computerized 3D image of human
body.
6. Desktop Publishing: - It deals with production of journals, newsletter, and newspapers using
word processing techniques with CG.
7. Games and Entertainment: - CG helps in creation of games such a riddle, puzzles, etc with
colorful and animated screen display which always attracts children.
8. Virtual reality: - On wearing special devices on eyes ears and fingers user can interact with
virtual; reality inside the virtual system.
9. Fractal: - This means image creation. It uses equation to repeat pattern of shapes, texture and
colors to simulate the evolution and growth of living organism.

CONCEPTUAL FRAMEWORK OF INTERACTIVE GRAPHICS

High level conceptual framework of interactive graphics consists of two main components; software
and hardware component where software part deals with application model, application program
and graphic system and hardware deals with computer devices like monitor, input and output
devices.
Application Model – It captures the object which is to be displayed on screen and it also maintains
the data about this object in a repository called as Application Database. This Application Database is
further referred by the application program. It is independent of display system.
Application Program – It creates application and it communicates with it to store the data and to
receive the data in the form of commands. It is also responsible for handling input and output
devices. It receives the input from user via input devices and then sends the command to graphics
system to display the object. It basically consists of the logic which tells what to display on screen.
Program extracts geometry and converts it to series of commands primitives of graphics system
Graphics system – It is responsible for actual displaying the object. I act as an interface between user
and hardware. It provides the user interface through which user can communicate easily with the

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
particular software where he can write the program. It then receives the series of graphic command
about the object to be displayed on screen from application program. It specifies the part that how to
display the object.
RASTER SCAN DISPLAY
In this display system, electron beam is swept across screen one row at a time from top to bottom.
Intensity of a beam is turned on or off to create illuminated spots. Picture definition is stored in
memory known as refresh buffer or frame buffer. This frame memory holds set of intensity values for
all screen points. It is well suited for displaying realistic display for e.g., Television, printers.

In simple black and white systems each screen point in either turned on or off. It requires only 1 bit
per pixel to control intensity of screen position. Additional bits are needed when colors are to be
displayed. For this purpose, 24 bits per pixel is used in high quality systems. If we are using 1 bit per
pixel then frame buffer is called as BitMap and if multiple bits are being used then it is known as
PixMap.

This system involves two concepts; Horizontal


Retrace and Vertical Retrace. Beam is swept
through each line one by one at a time. At the
end of each line electron beam returns to the left
side of screen to begin displaying next scan line.
Returning to the left of screen is called as
Horizontal Retrace.
At the end of each frame, beam is returned to the
top left corner of the screen to begin the next
frame. This is known as Vertical Retrace.

RANDOM SCAN DISPLAY


In this type of display, electron beam is directed only to the part of screen where picture is to be
drawn. It draws picture one line at a time. This system is also called a Vector or stroke writing or
Calligraphic displays. Refresh rate depends upon number of lines to be displayed. Picture definition
is stored in refresh buffer as a set of line drawing commands. To display a specific picture system
cycles through set of commands, drawing each component line in turn. After processing all
commands, system cycles back to first line command. This display system is suitable for only line
drawing application not for displaying realistic screens.

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I

DIFFERENCE BETWEEN RASTER AND RANDOM SCAN DISPLAY


S.NO Random Scan Display Raster Scan Display
1. Beam is moved between end points of Beam moved over the screen one scan line at
graphics primitives. a time from top to bottom, left to right.
2. Flickering happens when number of It is independent of the complexity of image.
primitives becomes too large.
3. Cost is more. It is less costly.
4. It draws continuous and smooth lines. It draws lines by approximating primitives.
5. It is capable to draw only lines. It is capable to draw realistic pictures.

RASTER SCAN DISPLAY SYSTEM


Interactive raster graphic system employs several
processing unit including CPU and special
purpose processor called video or display
controller. Display controller is used control
operation of display devices. It also accesses
frame buffer which is present in system memory
to draw and refresh the screen.

To draw any image frame buffer location is matched with screen positions. Screen origin may be
defined at lower left corner. X will get increase from left to right and y will get increased from bottom
to top. The first line which is scanned starts from top left corner of the screen i.e., from (0, y max) to (xmax,
ymax). Then y gets decremented for every next scan line. In the same manner x gets incremented by 1
for every scanned pixel. To scan whole line for this purpose video controller maintains x and y registers
to store coordinates of screen pixels. These all values are stored in frame buffer and are retrieved by
video controller to draw any image on screen starting from scanning first line to last line in each frame.
Screen is refreshed at 60 times per second. To speed up pixel processing video controller can retrieve
multiple pixel processing video controller can retrieve multiple values from refresh buffer on each pass.
In high resolution system two frame buffers are maintained. It is also used to perform transformations.

Disadvantage

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
1. It is quite slow because graphic package and application program both run in CPU.
2. Frame buffer is part of memory. SO, video controller accesses it through system bus by making
it busy till the usage time.

To overcome second disadvantage a separate port has been given to access the frame buffer.
Raster display system with peripheral display processor.
This employs a separate graphic processor to perform graphics function such as scan conversion. It
also has a separate frame buffer. System holds data and those programs that run on CPU such as
application program. Display processor memory holds data plus program that perform scan
conversion and raster graphics operations.
Disadvantage
1. CPU does not have direct access to frame buffer.
2. To perform any change in graphics double buffering is required.

Anti-aliasing (points and lines)


A drawback of raster display systems arises from the nature of the raster itself. The raster system can
display mathematically smooth lines, polygons, and boundaries of curved primitives such as circles
and ellipses only by approximating them with pixels on the raster grid. This can cause the problem of
"jaggies" or "stair-casing" as shown in the figure below. This visual artifact is a manifestation of a
sampling error called aliasing. Such artifacts occur when a function of a continuous variable that
contains sharp changes in intensity is approximated with discrete samples. Modern computer
graphics is concerned with techniques for reducing or removing "jaggies" or "stair-casing" referred to
as anti aliasing.

Figure: Aliased lines caused by the finite pixel size (left) and anti-aliased lines (right). Notice that the
anti-aliasing algorithm produces a somewhat "blurred" image.
There are several algorithms developed for anti-aliasing, the simplest is to increase the resolution.
Doubling the resolution in horizontal and vertical direction, will make the jags half in size and double
their numbers. They will look smoother, but this will quadruple the use of graphical memory, which
is expensive. There are other and cheaper ways to handle the problem. The simplest is called
unweighted area sampling. Consider lines (which are infinitely thin), they can be approximated as a
one pixel wide quadrilateral. The pixel values are given by the coverage of the quadrilateral. For each
pixel, the pixel value is given by A = A * degree-of coverage.

CATHOD RAY TUBE (CRT)

BASIC OPERATION

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
A beam of electrons i.e., cathode rays is emitted by an electron gun passes through focusing and
deflection systems that directs the beam towards specified position on the phosphor coated screen.
The phosphor then emits a small spot of light at each position contacted by the electron beam. This
light emitted by phosphorus fades very rapidly so method is always required to redraw the image
again and again. This type of display is known as Refresh cathode Ray Tube.

Primary component of an electron gun are heated metal cathode and a control grid. Heat is supplied
to the cathode by directing current through wire. Due to this free and negatively charged electrons
are accelerated towards phosphorus coated screen by a high positive voltage. The high positive
voltage is generated with a positively charged metal near the phosphorus screen or accelerating
anode can be used.
Intensity of electron beam is controlled by setting voltage level on control grid which is metal
cylinder that fits over cathode. Since amount of light emitted by phosphorus coating depends on no.
of electrons striking the screen. We can control brightness of display by varying voltage on control
grid.
Focusing system is required to force the electron beam to converge into a small spot. Otherwise
electrons would repel each other and beam would spread out. Focusing system is accomplished with
either electric magnetic field.
Additional focusing hardware is used in high precision system. The distance that beam travels to
different points on the screen varies. As the beam moves to outer edge of screen displaying image
becomes blurred. To compensate this system can adjust focusing according to screen position of the
beam.
1. Different kinds of phosphorus are available. Major difference between them exists due to
PERSISTENCE i.e., how long they continue to emit light after CRT beam is removed. It may also be
defined as time taken by emitted light from screen to decay to one tenth of original intensity. Lower
persistence phosphorus requires higher refresh rate to maintain a picture on the screen without
flicker.
2. Maximum no. of points that can be displayed without overlap on CRT is referred to as
RESOLUTION. It is no. of points per centimeters that can be plotted horizontally and vertically.
Resolution depends on type of phosphorus, intensity to be displayed focusing and deflection system.
3. ASPECT RATIO: - the no. gives the ratio of vertical points to horizontal points that are necessary
to produce equal length lines in both directions. Three fourth means that vertical line plotted with
three points has same length as a horizontal line plotting with four points.

COLOR CRT
Color CRT is based on either of two methods to emit light.
1. Beam penetration
This method is used in random scan monitors. It works in same way as normal CRT works but it uses
combinations of phosphorus to produce range of colors. In this CRT uses two layers of phosphorus
which are usually red and green. Displaying color depends upon how far the electron beam
penetrates into the phosphorus layers. Beam of slow electrons excites only red layers and that of fast
type electrons penetrates through red layer and excites inner green layer. At intermediate beam
speed orange and yellow colors are produced. So color depends upon beam acceleration voltage.
Advantage
1. Inexpensive
Disadvantage
1. Only four colors can be produced.
2. Quality of image is not good.

2. Shadow mask
Prepared By: Shilpa Taneja
IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
This method is used in raster scan system. This type of CRT uses 3 phosphorus color dots at each
pixels position to produce wide range of colors where one phosphorus element emits red, other green
and third blue color. I.e., it uses 3electron guns one for each color dot. It uses shadow mask grid
which is placed just behind phosphorus coated screen.

Delta-delta shadow mask method is used commonly. In this 3electron beam are deflected and
focused as a group onto shadow mask which contains series of holes aligned with the dot.
Combinations of these 3beam activate a dot triangle which appears as a small spot on screen.
Another method used is known as inline. In this method colored guns and dots are arranged along
one scan line. This is much easier way and is used high resolution CRT. Color variation is obtained
with the help of varying the intensity level of 3electron beams. By turning off red and blue we will
get only green color. Colors also depend on amount of excitation RGB phosphorus for e.g., white is
produced when equal intensity of RGB is used. Yellow is produced when only green and red are
used.
DIRECT VIEW STORAGE TUBE (DVST)
DVST provides us an alternative method for maintaining the screen image that is to store that image
inside CRT itself instead of refreshing the screen.
For this purpose DVST uses two electron guns one for storing the picture and another for maintain
the display by emitting low speed electrons which does not affect the picture being displayed but
actually provides strength.
ADVANTAGES
1. No refreshing is required.
2. Complex picture can be displayed without flickering.
DISADVANTAGE
1. It cannot display colors.

FLAT PANEL DISPLAY


Another emerging technology FPD provides us a significant feature that is, it is thinner than CRT. It
has reduced volume, weight, and power requirement as compare to CRT for e.g., calculators, TV
monitors, Laptop monitor, and Pocket video games.
These are available in two categories:-
1. Emissive – that converts electrical energy into light.
2. Non-Emissive – uses effects to convert sunlight or light from other source into graphical pattern.
EMISSIVE
1. Plasma / gas discharge display
It is made up of two glasses plates and region in between them is filled up with gasses where main is
neon gas. One glass plate has vertical conducting ribbon and other has horizontal conducting ribbon
and when very high voltage is supplied to them, then it breaks down gasses into glowing plasma of
electrons and ions picture definition is stored in refresh buffer. It uses refresh rate of 60.
Note: - Interlacing – It is refreshing mechanism. It works in two passes. Old lines are refreshed and
then even lines are refreshed.

2. THIN-FILM ELECTRO LUMINESCENT DISPLAY

Prepared By: Shilpa Taneja


IITM\ BCA-303 \ COMPUTER GRAPHICS\ UNIT- I
These are similar to plasma but it uses phosphorous such as zinc sulfide doped with manganese to fill
up the region between glass plate instead of gases. It uses two electrodes. When high voltage is
supplied to them, phosphorus becomes conductor. It absorbs electrical energy and produces light
similar to plasma.
3. LED (LIGHT EMMITTING DIODE)
A matrix of diode is arranged to form pixel position in display. Picture definition is stored in refresh
buffer. Voltage is applied to diodes to produce light.

NON- EMMISIVE
1.) LCD (liquid crystal display)
It display picture either by passing polarized light from surrounding or it uses internal light source
through liquid crystal material. It uses compounds which have crystalline arrangement of molecules
but they flow like liquid. It uses two glass plates when one has vertical conductor and other has
horizontal conductor and in between these plates we have liquid material which produces light when
voltage is supplied to conductors. Refresh rate used is 60.

Prepared By: Shilpa Taneja

You might also like