1. The document discusses raster graphics and algorithms for drawing basic 2D primitives like points, lines, circles, and polygons.
2. It describes two common line drawing algorithms - the Digital Differential Analyzer (DDA) algorithm and Bresenham's line algorithm.
3. The DDA algorithm draws lines by calculating pixel positions using the slope of the line, while Bresenham's algorithm uses only integer calculations to find the next pixel position along the line.
classification algorithms, decision tree, naive bayes, back propagation, KNN,TU, BIM 8th semester Data mining and data warehousing Slide by Tekendra Nath Yogi
classification algorithms, decision tree, naive bayes, back propagation, KNN,TU, BIM 8th semester Data mining and data warehousing Slide by Tekendra Nath Yogi
Cohen-Sutherland Line Clipping Algorithm:
When drawing a 2D line on screen, it might happen that one or both of the endpoints are outside the screen while a part of the line should still be visible. In that case, an efficient algorithm is needed to find two new endpoints that are on the edges on the screen, so that the part of the line that's visible can now be drawn. This way, all those points of the line outside the screen are clipped away and you don't need to waste any execution time on them.
A good clipping algorithm is the Cohen-Sutherland algorithm for this solution.
By,
Maruf Abdullah Rion
with today's advanced technology like photoshop, paint etc. we need to understand some basic concepts like how they are cropping the image , tilt the image etc.
In our presentation you will find basic introduction of 2D transformation.
This ppt's introduced Basics of computer graphics, which helps to diploma in computer engineering, DCA BCA, BE computer science student's to improve study in computer graphics.
At the end of this lesson, you should be able to;
describe the energy and the EM spectrum.
describe image acquisition methods.
discuss image formation model.
express sampling and quantization.
define dynamic range and image representation.
2015 course SPPU SEIT syllabus of subject Processor Architecture and Interfacing (PAI) This covers introduction to paging in 80386, Address Translation (Linear to physical), Page Level Protection,
Cohen-Sutherland Line Clipping Algorithm:
When drawing a 2D line on screen, it might happen that one or both of the endpoints are outside the screen while a part of the line should still be visible. In that case, an efficient algorithm is needed to find two new endpoints that are on the edges on the screen, so that the part of the line that's visible can now be drawn. This way, all those points of the line outside the screen are clipped away and you don't need to waste any execution time on them.
A good clipping algorithm is the Cohen-Sutherland algorithm for this solution.
By,
Maruf Abdullah Rion
with today's advanced technology like photoshop, paint etc. we need to understand some basic concepts like how they are cropping the image , tilt the image etc.
In our presentation you will find basic introduction of 2D transformation.
This ppt's introduced Basics of computer graphics, which helps to diploma in computer engineering, DCA BCA, BE computer science student's to improve study in computer graphics.
At the end of this lesson, you should be able to;
describe the energy and the EM spectrum.
describe image acquisition methods.
discuss image formation model.
express sampling and quantization.
define dynamic range and image representation.
2015 course SPPU SEIT syllabus of subject Processor Architecture and Interfacing (PAI) This covers introduction to paging in 80386, Address Translation (Linear to physical), Page Level Protection,
OpenGL (Open Graphics Library) is a cross-platform, hardware-accelerated, language-independent, industrial standard API for producing 3D (including 2D) graphics. Modern computers have dedicated GPU (Graphics Processing Unit) with its own memory to speed up graphics rendering.
Commonly a fixed area of the system memory is reserved for the frame buffer,
Video controller can direct access to the frame-buffer
Frame-buffer locations, and the corresponding screen positions, are referenced in Cartesian coordinates.
Some system employ lower-left corner as origin
But most common system employ upper-left corner as origin.
Scan lines are labeled from ymax, at the top of the screen to 0 at the bottom.
Along each scan line, screen pixel positions are labeled from 0 to xmax
It gives detailed description about Points, Lines, Attributes of Output Primitives, Line Functions, Line Drawing Algorithms, DDA Line drawing algorithms, Bresenham’s Line Algorithm, Circle Generating Algorthims
Notes for Mechanical and Computer science Students,
In the Notes Including the Basic to algo and transformation in Computer grafics Pixels, it is a important topic
This slide contain description about the line, circle and ellipse drawing algorithm in computer graphics. It also deals with the filled area primitive.
Similar to B. SC CSIT Computer Graphics Unit1.2 By Tekendra Nath Yogi (20)
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
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
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
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
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
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
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
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
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
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