SlideShare a Scribd company logo
1.2: Raster Graphics
Presented By : Tekendra Nath Yogi
Tekendranath@gmail.com
College Of Applied Business And Technology
Basic Raster Algorithms for 2D Primitives
• In Raster graphic system a picture can be describe in
two ways:
– A Set of intensities for the pixel positions in the display or
– A set of complex objects consisting of set of basic
geometric objects.
– These basic geometric objects are called output primitives;
– Includes:
• Point ,Line , Circle, Ellipse, Polygon, etc.
2By: Tekendra Nath Yogi2/9/2019
Contd….
• If the picture(scene) is described as a set of intensities for the
pixel positions in the display then the scene is displayed by
loading the pixel arrays into the frame buffer.
• If the picture(scene) is described as a set of complex objects
consisting of set of basic geometric objects then the scene is
displayed by scan converting the basic geometric-structure
specifications into pixel patterns.
• Normally picture is described in terms of output primitives.
3By: Tekendra Nath Yogi2/9/2019
Points
• Point plotting is accomplished by converting a single
coordinate position furnished by an application program into
appropriate operations for the output device in use.
• For example:
– For a black and- white raster system a point is plotted by setting the bit
value corresponding to a specified screen position within the frame
buffer to 1.
– Then, as the electron beam sweeps across each horizontal scan line, it
emits a burst of electrons (plots a point) whenever a value of 1 is
encountered in the frame buffer.
4By: Tekendra Nath Yogi2/9/2019
Contd….
Fig: point on a display device
5By: Tekendra Nath Yogi2/9/2019
Lines
• A line segment is completely defined in terms of its two
endpoints.
• Line segment is thus defined as:
– Line_seg ={(x1,y1), (x2, y2)}
6By: Tekendra Nath Yogi2/9/2019
Contd….
• Digital devices display a straight line by plotting (illuminating)
discrete coordinate points along the line path which are
calculated from the equation of the line.
7By: Tekendra Nath Yogi2/9/2019
Contd….
• Screen locations are referenced with integer values, so plotted
positions may only approximate actual line positions between
two specific endpoints.
• E.g.,: A computed line position of (10.48, 20.51) will be
converted to pixel position (10, 21). This rounding of
coordinate values to integers causes lines to be displayed with
a stairstep appearance (the “jaggies”).
8By: Tekendra Nath Yogi2/9/2019
Line Drawing Algorithms
• If the coordinates of end points of the line segment are known,
there are several methods for selecting the pixels between the
end pixels(line drawing).
• Two main algorithms :
– Digital Difference Analyzer (DDA algorithm)
– Bresenham Line Drawing Algorithm
• Based on the slope-intercept equation of a straight line.
9By: Tekendra Nath Yogi2/9/2019
Contd…
10
• The slope-intercept equation of a straight line is:
– Where, m = slope of line and b = y-intercept.
– For any two given points (x1, y1) and (x2, y2)
– Therefore, equation (1) becomes,
– At any point, (xk, yk)
)1(.............  bmxy
12
12
xx
yy
m



x
xx
yy
yb
12
12



)2(.............yk  bmxk
Contd..
11
• At (xk+1, yk+1),
• Subtracting (2) from (3) we get,
• Therefore,
– ∆y = m.∆x
– Or, ∆x = ∆y/ m
– Or, m = ∆y /∆x
These equations form the basis for sampling point between give two end point of a
line.
)3(............11   bmxy kk
)( 11 kkkk xxmyy  
DDAAlgorithm
• The digital differential analyzer(DDA) is a scan conversion
line algorithm based on calculating either:
– ∆y = m.∆x or
– ∆x = ∆y/m
• Sample the line at unit intervals in one coordinate
• Determine the corresponding integer values nearest the line
path in another co-ordinate
12By: Tekendra Nath Yogi2/9/2019
Case1: A line with positive slope
• a) assumption 1: line are processed left end to right end point:
– i) if (m<=1 ) then sampling in x-direction
• ∆x =1, xk+1 = xk+1 and
• yk+1 =yk+ m
– ii)if (m>1) then sampling in y-direction(i.e.,
reverse role of x and y)
• ∆y = 1, yk+1 =yk+1 and
• xk+1 = xk+(1/m)
13By: Tekendra Nath Yogi2/9/2019
Contd….
• b) assumption 2: line are processed right end to left end point:
– i) if (m<=1 ) then sampling in x-direction
• ∆x =-1,
• xk+1 = xk -1 and
• yk+1 =yk - m
– ii)if (m>1) then sampling in y-direction(i.e.,
reverse role of x and y)
• ∆y = - 1, yk+1 =yk-1 and
• xk+1 = xk -(1/m)
14By: Tekendra Nath Yogi2/9/2019
Case1: A line with negative slope
• a) assumption 1: line are processed left end to right end point:
– i) if (|m|<=1 ) then sampling in x-direction
• ∆x =1, xk+1 = xk+1 and
• yk+1 =yk+ m
– ii)if (|m|>1) then sampling in y-direction(i.e.,
reverse role of x and y)
• ∆y = -1, yk+1 =yk-1 and
• xk+1 = xk-(1/m)
15By: Tekendra Nath Yogi2/9/2019
Contd….
• b) assumption 2: line are processed right end to left end point:
– i) if (|m|<=1 ) then sampling in x-direction
• ∆x =-1,
• xk+1 = xk -1 and
• yk+1 =yk – m
– ii)if (|m|>1) then sampling in y-direction(i.e., reverse
role of x and y)
• ∆y = 1, yk+1 =yk+1 and
• xk+1 = xk +(1/m)
16By: Tekendra Nath Yogi2/9/2019
Contd….
DDAAlgorithm:
1. Input the two line endpoints (x1, y1) and (x2, y2).
2. Plot first point (x1, y1).
3. Calculate constants Δx = (x2- x1), and Δy =(y2-y1).
4. If |Δx| > |Δy|
then steps = |Δx|
else steps = |Δy|
5. Calculate XInc = Δx / steps and YInc = Δy / steps
6. for (k=0; k<steps; k++)
{
x =x+ xInc;
y =y+ yInc;
plot(ROUND(x), ROUND(y));
}
17By: Tekendra Nath Yogi2/9/2019
Contd….
• Advantages of DDA algorithm:
– It is the simplest algorithm and it does not require special skills for
implementation.
– It is a faster method for calculating pixel positions than the direct use of
equation y= mx+b.
• Disadvantages of DDA algorithm:
– Floating point arithmetic in DDA algorithm is still time consuming.
– The algorithm is orientation dependent. So the end point accuracy is
poor.
18By: Tekendra Nath Yogi2/9/2019
Contd….
• Example: Rasterize/digitize the line with end point(10, 20) and
(20, 30) using DDA algorithm.
• solution:
– Given two line end points are: (x1,y1) = (10, 20) and (x2, y2) = (20,30)
– Plot (10,20)
– Now calculating Δx = (x2- x1) =(20-10) = 10 and
– Δy =(y2-y1)= (30-20)= 10.
– Therefore, step =10
– Calculating XInc = Δx / steps = 10/10 = 1and
– YInc = Δy / steps = 10/10 =1
19By: Tekendra Nath Yogi2/9/2019
Contd….
Iteration no.(K) X = X+ xinc Y = Y+yinc Pixel(x,y)
0 11 21 (11,21)
1 12 22 (12,22)
2 13 23 (13,23)
3 14 24 (14,24)
4 15 25 (15,25)
5 16 26 (16,26)
6 17 27 (17,27)
7 18 28 (18,28)
8 19 29 (19,29)
9 20 30 (20,30)
20By: Tekendra Nath Yogi2/9/2019
Class work
• Example1: Rasterize the line with end point (10,20) and
(14,30).
• Example2: Rasterize the line with end point (20,30) and
(15,34).
• Example3: Rasterize the line with end point (0,0) and (-6,-6).
21By: Tekendra Nath Yogi2/9/2019
Bresenham's Line algorithm(BLA)
• An accurate and efficient line generating algorithm, developed
by Bresenham.
• scan conversion algorithm.
• scan converts lines only using integer calculation to find the
next (x, y) position to plot.
• Hence, It avoids incremental error accumulation.
22By: Tekendra Nath Yogi2/9/2019
Contd….
• Bresenham's scan-conversion process for lines with positive slope less than 1:
– Pixel positions along a line path are determined by sampling at unit x intervals.
– Starting from the left end point (x0, y0) of a given line
– step to each successive x position and
– y plot the pixel whose scan-line value is closest to the line path.
23By: Tekendra Nath Yogi2/9/2019
Contd….
• i.e.,:
– Assuming we have determined that the pixel at (xk, yk) is to be
displayed.
– we next need to decide which pixel to plot in column xk+1.
– Our choices are the pixels at positions (xk+1, yk)and (xk+1, yk+1).
– In this case choose the pixel positions that is closest to the
mathematical line
24By: Tekendra Nath Yogi2/9/2019
Contd….
• 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.
25By: Tekendra Nath Yogi2/9/2019
Contd….
• At sampling position xk+1, vertical pixel separation from
mathematical line path is labeled as d1& d2 as shown in figure
below .
• The y-coordinate on the mathematical line path at pixel column xk+1
is calculated as:
y=m(xk+1)+b
26By: Tekendra Nath Yogi2/9/2019
Contd….
• Then d1 = y - yk
= m(xk + 1)+b – yk
And d2 =( yk + 1) - y
= (yk + 1)-m ( xk + 1 )-b
• Now,
d1-d2 = 2m ( xk + 1 ) - ( yk + 1 )-yk+2b
= 2m (xk + 1) - 2yk + 2b – 1
27By: Tekendra Nath Yogi2/9/2019
Contd….
•
• u
28By: Tekendra Nath Yogi2/9/2019
Contd….
• J
• Note: For a line with positive slope greater than 1, we simply interchange
the role of x & y.
29By: Tekendra Nath Yogi2/9/2019
Contd….
• Algorithm:
contd….
30By: Tekendra Nath Yogi2/9/2019
Contd….
• Contd…
contd….
31By: Tekendra Nath Yogi2/9/2019
Contd….
• Contd…
32By: Tekendra Nath Yogi2/9/2019
Contd….
• Example: Digitize the line with end point (10,20) and (20,26)
using BLA.
• Solution:
1. Given, (x1,y1) = (10, 20) and (x2,y2) = (20,26)
2. dx= |20-10| =10 and dy =|26-20| =6
3. Here x2>x1 is true i.e., 20>10 is true so set a = 1
4. y2>y1 is true i.e., 26>20 is true so set b =1
5. Here (dx>dy) is true i.e., 10>6 is true so, initial decision parameter
p0= 2dy-dx =2*6-10= 2
33By: Tekendra Nath Yogi2/9/2019
Contd….
• For k= 0; k <10; k++
34By: Tekendra Nath Yogi2/9/2019
K xk yk pk Pk+1 Xk+1 Yk+1 Pixel(x,y)
0 10 20 2 -6 11 21 (11,21)
1 11 21 -6 6 12 21 (12,21)
2 12 21 6 -2 13 22 (13,22)
3 13 22 -2 10 14 22 (14,22)
4 14 22 10 2 15 23 (15,23)
5 15 23 2 -6 16 24 (16,24)
6 16 24 -6 6 17 24 (17,24)
7 17 24 6 -2 18 25 (18,25)
8 18 25 -2 10 19 25 (19,25)
9 19 25 10 2 20 26 (20,26)
Contd….
• For k = 0
– (Pk=2<0) is false so
– Pk+1 =pk + 2dy-2dx =2+ 2*6-2*10 =-6
– Xk+1 = xk+a =10+1 =11
– Yk+1 = yk+b =20+1 =21
35By: Tekendra Nath Yogi2/9/2019
Contd….
• For k = 1
– (Pk=-6<0) is true so
– Pk+1 =pk + 2dy =-6+ 2*6 =6
– Xk+1 = xk+a =11+1 =12
– Yk+1 = yk=21
36By: Tekendra Nath Yogi2/9/2019
Contd….
• For k = 2
– (Pk=6<0) is false so
– Pk+1 =pk + 2dy-2dx =6+ 2*6-2*10 =-2
– Xk+1 = xk+a =12+1 =13
– Yk+1 = yk+b =21+1 =22
37By: Tekendra Nath Yogi2/9/2019
Contd….
• For k = 3
– (Pk=-2<0) is true so
– Pk+1 =pk + 2dy =-2+ 2*6 =10
– Xk+1 = xk+a =13+1 =14
– Yk+1 = yk=22
38By: Tekendra Nath Yogi2/9/2019
Contd….
• For k = 4
– (Pk=10<0) is false so
– Pk+1 =pk + 2dy-2dx =10+ 2*6-2*10 =2
– Xk+1 = xk+a =14+1 =15
– Yk+1 = yk+b =22+1 =23
39By: Tekendra Nath Yogi2/9/2019
Contd….
• For k = 5
– (Pk=2<0) is false so
– Pk+1 =pk + 2dy-2dx =2+ 2*6-2*10 =-6
– Xk+1 = xk+a =15+1 =16
– Yk+1 = yk+b =23+1 =24
40By: Tekendra Nath Yogi2/9/2019
Contd….
• For k = 6
– (Pk=-6<0) is true so
– Pk+1 =pk + 2dy =-6+ 2*6 =6
– Xk+1 = xk+a =16+1 =17
– Yk+1 = yk=24
41By: Tekendra Nath Yogi2/9/2019
Contd….
• For k = 7
– (Pk=6<0) is false so
– Pk+1 =pk + 2dy-2dx =6+ 2*6-2*10 =-2
– Xk+1 = xk+a =17+1 =18
– Yk+1 = yk+b =24+1 =25
42By: Tekendra Nath Yogi2/9/2019
Contd….
• For k = 8
– (Pk=-2<0) is true so
– Pk+1 =pk + 2dy-2dx =-2+ 2*6-2*10 =10
– Xk+1 = xk+a =18+1 =19
– Yk+1 = yk+b =25
43By: Tekendra Nath Yogi2/9/2019
Contd….
• For k = 9
– (Pk=10<0) is false so
– Pk+1 =pk + 2dy-2dx =10+ 2*6-2*10 =2
– Xk+1 = xk+a =19+1 =20
– Yk+1 = yk+b =25+1 =26
44By: Tekendra Nath Yogi2/9/2019
Contd….
• Example1: Digitize the line with endpoints (3,10) and (6,2)
using Bresenham line algorithm.
• Example2: Digitize the line with endpoints (5,10) and (10,7)
using Bresenham line algorithm.
• Example3: Digitize the line with endpoints (11,5) and (6,10)
using Bresenham line algorithm.
45By: Tekendra Nath Yogi2/9/2019
Circle Generating algorithms
• Circle is a frequently used component in pictures and graphs.
• A circle is defined as the set of points that are all at a given
distance r from the center position (xc, yc) as shown in figure
below:
Fig: Circle with center coordinates (xc, yc) and radius r
46By: Tekendra Nath Yogi2/9/2019
Contd….
• The equation of circle is:
• Where (x, y) = point on circle circumference can be calculated
by stepping along x-axis in unit steps from xc-r to xc+r and
corresponding y-value can be calculated as:
47By: Tekendra Nath Yogi2/9/2019
222
)()( ryyxx cc 
22
)( xxryy cc 
Contd….
• Problems in above method:
– Square root calculation at each step increase computational complexity.
– Spacing between plotted pixel positions is not uniform.
48By: Tekendra Nath Yogi2/9/2019
Computation can be reduced by considering the symmetry properties of circle!
• 4-way symmetry: The shape of circle is similar in each quadrant.
• i.e., If (x, y) is pixel position on circumference of circle in 1st quadrant
then corresponding symmetric positions are:
• 2nd quadrant = (-x, y)
• 3rd quadrant = (-x, -y )
• 4th quadrant = (x, -y )
49By: Tekendra Nath Yogi2/9/2019
Contd….
• 8-way symmetry: circle sections in adjacent octants within one
quadrant are symmetric with respect to 450 line dividing the two
octants:
50By: Tekendra Nath Yogi2/9/2019
•A point at position (x,y)
on a one-eighth circle
sector is mapped into the
seven circle points in the
other octants of the xy-
plane.
•So, generate all pixel
positions around a circle
by calculating only the
points within the sector
from x= 0 to x=y
Problem of computation still persists !
Contd….
• Midpoint circle algorithm:
– In mid point circle algorithm, we sample at unit intervals and determine
the closest pixel position to the specified circle path at each step.
– For given radius r and screen center position (xc, yc), first calculate
pixel positions around a circle path centered at the coordinate origin
(0,0) by using 8-way symmetry.
– Then, move each calculated position (x, y) to its proper screen position
by adding xc to x and yc to y.
51By: Tekendra Nath Yogi2/9/2019
Contd….
• To apply the mid point method, circle function is defined as:
• For any point (x, y) :
52By: Tekendra Nath Yogi2/9/2019
222
),( ryxyxfcircle 








boundarycircletheoutsideisyxif
boundarycircletheonisyxif
boundarycircletheinsideisyxif
yxfcircle
),(,0
),(,0
),(,0
),(
Contd….
• In midpoint algorithm decision parameter is a circle function.
• Test are performed for midpoint between pixels near the circle
path at each sampling step.
53By: Tekendra Nath Yogi2/9/2019
222
)
2
1
()1(
)
2
1
,1(
ryx
yxfp
kk
kkcirclek


Fig: midpoint between the two
candidate pixels at sampling
position xk+1
Decision:
yk+1 = yk if pk<0
yk+1 = yk-1 otherwise
Contd….
• Successive decision parameter at sampling position xk+1+1
=xk+2 is:
54By: Tekendra Nath Yogi2/9/2019
1)()()1(2
)
2
1
(]1)1[(
)
2
1
,1(
1
22
11
22
1
2
111






kkkkkkk
kk
kkcirclek
yyyyxpp
ryx
yxfp
Contd….
• If pk<0 then yK+1 = yk Thus
Pk+1 = Pk + 2xk+1+1
• Otherwise , yK+1 = yk -1 Thus
Pk+1 = Pk + 2xk+1+1-2yk+1
• Also incremental evaluation of 2xk+1 and 2yk+1
2xk+1 = 2xk + 2
2yk+1 = 2yk – 2 if pk >0
• At start position (x0,y0) = (0,r)
2x0 = 0 and 2y0 = 2r
55By: Tekendra Nath Yogi2/9/2019
Contd….
• Initial decision parameter:
• For r specified as an integer, round p0 to
P0 = 1-r
(because all increments are integers)
56By: Tekendra Nath Yogi2/9/2019
r
rr
rfp circle



4
5
)
2
1
(1
)
2
1
,1(
22
0
Midpoint circle algorithm
1. Input radius r and circle center (xc, yc) and obtain the first point on the circumference of a
circle centered on the origin as
(x0,y0) = (0,r)
2. Calculate the initial value of the decision parameter as
P0 = 5/4 – r = 1-r
3. At each xk position, starting at k = 0, perform the following test:
If pk < 0, the next point along the circle centered on (0,0) is (xk+1,yk) and
Pk+1 = pk + 2xk+1 + 1
Otherwise, the next point along the circle is (xk+1,yK-1) and
Pk+1 = pk + 2xk+1 + 1 -2yk+1
Where 2xk+1 = 2xk + 2 and 2yk+1 = 2yk-2
4. Determine the symmetry points in the other seven octants.
5. Move each calculated pixel position (x,y) onto the circular path
centered on (xc,yc) and plot the co-ordinate values:
x = x + xc, y = y+yc
6. Repeat steps 3 through 5 until x ≥ y
57By: Tekendra Nath Yogi2/9/2019
Contd….
• Example1: Draw a circle with center at (2,3) and radius 4
using midpoint circle drawing algorithm.
– Solution: Step 1 and 2:
• Given, radius(r) = 4
• Circle center (xc, yc) = (2, 3)
• Initial point on boundary of circle (x0, y0) =(0,r)= (0, 4)
• Initial decision parameter = 1-r = 1-4= -3
• Successive decision parameter and positions along the circular path
are calculated as until x>= y i.e. while(x<y) is true.
58By: Tekendra Nath Yogi2/9/2019
Contd….
K Xk Yk Pk Xk+1 Yk+1 2yk+1 2xk+1 Pk+1 Pixel Symmetric pixels
0 0 4 -3 1 4 8 2 0 (1, 4) (4,1), (-1,4), (-4,1), (-1,
-4), (-4, -1), (1,-4), (4,-
1)
1 1 4 0 2 3 6 4 -1 (2,3) (3,2,), (-2,3), (-3,2), (-
2, -3), (-3, -2), (2,-3),
(3, -2)
2 2 3 -1 3 3 6 6 6 (3,3) (3,3,), (-3,3), (-3, 3), (-
3,-3), (-3,-3), (3,-3),
(3,-3)
59By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 0:
– Step 3:
• Xk = x0= 0
• Yk= y0= 4
• Pk= p0= 1-r = 1-4= -3
• Here pk< 0 is true
• So, next point is (xk+1, yk) = (0+1, 4) = (1, 4)
• and pk+1= pk + 2xk+1+1= -3+2*1 +1 =0
60By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 0 Contd….:
– Step4: Now calculating symmetric pixels:
• For pixel (1,4) : (4,1), (-1,4), (-4,1), (-1, -4), (-4, -1), (1,-4), (4,-1)
– Step 5: Moving each calculated pixel position (x,y) onto the circular
path centered on (2,3) as: x = x + xc, y = y+yc
– Move (1,4) To(1+2, 4+3)= (3,7)
– Move (4,1)to (4+2, 1+3) =(6, 4),
– Move (-1,4) To (-1+2, 4+3)= (1,7)
– Move (-4,1) To (-4+2, 1+3)= (-2,4)
– Move (-1, -4) To (-1+2, -4+3)= (1,-1)
– Move (-4, -1) To (-4+2, -1+3)= (-2,2)
– Move (1,-4) To (1+2, -4+3)= (3, -1)
– Move (4,-1) To (4+2, -1+3)= (6,2)
– Step 6: x< y is true so continue
61By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 1:
– Step3:
• Xk = x1= 1
• Yk= y1= 4
• Pk= p1= 0
• Here pk< 0 is false
• So, next point is (xk+1, yk -1) = (1+1, 4-1) = (2, 3)
• and pk+1= pk + 2xk+1+1 – 2yk+1= 0+ 2*2 +1 – 2*3 = -1
62By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 1 Contd…:
– Step 4: Now calculating symmetric pixels:
• For pixel (2,3): (3,2,), (-2,3), (-3,2), (-2, -3), (-3, -2), (2,-3), (3, -2)
– Step 5: Moving each calculated pixel position (x,y) onto the circular path
centered on (2,3) as: x = x + xc, y = y+yc
• Move (2,3) To (2+2, 3+3)= (4, 6)
• Move (3,2) To ( 3+2, 2+3)= (5,5)
• Move (-2,3) To (-2+2, 3+3)= (0,6)
• Move (-3,2) To (-3+2, 2+3)= (-1,5)
• Move (-2, -3) To (-2+2, -3+3)= (0,0)
• Move (-3, -2) To (-3+2, 3+3)= (-1,6)
• Move(2,-3) To (2+2, -3+3)= (4,0)
• Move (3, -2) To (3+2, -2+3)= (5,1)
– Step6: x< y is true so continue
63By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 2:
– Step 3:
• Xk = x2= 2
• Yk= y2= 3
• Pk= p2= -1
• Here pk< 0 is true
• So, next point is (xk+1, yk ) = (2+1, 3) = (3,3)
• And pk+1= pk + 2xk+1+1 = -1+ 2*3 +1 = 6
64By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 2 Contd…..:
– Step 4:Now calculating symmetric pixels:
• For pixel (3,3): (3,3,), (-3,3), (-3, 3), (-3,-3), (-3,-3), (3,-3), (3,-3)
– Step 5: Moving each calculated pixel position (x,y) onto the circular
path centered on (2,3) as: x = x + xc, y = y+yc
• Move (3,3) To (3+2, 3+3) = (5,6)
• Move (3,3) To (3+2, 3+3) = (5,6)
• Move (-3,3) To (-3+2, 3+3)= (-1,6)
• Move (-3,3) To (-3+2, 3+3)= (-1,6)
• Move (-3,-3) To (-3+2, -3+3)= (-1, 0)
• Move (-3,-3) To (-3+2, -3+3)= (-1, 0)
• Move (3,-3) To (3+2, -3+3)= (5, 0)
• Move (3,-3) To (3+2, -3+3)= (5, 0)
– Step 6: x< y is false so terminate!
65By: Tekendra Nath Yogi2/9/2019
Contd….
• Example2: calculate pixel position of circle with radius 10
and center at origin i.e. (xc, yc)= (0,0).
– Solution:
• Given, radius(r) = 10
• Circle center (xc, yc) = (0, 0)
• Initial point on boundary of circle (x0, y0) =(0,r)= (0, 10)
• Initial decision parameter = 1-r = 1-10 = -9
• Successive decision parameter and positions along the circular path
are calculated as until x>= y i.e. while(x<y) is true.
66By: Tekendra Nath Yogi2/9/2019
Contd….
67By: Tekendra Nath Yogi2/9/2019
K Xk Yk Pk Xk+1 Yk+1 Pk+1 pixel 2xk+1 2yk+1 Symmetric pixels
0 0 10 -9 1 10 -6 1,10 2 10 (10,1), ( 1,- 10), (-1, 10), (-1, -10), (-10,-
1), (-10,1), (10,-1)
1 1 10 -6 2 10 -1 2,10 4 20 (10, 2),(-2,10) ,(-10,2), (-2,-10), (-10,-
2),(2, -10),(10, -2)
2 2 10 -1 3 10 6 3,10 6 20 (10, 3), (-10, 3), (-3, 10), (-3, -10), (-10,
-3), (3, -10), (10, -3)
3 3 10 6 4 9 -3 4,9 8 18 (9,4), (-4, 9), (-9,4), (-4, -9), (-9, -4), (4,
-9), (9, 4)
4 4 9 -3 5 9 8 5,9 10 18 (9,5), (-5,9), (-9,5), (-5, -9), (-9, -5), (5, -
9), (9,-5)
5 5 9 8 6 8 5 6,8 12 16 (8,6), (-6,8), (-8,6) , (-6,-8), (-8, -6), (6, -
8), (8, -6)
6 6 8 5 7 7 6 7,7 14 14 (7,7), (-7,7) (-7, 7), (-7, -7), (-7, -7),(7, -
7) (7, -7)
Contd….
68By: Tekendra Nath Yogi2/9/2019
y
x1 2 3 4 5 6 7 8 90 10
1
2
3
8
9
0
10
5
6
7
4
Contd….
• Iteration 0:
– Xk = x0= 0
– Yk= y0= 10
– Pk= p0= 1-r = 1-10= -9
– Here pk< 0 is true
– So, next point is (xk+1, yk) = (0+1, 10) = (1, 10)
– Now pk+1= pk + 2xk+1+1= -9+2*1 +1 =-6
– Symmetric pixels: (10,1), ( 1,- 10), (-1, 10), (-1, -10), (-10,-1), (-10,1), (10,-1)
– Here circle center is at origin so directly plot the symmetric pixels
– x< y is true so continue
69By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 1:
– Xk = x1= 1
– Yk= y1= 10
– Pk= p1= -6
– Here pk< 0 is true
– So, next point is (xk+1, yk) = (1+1, 10) = (2, 10)
– Now pk+1= pk + 2xk+1+1= -6+2*2 +1 =-1
– Symmetric pixels:(10, 2),(-2,10) ,(-10,2), (-2,-10), (-10,-2),(2, -10),(10, -2)
– Here circle center is at origin so directly plot the symmetric pixels
– x< y is true so continue
70By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 2:
– Xk = x2= 2
– Yk= y2= 10
– Pk= p2= -1
– Here pk< 0 is true
– So, next point is (xk+1, yk) = (2+1, 10) = (3, 10)
– Now pk+1= pk + 2xk+1+1= -1+2*3+1 =6
– Symmetric pixels:(10, 3), (-10, 3), (-3, 10), (-3, -10), (-10, -3), (3, -10), (10, -
3)
– Here circle center is at origin so directly plot the symmetric pixels
– x< y is true so continue
71By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 3:
– Xk = x3= 3
– Yk= y3= 10
– Pk= p3= 6
– Here pk< 0 is false
– So, next point is (xk+1, yk -1) = (3+1, 10-1) = (4, 9)
– Now pk+1= pk + 2xk+1+1 – 2yk+1= 6+ 2*4 +1 – 2*9 = -3
– Symmetric pixels: (9,4), (-4, 9), (-9,4), (-4, -9), (-9, -4), (4, -9), (9, 4)
– Here circle center is at origin so directly plot the symmetric pixels
– x< y is true so continue
72By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 4:
– Xk = x4= 4
– Yk= y4= 9
– Pk= p4= -3
– Here pk< 0 is true
– So, next point is (xk+1, yk) = (4+1, 9) = (5,9)
– Now pk+1= pk + 2xk+1+1= -3+2*5+1 =8
– Symmetric pixels: (9,5), (-5,9), (-9,5), (-5, -9), (-9, -5), (5, -9), (9,-5)
– Here circle center is at origin so directly plot the symmetric pixels
– x< y is true so continue
73By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 5:
– Xk = x5= 5
– Yk= y5= 9
– Pk= p5= 8
– Here pk< 0 is false
– So, next point is (xk+1, yk -1) = (5+1, 9-1) = (6, 8)
– Now pk+1= pk + 2xk+1+1 – 2yk+1= 8+ 2*6 +1 – 2*8 = 5
– Symmetric pixels:(8,6), (-6,8), (-8,6) , (-6,-8), (-8, -6), (6, -8), (8, -6)
– Here circle center is at origin so directly plot the symmetric pixels
– x< y is true so continue
74By: Tekendra Nath Yogi2/9/2019
Contd….
• Iteration 6:
– Xk = x6= 6
– Yk= y6= 8
– Pk= p6= 5
– Here pk< 0 is false
– So, next point is (xk+1, yk -1) = (6+1, 8-1) = (7, 7)
– Now pk+1= pk + 2xk+1+1 – 2yk+1= 5+ 2*7 +1 – 2*7 = 6
– Symmetric pixels: (7,7), (-7,7) (-7, 7), (-7, -7), (-7, -7),(7, -7) (7, -7)
– Here circle center is at origin so directly plot the symmetric pixels
– x< y is false so terminate !
75By: Tekendra Nath Yogi2/9/2019
Homework
• Example1: Draw a circle with center at (2,3) and radius 8
using midpoint circle drawing algorithm. (Note: pixel = (x+xc,
y+yc)
• Example2: Draw a circle with center at (3,3) and radius 4
using midpoint circle drawing algorithm. (Note: pixel = (x+xc,
y+yc)
• Example3: Draw a circle with center at (3,5) and radius 10
using midpoint circle drawing algorithm. (Note: pixel = (x+xc,
y+yc)
76By: Tekendra Nath Yogi2/9/2019
Implementation
77By: Tekendra Nath Yogi2/9/2019
Contd….
78By: Tekendra Nath Yogi2/9/2019
Contd….
79By: Tekendra Nath Yogi2/9/2019
Contd….
• Output:
80By: Tekendra Nath Yogi2/9/2019
Ellipse Generating Algorithm
• Loosely stated:
– Ellipse is an elongated circle. So, ellipse can be generated by modifying
circle –drawing procedures.
• A precise definition:
– An ellipse is defined as the set of points such that the sum of the
distances from two fixed positions(foci) is the same for all points.
– i.e., d1+d2= constant for all point on the boundary of the ellipse
81By: Tekendra Nath Yogi2/9/2019
Contd..
• let F1= (x1, y1) and F2= (x2, y2) and boundary point P(x, y)
• Then d1 = and d2 =
• So,
82By: Tekendra Nath Yogi2/9/2019
        constant
2
2
2
2
2
1
2
1  yyxxyyxx
Contd….
• Assumption for simplification: major and minor axes are
oriented to align with the coordinate axes as shown in figure
below.
• For above ellipse, equation of the ellipse can be written as:
• Problem: computational complexity!
83By: Tekendra Nath Yogi2/9/2019
1
22








 





 
y
c
x
c
r
yy
r
xx
Contd….
• To reduce computational complexity symmetric property can
be used.
– An ellipse in standard position is symmetric between quadrants as
shown in figure below:
84By: Tekendra Nath Yogi2/9/2019
(x,y)
(x,-y)
(-x,y)
(-x,-y)
rx
ry
Contd….
• Midpoint ellipse algorithm:
– Given rx , ry and (xc, yc)
– Midpoint ellipse algorithm first determine the boundary points (x, y) of
the ellipse in standard position centered on the origin, and
– Then shift the points so the ellipse is centered at (xc, yc)
85By: Tekendra Nath Yogi2/9/2019
Contd….
• The midpoint ellipse algorithm started either at(0, ry) or at (rx,
0), and is applied throughout the first quadrant by taking unit
steps in the x-direction where the slope of the curve has a
magnitude less than 1(region1), and taking unit steps in the y-
direction where the slope has a magnitude greater than
1(region2).
86By: Tekendra Nath Yogi2/9/2019
Contd….
• Consider an ellipse centered at the origin, (xc,yc)=(0,0) then the ellipse
equation becomes:
• To apply the midpoint method Ellipse function is defined as:
• For any point (x,y)
– fe(x,y) < 0 if (x,y) is inside the ellipse
– fe(x,y) = 0 if (x,y) is on the ellipse
– fe(x,y) > 0 if (x,y) is outside the ellipse
• Thus, the ellipse function serves as a decision
Parameter in midpoint ellipse algorithm.
87By: Tekendra Nath Yogi2/9/2019
1
22















yx r
y
r
x
  222222
, yxxye rryrxryxf 
Contd….
• Decision parameter at sampling
position (xk+1) in region1:
88By: Tekendra Nath Yogi2/9/2019
Midpoint between candidate
pixels at sampling position
xK+ 1 along an elliptical
path
 
22
2
222
2
1
2
1
)1(
,11
yxkxky
kkek
rryrxr
yxfp








Decision:
yk+1 = yk if p1k<0 , i.e., select pixel( xK+1,yk) to plot
yk+1 = yk-1 otherwise, i.e., select pixel( xK+1,yk -1 ) to plot
Contd….
• At the next sampling position (xk+1 + 1 = xk + 2), the decision
parameter for region 1 is evaluated as
where yk+1 is either yk or yk -1 depending on the sign of p1k.
89By: Tekendra Nath Yogi2/9/2019
 
































22
1
222
1
22
2
1
222
2
1
111
2
1
2
1
)1(211
2
1
]1)1[(
,11
kkxykykk
yxkxky
kkek
yyrrxrpp
or
rryrxr
yxfp
Contd….
• where yk+1 is either yk or yk -1 depending on the sign of p1k.
• So, successive decision parameter:
• At the initial position (x0, y0)= (0, ry), the two terms evaluate to
2ry
2x = 0 ……. (i) & 2rx
2y = 2rx
2ry ……. (ii)
• As x and y are incremented, updated values are obtained by adding 2ry
2 to
(i) and subtracting 2rx
2 from (ii).
90By: Tekendra Nath Yogi2/9/2019






011
01
1
kk
kk
k
pify
pify
y










01221
0121
1
22
1
2
2
1
2
1
kkxykyk
kykyk
k
pifyrrxrp
pifrxrp
P
Contd….
• Updated values are compared at each step, and we move from
region 1 to region 2 when 2ry
2x >= 2rx
2y
• In region 1, initial value of decision parameter is obtained by
evaluating the ellipse function at the start position (x0, y0) = (0,
ry):
91By: Tekendra Nath Yogi2/9/2019
222
0
22
2
22
0
0
4
1
1
2
1
1
2
1
,11
xyxy
yxyxy
ye
rrrrp
or
rrrrrp
rfp















Contd….
• Decision parameter at sampling position (yk-1) in region2:
– Over region 2, we sample at unit steps in the negative y direction, and
the midpoint is now taken between horizontal pixels at each step.
92By: Tekendra Nath Yogi2/9/2019
Contd….
• For region 2 the decision parameter is evaluated as
93By: Tekendra Nath Yogi2/9/2019
 
  2222
2
2
2
1
1
2
1
1,2
yxkxky
kkek
rryrxr
yxfp








Decision:
xk+1 = xk if p2k > 0 , i.e., select pixel( xK,yk-1) to plot
xk+1 = xk+1 otherwise, i.e., select pixel( xK+1,yk -1 ) to plot
Contd….
• At the next sampling position (yk+1 - 1 = yk - 2), the decision
parameter for region 2 is evaluated as:
• where xk+1 is set either to xk or to xk+1depending on the sign of
p2k.
94By: Tekendra Nath Yogi2/9/2019
 
































22
1
222
1
2222
2
1
2
12
1
11
2
1
2
1
)1(222
]1)1[(
2
1
1,2
kkyxkxkk
yxkxky
kkek
xxrryrpp
or
rryrxr
yxfp
Contd….
• where xk+1 is set either to xk or to xk+1depending on the sign of
p2k.
– If p2k > 0, next point is (xk, yk-1) and
– else, next point is (xk+1, yk-1) and
95By: Tekendra Nath Yogi2/9/2019
2
1
2
1 222 xkxkk ryrpp  
2
1
2
1
2
1 2222 xkxkykk ryrxrpp  
Contd….
• In region 2, initial value of decision parameter is obtained by
evaluating the ellipse function at the initial position (x0, y0) that
is the last position selected in region 1
96By: Tekendra Nath Yogi2/9/2019
  222
0
2
2
0
2
0
000
1
2
1
2
1,
2
1
2
yxxy
e
rryrxrp
yxfp














Midpoint Ellipse Algorithm
1. Input rx, ry and ellipse center (xc, yc). Obtain the first point on an ellipse
centered on the origin (0, 0),
(x0, y0) = (0, ry).
1. Calculate initial value for decision parameter in region 1 as:
2
4
122
01 xyxy rrrrp 
Midpoint Ellipse Algorithm
3. At each xk in region 1, starting from k = 0, test p1k :
If p1k < 0, next point (xk+1, yk) and
else, next point (xk+1, yk-1) and
with 2ry
2xk+1 = 2ry
2xk + 2ry
2, 2rx
2yk+1 = 2rx
2yk – 2rx
2
and repeat step 3 until 2ry
2x  2rx
2y
2
1
2
1 211 ykykk rxrpp  
2
1
2
1
2
1 2211 ykxkykk ryrxrpp  
Midpoint Ellipse Algorithm
4. Calculate the initial value for decision parameter in region 2 using the last point
calculated in region 1 as:
where (x0, y0) is the last position calculate in region 1
5. At each yk in region 2, starting from k = 0, test p2k:
If p2k > 0, next point is (xk, yk-1) and
else, next point is (xk+1, yk-1) and
continue until y=0
2
1
2
1 222 xkxkk ryrpp  
    222
0
22
2
1
0
2
0 12 yxxy rryrxrp 
2
1
2
1
2
1 2222 xkxkykk ryrxrpp  
Midpoint Ellipse Algorithm
6. For both region determine symmetry points in the other 3 quadrants
7. Move each calculated pixel position (x,y) onto the elliptical path centered
on (xc,yc) and plot the coordinate values
x=x + xc, y =y + yc
Example
•Digitize an ellipse with center (0,0) and x-radius (rx )=8 and y-
radius (ry)=6, using the midpoint ellipse algorithm.
•For region 1:
–Initial point for ellipse centered at origin is (x0, y0) =(0, ry)= (0, 6)
2ry
2x = 0 and
2rx
2ry = 768
p10 = ?
–The initial value of decision parameter is:
102By: Tekendra Nath Yogi2/9/2019
3321
2
4
122
0  xyxy rrrrp
Contd….
• Successive decision parameter values and positions along the
ellipse path are calculated using the midpoint method as:
103By: Tekendra Nath Yogi2/9/2019
k p1k (xk+1,yk+1) 2ry
2 xk+1 2 rx
2yk+1
0 -332 (1,6) 72 768
1
2
3
4
5
6
Contd….
104By: Tekendra Nath Yogi2/9/2019
k p1k
(xk+1,yk+1) 2ry
2 xk+1 2 rx
2yk+1
0 -332 (1,6) 72 768
1 -224 (2,6) 144 768
2 -44 (3,6) 216 768
3 208 (4,5) 288 640
4 -108 (5,5) 360 640
5 288 (6,4) 432 512
6 244 (7,3) 504 384
Contd….
• For region 2, initial point is (x0, y0) = (7, 3), and initial
decision parameter is :
• The remaining pixels along the elliptical path in the first
quadrant are then calculated as:
• Now stop calculation, since y= 0 .
105By: Tekendra Nath Yogi2/9/2019
  23)2,7(1,2 2
1
2
1  ekkek fyxfp
k p2k (xk+1,yk+1) 2rv
2 xk+1 2 rx
2yk+1
0 -23 (8, 2) 576 256
1 361 (8, 1) 576 128
2 297 (8, 0) ---- ----
Plot pixel positions
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8
Contd….
• Symmetric point calculation:
– For (0, 6) : (0, 6), (0, -6), (0, -6)
– For (1,6) : (-1, 6), (-1,-6), (1, -6)
– For (2,6): (-2,6), (-2, -6), (2,-6)
– For (3,6): (-3,6), (-3, -6), (3, -6)
– For(4,5): (-4, 5), (-4,-5) (4,-5)
– For (5, 5): (-5,5), (-5,-5) (5,-5)
– For (6,4):(-6,4) (-6,-4) (6,-4)
– For (7,3): (-7,3), (-7,-3), (7,-3)
– For (8,2):(-8,2), (-8,-2), (8,-2)
– For (8,1): (-8,1), (-8,-1), (8,-1)
– For (8,0): (-8,0), (-8,0), (8,0)
107By: Tekendra Nath Yogi2/9/2019
Homework
• Example2: Digitize an ellipse with rx=8 and ry=6, and
centered at (2,3) using the midpoint ellipse algorithm.
• Example 3: Digitize an ellipse with center (20, 20) and x-
radius= 8 and y-radius= 6.
108By: Tekendra Nath Yogi2/9/2019
Midpoint Ellipse algorithm implementation
109By: Tekendra Nath Yogi2/9/2019
Contd….
110By: Tekendra Nath Yogi2/9/2019
Contd….
111By: Tekendra Nath Yogi2/9/2019
Contd….
• Output:
112By: Tekendra Nath Yogi2/9/2019
Thank You !
113By: Tekendra Nath Yogi2/9/2019

More Related Content

What's hot

Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
Maruf Abdullah (Rion)
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
Mani Kanth
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithm
Pooja Dixit
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
Mani Kanth
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
Pooja Dixit
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
Ankit Garg
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
Ankit Garg
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fillwahab13
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in Graphics
Rajani Thite
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
Laxman Puri
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
Sandesh Jonchhe
 
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICSATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
nehrurevathy
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
Timbal Mayank
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
kparthjadhav
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
KKARUNKARTHIK
 
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdfUNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
SayantanMajhi2
 
COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I
Hemantha Kulathilake
 
Register of 80386
Register of 80386Register of 80386
Register of 80386aviban
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 Microporcessor
KanchanPatil34
 
Frame buffer
Frame bufferFrame buffer
Frame buffer
Aparna Joshi
 

What's hot (20)

Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithm
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in Graphics
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
 
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICSATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
ATTRIBUTES OF OUTPUT PRIMITIVES IN COMPUTER GRAPHICS
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdfUNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
UNIT-6-Illumination-Models-and-Surface-Rendering-Methods.pdf
 
COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I
 
Register of 80386
Register of 80386Register of 80386
Register of 80386
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 Microporcessor
 
Frame buffer
Frame bufferFrame buffer
Frame buffer
 

Similar to B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi

B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
Tekendra Nath Yogi
 
Lecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptLecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.ppt
GaganvirKaur
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptx
AhmadAbba6
 
lecture 1.pptx
lecture 1.pptxlecture 1.pptx
lecture 1.pptx
MDRAKIB180107
 
Notes_456_Lines_Drawing2_4 (1).pdf
Notes_456_Lines_Drawing2_4 (1).pdfNotes_456_Lines_Drawing2_4 (1).pdf
Notes_456_Lines_Drawing2_4 (1).pdf
PranavRawat14
 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
RAJKIYA ENGINEERING COLLEGE, BANDA
 
Primitives
PrimitivesPrimitives
03.Scan Conversion.ppt
03.Scan Conversion.ppt03.Scan Conversion.ppt
03.Scan Conversion.ppt
RobinAhmedSaikat
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniya
TutorialsDuniya.com
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
aravindangc
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
Prabin Gautam
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
SanthiNivas
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
RAJKIYA ENGINEERING COLLEGE, BANDA
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Ankit Kumar
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
RajJain516913
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
Diksha Trivedi
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygonsaa11bb11
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
Kumar
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
Kamal Acharya
 

Similar to B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi (20)

B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
 
Lecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptLecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.ppt
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptx
 
lecture 1.pptx
lecture 1.pptxlecture 1.pptx
lecture 1.pptx
 
Notes_456_Lines_Drawing2_4 (1).pdf
Notes_456_Lines_Drawing2_4 (1).pdfNotes_456_Lines_Drawing2_4 (1).pdf
Notes_456_Lines_Drawing2_4 (1).pdf
 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
 
Primitives
PrimitivesPrimitives
Primitives
 
03.Scan Conversion.ppt
03.Scan Conversion.ppt03.Scan Conversion.ppt
03.Scan Conversion.ppt
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniya
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygons
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 

More from Tekendra Nath Yogi

Unit9:Expert System
Unit9:Expert SystemUnit9:Expert System
Unit9:Expert System
Tekendra Nath Yogi
 
Unit7: Production System
Unit7: Production SystemUnit7: Production System
Unit7: Production System
Tekendra Nath Yogi
 
Unit8: Uncertainty in AI
Unit8: Uncertainty in AIUnit8: Uncertainty in AI
Unit8: Uncertainty in AI
Tekendra Nath Yogi
 
Unit5: Learning
Unit5: LearningUnit5: Learning
Unit5: Learning
Tekendra Nath Yogi
 
Unit4: Knowledge Representation
Unit4: Knowledge RepresentationUnit4: Knowledge Representation
Unit4: Knowledge Representation
Tekendra Nath Yogi
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
Tekendra Nath Yogi
 
Unit2: Agents and Environment
Unit2: Agents and EnvironmentUnit2: Agents and Environment
Unit2: Agents and Environment
Tekendra Nath Yogi
 
Unit1: Introduction to AI
Unit1: Introduction to AIUnit1: Introduction to AI
Unit1: Introduction to AI
Tekendra Nath Yogi
 
Unit 6: Application of AI
Unit 6: Application of AIUnit 6: Application of AI
Unit 6: Application of AI
Tekendra Nath Yogi
 
Unit10
Unit10Unit10
Unit9
Unit9Unit9
Unit8
Unit8Unit8
Unit7
Unit7Unit7
BIM Data Mining Unit5 by Tekendra Nath Yogi
 BIM Data Mining Unit5 by Tekendra Nath Yogi BIM Data Mining Unit5 by Tekendra Nath Yogi
BIM Data Mining Unit5 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
BIM Data Mining Unit4 by Tekendra Nath Yogi
 BIM Data Mining Unit4 by Tekendra Nath Yogi BIM Data Mining Unit4 by Tekendra Nath Yogi
BIM Data Mining Unit4 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
BIM Data Mining Unit2 by Tekendra Nath Yogi
 BIM Data Mining Unit2 by Tekendra Nath Yogi BIM Data Mining Unit2 by Tekendra Nath Yogi
BIM Data Mining Unit2 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
BIM Data Mining Unit1 by Tekendra Nath Yogi
 BIM Data Mining Unit1 by Tekendra Nath Yogi BIM Data Mining Unit1 by Tekendra Nath Yogi
BIM Data Mining Unit1 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
Unit6
Unit6Unit6
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
Tekendra Nath Yogi
 
B.sc CSIT 2nd semester C++ Unit7
B.sc CSIT  2nd semester C++ Unit7B.sc CSIT  2nd semester C++ Unit7
B.sc CSIT 2nd semester C++ Unit7
Tekendra Nath Yogi
 

More from Tekendra Nath Yogi (20)

Unit9:Expert System
Unit9:Expert SystemUnit9:Expert System
Unit9:Expert System
 
Unit7: Production System
Unit7: Production SystemUnit7: Production System
Unit7: Production System
 
Unit8: Uncertainty in AI
Unit8: Uncertainty in AIUnit8: Uncertainty in AI
Unit8: Uncertainty in AI
 
Unit5: Learning
Unit5: LearningUnit5: Learning
Unit5: Learning
 
Unit4: Knowledge Representation
Unit4: Knowledge RepresentationUnit4: Knowledge Representation
Unit4: Knowledge Representation
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
 
Unit2: Agents and Environment
Unit2: Agents and EnvironmentUnit2: Agents and Environment
Unit2: Agents and Environment
 
Unit1: Introduction to AI
Unit1: Introduction to AIUnit1: Introduction to AI
Unit1: Introduction to AI
 
Unit 6: Application of AI
Unit 6: Application of AIUnit 6: Application of AI
Unit 6: Application of AI
 
Unit10
Unit10Unit10
Unit10
 
Unit9
Unit9Unit9
Unit9
 
Unit8
Unit8Unit8
Unit8
 
Unit7
Unit7Unit7
Unit7
 
BIM Data Mining Unit5 by Tekendra Nath Yogi
 BIM Data Mining Unit5 by Tekendra Nath Yogi BIM Data Mining Unit5 by Tekendra Nath Yogi
BIM Data Mining Unit5 by Tekendra Nath Yogi
 
BIM Data Mining Unit4 by Tekendra Nath Yogi
 BIM Data Mining Unit4 by Tekendra Nath Yogi BIM Data Mining Unit4 by Tekendra Nath Yogi
BIM Data Mining Unit4 by Tekendra Nath Yogi
 
BIM Data Mining Unit2 by Tekendra Nath Yogi
 BIM Data Mining Unit2 by Tekendra Nath Yogi BIM Data Mining Unit2 by Tekendra Nath Yogi
BIM Data Mining Unit2 by Tekendra Nath Yogi
 
BIM Data Mining Unit1 by Tekendra Nath Yogi
 BIM Data Mining Unit1 by Tekendra Nath Yogi BIM Data Mining Unit1 by Tekendra Nath Yogi
BIM Data Mining Unit1 by Tekendra Nath Yogi
 
Unit6
Unit6Unit6
Unit6
 
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
 
B.sc CSIT 2nd semester C++ Unit7
B.sc CSIT  2nd semester C++ Unit7B.sc CSIT  2nd semester C++ Unit7
B.sc CSIT 2nd semester C++ Unit7
 

Recently uploaded

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 

Recently uploaded (20)

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 

B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi

  • 1. 1.2: Raster Graphics Presented By : Tekendra Nath Yogi Tekendranath@gmail.com College Of Applied Business And Technology
  • 2. Basic Raster Algorithms for 2D Primitives • In Raster graphic system a picture can be describe in two ways: – A Set of intensities for the pixel positions in the display or – A set of complex objects consisting of set of basic geometric objects. – These basic geometric objects are called output primitives; – Includes: • Point ,Line , Circle, Ellipse, Polygon, etc. 2By: Tekendra Nath Yogi2/9/2019
  • 3. Contd…. • If the picture(scene) is described as a set of intensities for the pixel positions in the display then the scene is displayed by loading the pixel arrays into the frame buffer. • If the picture(scene) is described as a set of complex objects consisting of set of basic geometric objects then the scene is displayed by scan converting the basic geometric-structure specifications into pixel patterns. • Normally picture is described in terms of output primitives. 3By: Tekendra Nath Yogi2/9/2019
  • 4. Points • Point plotting is accomplished by converting a single coordinate position furnished by an application program into appropriate operations for the output device in use. • For example: – For a black and- white raster system a point is plotted by setting the bit value corresponding to a specified screen position within the frame buffer to 1. – Then, as the electron beam sweeps across each horizontal scan line, it emits a burst of electrons (plots a point) whenever a value of 1 is encountered in the frame buffer. 4By: Tekendra Nath Yogi2/9/2019
  • 5. Contd…. Fig: point on a display device 5By: Tekendra Nath Yogi2/9/2019
  • 6. Lines • A line segment is completely defined in terms of its two endpoints. • Line segment is thus defined as: – Line_seg ={(x1,y1), (x2, y2)} 6By: Tekendra Nath Yogi2/9/2019
  • 7. Contd…. • Digital devices display a straight line by plotting (illuminating) discrete coordinate points along the line path which are calculated from the equation of the line. 7By: Tekendra Nath Yogi2/9/2019
  • 8. Contd…. • Screen locations are referenced with integer values, so plotted positions may only approximate actual line positions between two specific endpoints. • E.g.,: A computed line position of (10.48, 20.51) will be converted to pixel position (10, 21). This rounding of coordinate values to integers causes lines to be displayed with a stairstep appearance (the “jaggies”). 8By: Tekendra Nath Yogi2/9/2019
  • 9. Line Drawing Algorithms • If the coordinates of end points of the line segment are known, there are several methods for selecting the pixels between the end pixels(line drawing). • Two main algorithms : – Digital Difference Analyzer (DDA algorithm) – Bresenham Line Drawing Algorithm • Based on the slope-intercept equation of a straight line. 9By: Tekendra Nath Yogi2/9/2019
  • 10. Contd… 10 • The slope-intercept equation of a straight line is: – Where, m = slope of line and b = y-intercept. – For any two given points (x1, y1) and (x2, y2) – Therefore, equation (1) becomes, – At any point, (xk, yk) )1(.............  bmxy 12 12 xx yy m    x xx yy yb 12 12    )2(.............yk  bmxk
  • 11. Contd.. 11 • At (xk+1, yk+1), • Subtracting (2) from (3) we get, • Therefore, – ∆y = m.∆x – Or, ∆x = ∆y/ m – Or, m = ∆y /∆x These equations form the basis for sampling point between give two end point of a line. )3(............11   bmxy kk )( 11 kkkk xxmyy  
  • 12. DDAAlgorithm • The digital differential analyzer(DDA) is a scan conversion line algorithm based on calculating either: – ∆y = m.∆x or – ∆x = ∆y/m • Sample the line at unit intervals in one coordinate • Determine the corresponding integer values nearest the line path in another co-ordinate 12By: Tekendra Nath Yogi2/9/2019
  • 13. Case1: A line with positive slope • a) assumption 1: line are processed left end to right end point: – i) if (m<=1 ) then sampling in x-direction • ∆x =1, xk+1 = xk+1 and • yk+1 =yk+ m – ii)if (m>1) then sampling in y-direction(i.e., reverse role of x and y) • ∆y = 1, yk+1 =yk+1 and • xk+1 = xk+(1/m) 13By: Tekendra Nath Yogi2/9/2019
  • 14. Contd…. • b) assumption 2: line are processed right end to left end point: – i) if (m<=1 ) then sampling in x-direction • ∆x =-1, • xk+1 = xk -1 and • yk+1 =yk - m – ii)if (m>1) then sampling in y-direction(i.e., reverse role of x and y) • ∆y = - 1, yk+1 =yk-1 and • xk+1 = xk -(1/m) 14By: Tekendra Nath Yogi2/9/2019
  • 15. Case1: A line with negative slope • a) assumption 1: line are processed left end to right end point: – i) if (|m|<=1 ) then sampling in x-direction • ∆x =1, xk+1 = xk+1 and • yk+1 =yk+ m – ii)if (|m|>1) then sampling in y-direction(i.e., reverse role of x and y) • ∆y = -1, yk+1 =yk-1 and • xk+1 = xk-(1/m) 15By: Tekendra Nath Yogi2/9/2019
  • 16. Contd…. • b) assumption 2: line are processed right end to left end point: – i) if (|m|<=1 ) then sampling in x-direction • ∆x =-1, • xk+1 = xk -1 and • yk+1 =yk – m – ii)if (|m|>1) then sampling in y-direction(i.e., reverse role of x and y) • ∆y = 1, yk+1 =yk+1 and • xk+1 = xk +(1/m) 16By: Tekendra Nath Yogi2/9/2019
  • 17. Contd…. DDAAlgorithm: 1. Input the two line endpoints (x1, y1) and (x2, y2). 2. Plot first point (x1, y1). 3. Calculate constants Δx = (x2- x1), and Δy =(y2-y1). 4. If |Δx| > |Δy| then steps = |Δx| else steps = |Δy| 5. Calculate XInc = Δx / steps and YInc = Δy / steps 6. for (k=0; k<steps; k++) { x =x+ xInc; y =y+ yInc; plot(ROUND(x), ROUND(y)); } 17By: Tekendra Nath Yogi2/9/2019
  • 18. Contd…. • Advantages of DDA algorithm: – It is the simplest algorithm and it does not require special skills for implementation. – It is a faster method for calculating pixel positions than the direct use of equation y= mx+b. • Disadvantages of DDA algorithm: – Floating point arithmetic in DDA algorithm is still time consuming. – The algorithm is orientation dependent. So the end point accuracy is poor. 18By: Tekendra Nath Yogi2/9/2019
  • 19. Contd…. • Example: Rasterize/digitize the line with end point(10, 20) and (20, 30) using DDA algorithm. • solution: – Given two line end points are: (x1,y1) = (10, 20) and (x2, y2) = (20,30) – Plot (10,20) – Now calculating Δx = (x2- x1) =(20-10) = 10 and – Δy =(y2-y1)= (30-20)= 10. – Therefore, step =10 – Calculating XInc = Δx / steps = 10/10 = 1and – YInc = Δy / steps = 10/10 =1 19By: Tekendra Nath Yogi2/9/2019
  • 20. Contd…. Iteration no.(K) X = X+ xinc Y = Y+yinc Pixel(x,y) 0 11 21 (11,21) 1 12 22 (12,22) 2 13 23 (13,23) 3 14 24 (14,24) 4 15 25 (15,25) 5 16 26 (16,26) 6 17 27 (17,27) 7 18 28 (18,28) 8 19 29 (19,29) 9 20 30 (20,30) 20By: Tekendra Nath Yogi2/9/2019
  • 21. Class work • Example1: Rasterize the line with end point (10,20) and (14,30). • Example2: Rasterize the line with end point (20,30) and (15,34). • Example3: Rasterize the line with end point (0,0) and (-6,-6). 21By: Tekendra Nath Yogi2/9/2019
  • 22. Bresenham's Line algorithm(BLA) • An accurate and efficient line generating algorithm, developed by Bresenham. • scan conversion algorithm. • scan converts lines only using integer calculation to find the next (x, y) position to plot. • Hence, It avoids incremental error accumulation. 22By: Tekendra Nath Yogi2/9/2019
  • 23. Contd…. • Bresenham's scan-conversion process for lines with positive slope less than 1: – Pixel positions along a line path are determined by sampling at unit x intervals. – Starting from the left end point (x0, y0) of a given line – step to each successive x position and – y plot the pixel whose scan-line value is closest to the line path. 23By: Tekendra Nath Yogi2/9/2019
  • 24. Contd…. • i.e.,: – Assuming we have determined that the pixel at (xk, yk) is to be displayed. – we next need to decide which pixel to plot in column xk+1. – Our choices are the pixels at positions (xk+1, yk)and (xk+1, yk+1). – In this case choose the pixel positions that is closest to the mathematical line 24By: Tekendra Nath Yogi2/9/2019
  • 25. Contd…. • 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. 25By: Tekendra Nath Yogi2/9/2019
  • 26. Contd…. • At sampling position xk+1, vertical pixel separation from mathematical line path is labeled as d1& d2 as shown in figure below . • The y-coordinate on the mathematical line path at pixel column xk+1 is calculated as: y=m(xk+1)+b 26By: Tekendra Nath Yogi2/9/2019
  • 27. Contd…. • Then d1 = y - yk = m(xk + 1)+b – yk And d2 =( yk + 1) - y = (yk + 1)-m ( xk + 1 )-b • Now, d1-d2 = 2m ( xk + 1 ) - ( yk + 1 )-yk+2b = 2m (xk + 1) - 2yk + 2b – 1 27By: Tekendra Nath Yogi2/9/2019
  • 29. Contd…. • J • Note: For a line with positive slope greater than 1, we simply interchange the role of x & y. 29By: Tekendra Nath Yogi2/9/2019
  • 33. Contd…. • Example: Digitize the line with end point (10,20) and (20,26) using BLA. • Solution: 1. Given, (x1,y1) = (10, 20) and (x2,y2) = (20,26) 2. dx= |20-10| =10 and dy =|26-20| =6 3. Here x2>x1 is true i.e., 20>10 is true so set a = 1 4. y2>y1 is true i.e., 26>20 is true so set b =1 5. Here (dx>dy) is true i.e., 10>6 is true so, initial decision parameter p0= 2dy-dx =2*6-10= 2 33By: Tekendra Nath Yogi2/9/2019
  • 34. Contd…. • For k= 0; k <10; k++ 34By: Tekendra Nath Yogi2/9/2019 K xk yk pk Pk+1 Xk+1 Yk+1 Pixel(x,y) 0 10 20 2 -6 11 21 (11,21) 1 11 21 -6 6 12 21 (12,21) 2 12 21 6 -2 13 22 (13,22) 3 13 22 -2 10 14 22 (14,22) 4 14 22 10 2 15 23 (15,23) 5 15 23 2 -6 16 24 (16,24) 6 16 24 -6 6 17 24 (17,24) 7 17 24 6 -2 18 25 (18,25) 8 18 25 -2 10 19 25 (19,25) 9 19 25 10 2 20 26 (20,26)
  • 35. Contd…. • For k = 0 – (Pk=2<0) is false so – Pk+1 =pk + 2dy-2dx =2+ 2*6-2*10 =-6 – Xk+1 = xk+a =10+1 =11 – Yk+1 = yk+b =20+1 =21 35By: Tekendra Nath Yogi2/9/2019
  • 36. Contd…. • For k = 1 – (Pk=-6<0) is true so – Pk+1 =pk + 2dy =-6+ 2*6 =6 – Xk+1 = xk+a =11+1 =12 – Yk+1 = yk=21 36By: Tekendra Nath Yogi2/9/2019
  • 37. Contd…. • For k = 2 – (Pk=6<0) is false so – Pk+1 =pk + 2dy-2dx =6+ 2*6-2*10 =-2 – Xk+1 = xk+a =12+1 =13 – Yk+1 = yk+b =21+1 =22 37By: Tekendra Nath Yogi2/9/2019
  • 38. Contd…. • For k = 3 – (Pk=-2<0) is true so – Pk+1 =pk + 2dy =-2+ 2*6 =10 – Xk+1 = xk+a =13+1 =14 – Yk+1 = yk=22 38By: Tekendra Nath Yogi2/9/2019
  • 39. Contd…. • For k = 4 – (Pk=10<0) is false so – Pk+1 =pk + 2dy-2dx =10+ 2*6-2*10 =2 – Xk+1 = xk+a =14+1 =15 – Yk+1 = yk+b =22+1 =23 39By: Tekendra Nath Yogi2/9/2019
  • 40. Contd…. • For k = 5 – (Pk=2<0) is false so – Pk+1 =pk + 2dy-2dx =2+ 2*6-2*10 =-6 – Xk+1 = xk+a =15+1 =16 – Yk+1 = yk+b =23+1 =24 40By: Tekendra Nath Yogi2/9/2019
  • 41. Contd…. • For k = 6 – (Pk=-6<0) is true so – Pk+1 =pk + 2dy =-6+ 2*6 =6 – Xk+1 = xk+a =16+1 =17 – Yk+1 = yk=24 41By: Tekendra Nath Yogi2/9/2019
  • 42. Contd…. • For k = 7 – (Pk=6<0) is false so – Pk+1 =pk + 2dy-2dx =6+ 2*6-2*10 =-2 – Xk+1 = xk+a =17+1 =18 – Yk+1 = yk+b =24+1 =25 42By: Tekendra Nath Yogi2/9/2019
  • 43. Contd…. • For k = 8 – (Pk=-2<0) is true so – Pk+1 =pk + 2dy-2dx =-2+ 2*6-2*10 =10 – Xk+1 = xk+a =18+1 =19 – Yk+1 = yk+b =25 43By: Tekendra Nath Yogi2/9/2019
  • 44. Contd…. • For k = 9 – (Pk=10<0) is false so – Pk+1 =pk + 2dy-2dx =10+ 2*6-2*10 =2 – Xk+1 = xk+a =19+1 =20 – Yk+1 = yk+b =25+1 =26 44By: Tekendra Nath Yogi2/9/2019
  • 45. Contd…. • Example1: Digitize the line with endpoints (3,10) and (6,2) using Bresenham line algorithm. • Example2: Digitize the line with endpoints (5,10) and (10,7) using Bresenham line algorithm. • Example3: Digitize the line with endpoints (11,5) and (6,10) using Bresenham line algorithm. 45By: Tekendra Nath Yogi2/9/2019
  • 46. Circle Generating algorithms • Circle is a frequently used component in pictures and graphs. • A circle is defined as the set of points that are all at a given distance r from the center position (xc, yc) as shown in figure below: Fig: Circle with center coordinates (xc, yc) and radius r 46By: Tekendra Nath Yogi2/9/2019
  • 47. Contd…. • The equation of circle is: • Where (x, y) = point on circle circumference can be calculated by stepping along x-axis in unit steps from xc-r to xc+r and corresponding y-value can be calculated as: 47By: Tekendra Nath Yogi2/9/2019 222 )()( ryyxx cc  22 )( xxryy cc 
  • 48. Contd…. • Problems in above method: – Square root calculation at each step increase computational complexity. – Spacing between plotted pixel positions is not uniform. 48By: Tekendra Nath Yogi2/9/2019
  • 49. Computation can be reduced by considering the symmetry properties of circle! • 4-way symmetry: The shape of circle is similar in each quadrant. • i.e., If (x, y) is pixel position on circumference of circle in 1st quadrant then corresponding symmetric positions are: • 2nd quadrant = (-x, y) • 3rd quadrant = (-x, -y ) • 4th quadrant = (x, -y ) 49By: Tekendra Nath Yogi2/9/2019
  • 50. Contd…. • 8-way symmetry: circle sections in adjacent octants within one quadrant are symmetric with respect to 450 line dividing the two octants: 50By: Tekendra Nath Yogi2/9/2019 •A point at position (x,y) on a one-eighth circle sector is mapped into the seven circle points in the other octants of the xy- plane. •So, generate all pixel positions around a circle by calculating only the points within the sector from x= 0 to x=y Problem of computation still persists !
  • 51. Contd…. • Midpoint circle algorithm: – In mid point circle algorithm, we sample at unit intervals and determine the closest pixel position to the specified circle path at each step. – For given radius r and screen center position (xc, yc), first calculate pixel positions around a circle path centered at the coordinate origin (0,0) by using 8-way symmetry. – Then, move each calculated position (x, y) to its proper screen position by adding xc to x and yc to y. 51By: Tekendra Nath Yogi2/9/2019
  • 52. Contd…. • To apply the mid point method, circle function is defined as: • For any point (x, y) : 52By: Tekendra Nath Yogi2/9/2019 222 ),( ryxyxfcircle          boundarycircletheoutsideisyxif boundarycircletheonisyxif boundarycircletheinsideisyxif yxfcircle ),(,0 ),(,0 ),(,0 ),(
  • 53. Contd…. • In midpoint algorithm decision parameter is a circle function. • Test are performed for midpoint between pixels near the circle path at each sampling step. 53By: Tekendra Nath Yogi2/9/2019 222 ) 2 1 ()1( ) 2 1 ,1( ryx yxfp kk kkcirclek   Fig: midpoint between the two candidate pixels at sampling position xk+1 Decision: yk+1 = yk if pk<0 yk+1 = yk-1 otherwise
  • 54. Contd…. • Successive decision parameter at sampling position xk+1+1 =xk+2 is: 54By: Tekendra Nath Yogi2/9/2019 1)()()1(2 ) 2 1 (]1)1[( ) 2 1 ,1( 1 22 11 22 1 2 111       kkkkkkk kk kkcirclek yyyyxpp ryx yxfp
  • 55. Contd…. • If pk<0 then yK+1 = yk Thus Pk+1 = Pk + 2xk+1+1 • Otherwise , yK+1 = yk -1 Thus Pk+1 = Pk + 2xk+1+1-2yk+1 • Also incremental evaluation of 2xk+1 and 2yk+1 2xk+1 = 2xk + 2 2yk+1 = 2yk – 2 if pk >0 • At start position (x0,y0) = (0,r) 2x0 = 0 and 2y0 = 2r 55By: Tekendra Nath Yogi2/9/2019
  • 56. Contd…. • Initial decision parameter: • For r specified as an integer, round p0 to P0 = 1-r (because all increments are integers) 56By: Tekendra Nath Yogi2/9/2019 r rr rfp circle    4 5 ) 2 1 (1 ) 2 1 ,1( 22 0
  • 57. Midpoint circle algorithm 1. Input radius r and circle center (xc, yc) and obtain the first point on the circumference of a circle centered on the origin as (x0,y0) = (0,r) 2. Calculate the initial value of the decision parameter as P0 = 5/4 – r = 1-r 3. At each xk position, starting at k = 0, perform the following test: If pk < 0, the next point along the circle centered on (0,0) is (xk+1,yk) and Pk+1 = pk + 2xk+1 + 1 Otherwise, the next point along the circle is (xk+1,yK-1) and Pk+1 = pk + 2xk+1 + 1 -2yk+1 Where 2xk+1 = 2xk + 2 and 2yk+1 = 2yk-2 4. Determine the symmetry points in the other seven octants. 5. Move each calculated pixel position (x,y) onto the circular path centered on (xc,yc) and plot the co-ordinate values: x = x + xc, y = y+yc 6. Repeat steps 3 through 5 until x ≥ y 57By: Tekendra Nath Yogi2/9/2019
  • 58. Contd…. • Example1: Draw a circle with center at (2,3) and radius 4 using midpoint circle drawing algorithm. – Solution: Step 1 and 2: • Given, radius(r) = 4 • Circle center (xc, yc) = (2, 3) • Initial point on boundary of circle (x0, y0) =(0,r)= (0, 4) • Initial decision parameter = 1-r = 1-4= -3 • Successive decision parameter and positions along the circular path are calculated as until x>= y i.e. while(x<y) is true. 58By: Tekendra Nath Yogi2/9/2019
  • 59. Contd…. K Xk Yk Pk Xk+1 Yk+1 2yk+1 2xk+1 Pk+1 Pixel Symmetric pixels 0 0 4 -3 1 4 8 2 0 (1, 4) (4,1), (-1,4), (-4,1), (-1, -4), (-4, -1), (1,-4), (4,- 1) 1 1 4 0 2 3 6 4 -1 (2,3) (3,2,), (-2,3), (-3,2), (- 2, -3), (-3, -2), (2,-3), (3, -2) 2 2 3 -1 3 3 6 6 6 (3,3) (3,3,), (-3,3), (-3, 3), (- 3,-3), (-3,-3), (3,-3), (3,-3) 59By: Tekendra Nath Yogi2/9/2019
  • 60. Contd…. • Iteration 0: – Step 3: • Xk = x0= 0 • Yk= y0= 4 • Pk= p0= 1-r = 1-4= -3 • Here pk< 0 is true • So, next point is (xk+1, yk) = (0+1, 4) = (1, 4) • and pk+1= pk + 2xk+1+1= -3+2*1 +1 =0 60By: Tekendra Nath Yogi2/9/2019
  • 61. Contd…. • Iteration 0 Contd….: – Step4: Now calculating symmetric pixels: • For pixel (1,4) : (4,1), (-1,4), (-4,1), (-1, -4), (-4, -1), (1,-4), (4,-1) – Step 5: Moving each calculated pixel position (x,y) onto the circular path centered on (2,3) as: x = x + xc, y = y+yc – Move (1,4) To(1+2, 4+3)= (3,7) – Move (4,1)to (4+2, 1+3) =(6, 4), – Move (-1,4) To (-1+2, 4+3)= (1,7) – Move (-4,1) To (-4+2, 1+3)= (-2,4) – Move (-1, -4) To (-1+2, -4+3)= (1,-1) – Move (-4, -1) To (-4+2, -1+3)= (-2,2) – Move (1,-4) To (1+2, -4+3)= (3, -1) – Move (4,-1) To (4+2, -1+3)= (6,2) – Step 6: x< y is true so continue 61By: Tekendra Nath Yogi2/9/2019
  • 62. Contd…. • Iteration 1: – Step3: • Xk = x1= 1 • Yk= y1= 4 • Pk= p1= 0 • Here pk< 0 is false • So, next point is (xk+1, yk -1) = (1+1, 4-1) = (2, 3) • and pk+1= pk + 2xk+1+1 – 2yk+1= 0+ 2*2 +1 – 2*3 = -1 62By: Tekendra Nath Yogi2/9/2019
  • 63. Contd…. • Iteration 1 Contd…: – Step 4: Now calculating symmetric pixels: • For pixel (2,3): (3,2,), (-2,3), (-3,2), (-2, -3), (-3, -2), (2,-3), (3, -2) – Step 5: Moving each calculated pixel position (x,y) onto the circular path centered on (2,3) as: x = x + xc, y = y+yc • Move (2,3) To (2+2, 3+3)= (4, 6) • Move (3,2) To ( 3+2, 2+3)= (5,5) • Move (-2,3) To (-2+2, 3+3)= (0,6) • Move (-3,2) To (-3+2, 2+3)= (-1,5) • Move (-2, -3) To (-2+2, -3+3)= (0,0) • Move (-3, -2) To (-3+2, 3+3)= (-1,6) • Move(2,-3) To (2+2, -3+3)= (4,0) • Move (3, -2) To (3+2, -2+3)= (5,1) – Step6: x< y is true so continue 63By: Tekendra Nath Yogi2/9/2019
  • 64. Contd…. • Iteration 2: – Step 3: • Xk = x2= 2 • Yk= y2= 3 • Pk= p2= -1 • Here pk< 0 is true • So, next point is (xk+1, yk ) = (2+1, 3) = (3,3) • And pk+1= pk + 2xk+1+1 = -1+ 2*3 +1 = 6 64By: Tekendra Nath Yogi2/9/2019
  • 65. Contd…. • Iteration 2 Contd…..: – Step 4:Now calculating symmetric pixels: • For pixel (3,3): (3,3,), (-3,3), (-3, 3), (-3,-3), (-3,-3), (3,-3), (3,-3) – Step 5: Moving each calculated pixel position (x,y) onto the circular path centered on (2,3) as: x = x + xc, y = y+yc • Move (3,3) To (3+2, 3+3) = (5,6) • Move (3,3) To (3+2, 3+3) = (5,6) • Move (-3,3) To (-3+2, 3+3)= (-1,6) • Move (-3,3) To (-3+2, 3+3)= (-1,6) • Move (-3,-3) To (-3+2, -3+3)= (-1, 0) • Move (-3,-3) To (-3+2, -3+3)= (-1, 0) • Move (3,-3) To (3+2, -3+3)= (5, 0) • Move (3,-3) To (3+2, -3+3)= (5, 0) – Step 6: x< y is false so terminate! 65By: Tekendra Nath Yogi2/9/2019
  • 66. Contd…. • Example2: calculate pixel position of circle with radius 10 and center at origin i.e. (xc, yc)= (0,0). – Solution: • Given, radius(r) = 10 • Circle center (xc, yc) = (0, 0) • Initial point on boundary of circle (x0, y0) =(0,r)= (0, 10) • Initial decision parameter = 1-r = 1-10 = -9 • Successive decision parameter and positions along the circular path are calculated as until x>= y i.e. while(x<y) is true. 66By: Tekendra Nath Yogi2/9/2019
  • 67. Contd…. 67By: Tekendra Nath Yogi2/9/2019 K Xk Yk Pk Xk+1 Yk+1 Pk+1 pixel 2xk+1 2yk+1 Symmetric pixels 0 0 10 -9 1 10 -6 1,10 2 10 (10,1), ( 1,- 10), (-1, 10), (-1, -10), (-10,- 1), (-10,1), (10,-1) 1 1 10 -6 2 10 -1 2,10 4 20 (10, 2),(-2,10) ,(-10,2), (-2,-10), (-10,- 2),(2, -10),(10, -2) 2 2 10 -1 3 10 6 3,10 6 20 (10, 3), (-10, 3), (-3, 10), (-3, -10), (-10, -3), (3, -10), (10, -3) 3 3 10 6 4 9 -3 4,9 8 18 (9,4), (-4, 9), (-9,4), (-4, -9), (-9, -4), (4, -9), (9, 4) 4 4 9 -3 5 9 8 5,9 10 18 (9,5), (-5,9), (-9,5), (-5, -9), (-9, -5), (5, - 9), (9,-5) 5 5 9 8 6 8 5 6,8 12 16 (8,6), (-6,8), (-8,6) , (-6,-8), (-8, -6), (6, - 8), (8, -6) 6 6 8 5 7 7 6 7,7 14 14 (7,7), (-7,7) (-7, 7), (-7, -7), (-7, -7),(7, - 7) (7, -7)
  • 68. Contd…. 68By: Tekendra Nath Yogi2/9/2019 y x1 2 3 4 5 6 7 8 90 10 1 2 3 8 9 0 10 5 6 7 4
  • 69. Contd…. • Iteration 0: – Xk = x0= 0 – Yk= y0= 10 – Pk= p0= 1-r = 1-10= -9 – Here pk< 0 is true – So, next point is (xk+1, yk) = (0+1, 10) = (1, 10) – Now pk+1= pk + 2xk+1+1= -9+2*1 +1 =-6 – Symmetric pixels: (10,1), ( 1,- 10), (-1, 10), (-1, -10), (-10,-1), (-10,1), (10,-1) – Here circle center is at origin so directly plot the symmetric pixels – x< y is true so continue 69By: Tekendra Nath Yogi2/9/2019
  • 70. Contd…. • Iteration 1: – Xk = x1= 1 – Yk= y1= 10 – Pk= p1= -6 – Here pk< 0 is true – So, next point is (xk+1, yk) = (1+1, 10) = (2, 10) – Now pk+1= pk + 2xk+1+1= -6+2*2 +1 =-1 – Symmetric pixels:(10, 2),(-2,10) ,(-10,2), (-2,-10), (-10,-2),(2, -10),(10, -2) – Here circle center is at origin so directly plot the symmetric pixels – x< y is true so continue 70By: Tekendra Nath Yogi2/9/2019
  • 71. Contd…. • Iteration 2: – Xk = x2= 2 – Yk= y2= 10 – Pk= p2= -1 – Here pk< 0 is true – So, next point is (xk+1, yk) = (2+1, 10) = (3, 10) – Now pk+1= pk + 2xk+1+1= -1+2*3+1 =6 – Symmetric pixels:(10, 3), (-10, 3), (-3, 10), (-3, -10), (-10, -3), (3, -10), (10, - 3) – Here circle center is at origin so directly plot the symmetric pixels – x< y is true so continue 71By: Tekendra Nath Yogi2/9/2019
  • 72. Contd…. • Iteration 3: – Xk = x3= 3 – Yk= y3= 10 – Pk= p3= 6 – Here pk< 0 is false – So, next point is (xk+1, yk -1) = (3+1, 10-1) = (4, 9) – Now pk+1= pk + 2xk+1+1 – 2yk+1= 6+ 2*4 +1 – 2*9 = -3 – Symmetric pixels: (9,4), (-4, 9), (-9,4), (-4, -9), (-9, -4), (4, -9), (9, 4) – Here circle center is at origin so directly plot the symmetric pixels – x< y is true so continue 72By: Tekendra Nath Yogi2/9/2019
  • 73. Contd…. • Iteration 4: – Xk = x4= 4 – Yk= y4= 9 – Pk= p4= -3 – Here pk< 0 is true – So, next point is (xk+1, yk) = (4+1, 9) = (5,9) – Now pk+1= pk + 2xk+1+1= -3+2*5+1 =8 – Symmetric pixels: (9,5), (-5,9), (-9,5), (-5, -9), (-9, -5), (5, -9), (9,-5) – Here circle center is at origin so directly plot the symmetric pixels – x< y is true so continue 73By: Tekendra Nath Yogi2/9/2019
  • 74. Contd…. • Iteration 5: – Xk = x5= 5 – Yk= y5= 9 – Pk= p5= 8 – Here pk< 0 is false – So, next point is (xk+1, yk -1) = (5+1, 9-1) = (6, 8) – Now pk+1= pk + 2xk+1+1 – 2yk+1= 8+ 2*6 +1 – 2*8 = 5 – Symmetric pixels:(8,6), (-6,8), (-8,6) , (-6,-8), (-8, -6), (6, -8), (8, -6) – Here circle center is at origin so directly plot the symmetric pixels – x< y is true so continue 74By: Tekendra Nath Yogi2/9/2019
  • 75. Contd…. • Iteration 6: – Xk = x6= 6 – Yk= y6= 8 – Pk= p6= 5 – Here pk< 0 is false – So, next point is (xk+1, yk -1) = (6+1, 8-1) = (7, 7) – Now pk+1= pk + 2xk+1+1 – 2yk+1= 5+ 2*7 +1 – 2*7 = 6 – Symmetric pixels: (7,7), (-7,7) (-7, 7), (-7, -7), (-7, -7),(7, -7) (7, -7) – Here circle center is at origin so directly plot the symmetric pixels – x< y is false so terminate ! 75By: Tekendra Nath Yogi2/9/2019
  • 76. Homework • Example1: Draw a circle with center at (2,3) and radius 8 using midpoint circle drawing algorithm. (Note: pixel = (x+xc, y+yc) • Example2: Draw a circle with center at (3,3) and radius 4 using midpoint circle drawing algorithm. (Note: pixel = (x+xc, y+yc) • Example3: Draw a circle with center at (3,5) and radius 10 using midpoint circle drawing algorithm. (Note: pixel = (x+xc, y+yc) 76By: Tekendra Nath Yogi2/9/2019
  • 81. Ellipse Generating Algorithm • Loosely stated: – Ellipse is an elongated circle. So, ellipse can be generated by modifying circle –drawing procedures. • A precise definition: – An ellipse is defined as the set of points such that the sum of the distances from two fixed positions(foci) is the same for all points. – i.e., d1+d2= constant for all point on the boundary of the ellipse 81By: Tekendra Nath Yogi2/9/2019
  • 82. Contd.. • let F1= (x1, y1) and F2= (x2, y2) and boundary point P(x, y) • Then d1 = and d2 = • So, 82By: Tekendra Nath Yogi2/9/2019         constant 2 2 2 2 2 1 2 1  yyxxyyxx
  • 83. Contd…. • Assumption for simplification: major and minor axes are oriented to align with the coordinate axes as shown in figure below. • For above ellipse, equation of the ellipse can be written as: • Problem: computational complexity! 83By: Tekendra Nath Yogi2/9/2019 1 22                  y c x c r yy r xx
  • 84. Contd…. • To reduce computational complexity symmetric property can be used. – An ellipse in standard position is symmetric between quadrants as shown in figure below: 84By: Tekendra Nath Yogi2/9/2019 (x,y) (x,-y) (-x,y) (-x,-y) rx ry
  • 85. Contd…. • Midpoint ellipse algorithm: – Given rx , ry and (xc, yc) – Midpoint ellipse algorithm first determine the boundary points (x, y) of the ellipse in standard position centered on the origin, and – Then shift the points so the ellipse is centered at (xc, yc) 85By: Tekendra Nath Yogi2/9/2019
  • 86. Contd…. • The midpoint ellipse algorithm started either at(0, ry) or at (rx, 0), and is applied throughout the first quadrant by taking unit steps in the x-direction where the slope of the curve has a magnitude less than 1(region1), and taking unit steps in the y- direction where the slope has a magnitude greater than 1(region2). 86By: Tekendra Nath Yogi2/9/2019
  • 87. Contd…. • Consider an ellipse centered at the origin, (xc,yc)=(0,0) then the ellipse equation becomes: • To apply the midpoint method Ellipse function is defined as: • For any point (x,y) – fe(x,y) < 0 if (x,y) is inside the ellipse – fe(x,y) = 0 if (x,y) is on the ellipse – fe(x,y) > 0 if (x,y) is outside the ellipse • Thus, the ellipse function serves as a decision Parameter in midpoint ellipse algorithm. 87By: Tekendra Nath Yogi2/9/2019 1 22                yx r y r x   222222 , yxxye rryrxryxf 
  • 88. Contd…. • Decision parameter at sampling position (xk+1) in region1: 88By: Tekendra Nath Yogi2/9/2019 Midpoint between candidate pixels at sampling position xK+ 1 along an elliptical path   22 2 222 2 1 2 1 )1( ,11 yxkxky kkek rryrxr yxfp         Decision: yk+1 = yk if p1k<0 , i.e., select pixel( xK+1,yk) to plot yk+1 = yk-1 otherwise, i.e., select pixel( xK+1,yk -1 ) to plot
  • 89. Contd…. • At the next sampling position (xk+1 + 1 = xk + 2), the decision parameter for region 1 is evaluated as where yk+1 is either yk or yk -1 depending on the sign of p1k. 89By: Tekendra Nath Yogi2/9/2019                                   22 1 222 1 22 2 1 222 2 1 111 2 1 2 1 )1(211 2 1 ]1)1[( ,11 kkxykykk yxkxky kkek yyrrxrpp or rryrxr yxfp
  • 90. Contd…. • where yk+1 is either yk or yk -1 depending on the sign of p1k. • So, successive decision parameter: • At the initial position (x0, y0)= (0, ry), the two terms evaluate to 2ry 2x = 0 ……. (i) & 2rx 2y = 2rx 2ry ……. (ii) • As x and y are incremented, updated values are obtained by adding 2ry 2 to (i) and subtracting 2rx 2 from (ii). 90By: Tekendra Nath Yogi2/9/2019       011 01 1 kk kk k pify pify y           01221 0121 1 22 1 2 2 1 2 1 kkxykyk kykyk k pifyrrxrp pifrxrp P
  • 91. Contd…. • Updated values are compared at each step, and we move from region 1 to region 2 when 2ry 2x >= 2rx 2y • In region 1, initial value of decision parameter is obtained by evaluating the ellipse function at the start position (x0, y0) = (0, ry): 91By: Tekendra Nath Yogi2/9/2019 222 0 22 2 22 0 0 4 1 1 2 1 1 2 1 ,11 xyxy yxyxy ye rrrrp or rrrrrp rfp               
  • 92. Contd…. • Decision parameter at sampling position (yk-1) in region2: – Over region 2, we sample at unit steps in the negative y direction, and the midpoint is now taken between horizontal pixels at each step. 92By: Tekendra Nath Yogi2/9/2019
  • 93. Contd…. • For region 2 the decision parameter is evaluated as 93By: Tekendra Nath Yogi2/9/2019     2222 2 2 2 1 1 2 1 1,2 yxkxky kkek rryrxr yxfp         Decision: xk+1 = xk if p2k > 0 , i.e., select pixel( xK,yk-1) to plot xk+1 = xk+1 otherwise, i.e., select pixel( xK+1,yk -1 ) to plot
  • 94. Contd…. • At the next sampling position (yk+1 - 1 = yk - 2), the decision parameter for region 2 is evaluated as: • where xk+1 is set either to xk or to xk+1depending on the sign of p2k. 94By: Tekendra Nath Yogi2/9/2019                                   22 1 222 1 2222 2 1 2 12 1 11 2 1 2 1 )1(222 ]1)1[( 2 1 1,2 kkyxkxkk yxkxky kkek xxrryrpp or rryrxr yxfp
  • 95. Contd…. • where xk+1 is set either to xk or to xk+1depending on the sign of p2k. – If p2k > 0, next point is (xk, yk-1) and – else, next point is (xk+1, yk-1) and 95By: Tekendra Nath Yogi2/9/2019 2 1 2 1 222 xkxkk ryrpp   2 1 2 1 2 1 2222 xkxkykk ryrxrpp  
  • 96. Contd…. • In region 2, initial value of decision parameter is obtained by evaluating the ellipse function at the initial position (x0, y0) that is the last position selected in region 1 96By: Tekendra Nath Yogi2/9/2019   222 0 2 2 0 2 0 000 1 2 1 2 1, 2 1 2 yxxy e rryrxrp yxfp              
  • 97. Midpoint Ellipse Algorithm 1. Input rx, ry and ellipse center (xc, yc). Obtain the first point on an ellipse centered on the origin (0, 0), (x0, y0) = (0, ry). 1. Calculate initial value for decision parameter in region 1 as: 2 4 122 01 xyxy rrrrp 
  • 98. Midpoint Ellipse Algorithm 3. At each xk in region 1, starting from k = 0, test p1k : If p1k < 0, next point (xk+1, yk) and else, next point (xk+1, yk-1) and with 2ry 2xk+1 = 2ry 2xk + 2ry 2, 2rx 2yk+1 = 2rx 2yk – 2rx 2 and repeat step 3 until 2ry 2x  2rx 2y 2 1 2 1 211 ykykk rxrpp   2 1 2 1 2 1 2211 ykxkykk ryrxrpp  
  • 99. Midpoint Ellipse Algorithm 4. Calculate the initial value for decision parameter in region 2 using the last point calculated in region 1 as: where (x0, y0) is the last position calculate in region 1 5. At each yk in region 2, starting from k = 0, test p2k: If p2k > 0, next point is (xk, yk-1) and else, next point is (xk+1, yk-1) and continue until y=0 2 1 2 1 222 xkxkk ryrpp       222 0 22 2 1 0 2 0 12 yxxy rryrxrp  2 1 2 1 2 1 2222 xkxkykk ryrxrpp  
  • 100. Midpoint Ellipse Algorithm 6. For both region determine symmetry points in the other 3 quadrants 7. Move each calculated pixel position (x,y) onto the elliptical path centered on (xc,yc) and plot the coordinate values x=x + xc, y =y + yc
  • 101. Example •Digitize an ellipse with center (0,0) and x-radius (rx )=8 and y- radius (ry)=6, using the midpoint ellipse algorithm. •For region 1: –Initial point for ellipse centered at origin is (x0, y0) =(0, ry)= (0, 6) 2ry 2x = 0 and 2rx 2ry = 768 p10 = ? –The initial value of decision parameter is: 102By: Tekendra Nath Yogi2/9/2019 3321 2 4 122 0  xyxy rrrrp
  • 102. Contd…. • Successive decision parameter values and positions along the ellipse path are calculated using the midpoint method as: 103By: Tekendra Nath Yogi2/9/2019 k p1k (xk+1,yk+1) 2ry 2 xk+1 2 rx 2yk+1 0 -332 (1,6) 72 768 1 2 3 4 5 6
  • 103. Contd…. 104By: Tekendra Nath Yogi2/9/2019 k p1k (xk+1,yk+1) 2ry 2 xk+1 2 rx 2yk+1 0 -332 (1,6) 72 768 1 -224 (2,6) 144 768 2 -44 (3,6) 216 768 3 208 (4,5) 288 640 4 -108 (5,5) 360 640 5 288 (6,4) 432 512 6 244 (7,3) 504 384
  • 104. Contd…. • For region 2, initial point is (x0, y0) = (7, 3), and initial decision parameter is : • The remaining pixels along the elliptical path in the first quadrant are then calculated as: • Now stop calculation, since y= 0 . 105By: Tekendra Nath Yogi2/9/2019   23)2,7(1,2 2 1 2 1  ekkek fyxfp k p2k (xk+1,yk+1) 2rv 2 xk+1 2 rx 2yk+1 0 -23 (8, 2) 576 256 1 361 (8, 1) 576 128 2 297 (8, 0) ---- ----
  • 106. Contd…. • Symmetric point calculation: – For (0, 6) : (0, 6), (0, -6), (0, -6) – For (1,6) : (-1, 6), (-1,-6), (1, -6) – For (2,6): (-2,6), (-2, -6), (2,-6) – For (3,6): (-3,6), (-3, -6), (3, -6) – For(4,5): (-4, 5), (-4,-5) (4,-5) – For (5, 5): (-5,5), (-5,-5) (5,-5) – For (6,4):(-6,4) (-6,-4) (6,-4) – For (7,3): (-7,3), (-7,-3), (7,-3) – For (8,2):(-8,2), (-8,-2), (8,-2) – For (8,1): (-8,1), (-8,-1), (8,-1) – For (8,0): (-8,0), (-8,0), (8,0) 107By: Tekendra Nath Yogi2/9/2019
  • 107. Homework • Example2: Digitize an ellipse with rx=8 and ry=6, and centered at (2,3) using the midpoint ellipse algorithm. • Example 3: Digitize an ellipse with center (20, 20) and x- radius= 8 and y-radius= 6. 108By: Tekendra Nath Yogi2/9/2019
  • 108. Midpoint Ellipse algorithm implementation 109By: Tekendra Nath Yogi2/9/2019
  • 112. Thank You ! 113By: Tekendra Nath Yogi2/9/2019