SlideShare a Scribd company logo
Bresenham’s Line Algorithm
.
2
of
13
The Problem (cont…)
What happens when we try to draw this on a
pixel based display?
How do we choose which pixels to turn on?
3
of
13
In Bresenham’s line drawing algorithm the
incremental integer calculations are used to
scan convert the lines, so that, the circles
and the other curves can be displayed.
?
? ?
?
4
of
13
.The next sample positions can be plotted
either at (3,2) or (3,3) ?
?
? ?
?
(2,2) (3,2)
(3,3)
5
of
13
6
of
13
For lines with positive slope m<1
The pixel positions on line can be identified by
doing sampling at unit x intervals.
The process of sampling begins from the pixel
position (X0,Y0) and proceeds by plotting the
pixels whose ‘Y’ value is nearest to the line path.
If the pixel to be displayed occurs at a position
(Xk, Yk) then the next pixel is either at (Xk+1,Yk) or
(Xk+1,Yk+1) i.e, (3,2) or (3,3)
 The ‘Y’ coordinate at the pixel position Xk+1
can be obtained from
Y=m(Xk+1)+b . . . . . . . . . . ……. eq 1
7
of
13
the separation between (Xk+1,Yk) and (Xk+1,Y) is d1 and the
separation between (Xk+1,Y) and (Xk+1, Yk+1) is d2 then
d1 = y – yk and
d2 = (Yk+1) – Y .
(Xk, yk)
(Xk, yk+1) (Xk+1, yk+1)
(Xk+1,yk)
P0 d1
d2
8
of
13
Y=m(Xk+1)+b . . . . . . . ……. eq 1
d1=y – yk
d1=m(xk+1)+b – Yk ( from eqn (1) …..( 2)
And d2= (Yk+1) – Y
=(YK+1) – [m(Xk+1)+b]
=(YK+1) – m(Xk+1) – b …….(3)
The difference is given as
d1-d2 =
= m(Xk+1)+b-Yk-[(Yk+1)-m(Xk+1)-b]
=m(Xk+1)+b-Yk-(Yk+1)+m(Xk+1)+b
d1-d2 = 2m(X +1)-2Y +2b – 1 ………(4)
9
of
13
Contd..
A decision parameter Pk can be obtained by substituting m= dy/dx in equation 4
d1 – d2 = 2m(Xk+1)-2Yk+2b – 1
= 2 dy/dx (Xk+1) – 2Yk + 2b – 1
= 2 dy(Xk+1)-2 dx.Yk + 2b.dx -dx
dx
dx(d1-d2) = 2 dy(Xk+1)-2 dx.Yk + 2b.dx - dx
= 2 dyXk+2 dy-2 dx.Yk + 2b.dx -dx
= 2 dyXk- 2 dx.Yk + c
Where, dx(d1-d2) = Pk and
c= 2 dy+ dx(2b-1)
Pk = 2 dyXk- 2 dx.Yk + c . . . . . . . . . . . . . . . . . . . … …(5 )
The value of c is constant and is independent of the pixel position. It can be
deleted in the recursive calculations, of for Pk
if d1 < d2 (i.e, Yk is nearer to the line path than Yk+1) then, Pk is negative.
If Pk is –ve, a lower pixel (Yk)is plotted else, an upper pixel (Yk+1)is plotted.
At k+1 step, the value of Pk is given as
PK+1 = 2 dyXk+1- 2 dx.Yk+1 + c …………………………………..(6 ) (from 5)
10
of
13
(X0, y0)
(X0, y0+1) (X0+1, y0+1)
(X0+1,y0)
P0 d1
d2
y=mx+c is the eq of line
In col 2 the line is passing through x0+1 so the y
value is given by
y=m(x0+1)+c (green dot)
Now we need to find out the values of d1 and d2
d1= y-y0
d2=(y0+1)-y
d1=m(x0+1) – y0 and d2= (y0+1) - m(x0+1)
d1-d2=[mx0+m – y0] - [(y0+1) - mx0-m]
=mx0+m – y0 - y0-1 + mx0+m
= 2mx0+2m –2y0-1
= 2mx0+2m –2mx0-1 (y=mx+c passes thr
(x0, y0) so we can say y0=mx0+c)
d1-d2 = 2mx0+2m –2mx0-1
d1-d2=2m-1 ( m= ∆y / ∆x)
d1-d2 = 2∆y/ ∆x - 1
Col 1 Col 2
∆x(d1-d2) = 2∆y - ∆x∆x(d1-d2) = 2∆y - ∆x
11
of
13
Bresenham’s algorithm
Step 1: Enter the 2 end points for a line and store the left
end point in (X0,Y0).
Step 2: Plot the first point be loading (X0,Y0) in the frame buffer.
Setp 3: determine the initial value of the decision parameter by
calculating the constants dx, dy, 2dy and 2dy-2dx as
P0 = 2dy –dx
Step 4: for each Xk, conduct the following test, starting from k= 0
If Pk <0, then the next point to be plotted is at (Xk+1, Yk) and
Pk+1 = Pk + 2dy
Else, the next point is (Xk+1, Yk+1) and
Pk+1 = Pk + 2dy –2dx (step 3)
Step 5: iterate through step (4) dx times.
12
of
13
Task
Let the given end points for the line be (30,20) and (40, 28)
Track the line using Bresenham Algortithm.
13
of
13
The starting point (x0, y0)=(30,20) and the
successive pixel positions are given in the following
table
K Pk (Xk+1, Yk+1)
0 6 (31,21)
1 2 (32,22
2 -2 33,22
3 14 34,23
4 10 35,24
5 6 36,25
6 2 37,26
7 -2 38,26
8 14 39,27
14
of
13
End points (30,20) (40,28)
dx=x2-x1=40-30=10 dy= y2-y1=28-20=8
P0=2dy-dx=2X8-10 = 6 >0 pt(31,21)
Pk+1= pk+2dy-2dx= 6+16-20 =2 >0 (32,22)
Pk+1=2+16-20 =-2 <0 (33,22)
Pk+1= pk+2dy =-2+16 = 14 >0 (34,23)
Pk+1= pk+2dy-2dx=14+16-20=10>0 (35,24)
Pk+1=10+16-20=6 >0 (36,25)
Pk+1= 6+16-20=2>0 (37,26)
Pk+1=2+16-20=-2 <0 (38,26)
Pk+1= pk+2dy=-2+16=14>0 (39,27)
Pk+1=pk+2dy-2dx= 14+16-20=10>0 (40,28)
15
of
13
Advantages of Bresenham’s Alg.
It uses only integer calculations
So, it is faster than DDA

More Related Content

What's hot

Computer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithmComputer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithm
Ruchi Maurya
 
Dda algo notes
Dda algo notesDda algo notes
Dda algo notes
shreeja asopa
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
Mani Kanth
 
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Saikrishna Tanguturu
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
Mahesh Kodituwakku
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.Mohd Arif
 
BRESENHAM’S LINE DRAWING ALGORITHM
BRESENHAM’S  LINE DRAWING ALGORITHMBRESENHAM’S  LINE DRAWING ALGORITHM
BRESENHAM’S LINE DRAWING ALGORITHM
St Mary's College,Thrissur,Kerala
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
Mani Kanth
 
DDA algorithm
DDA algorithmDDA algorithm
DDA algorithm
Yash Patel
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsThirunavukarasu Mani
 
Cs580
Cs580Cs580
Circle algorithm
Circle algorithmCircle algorithm
Circle algorithm
Pooja Dixit
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygonsaa11bb11
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiion
MuhammadHamza401
 
Unit 3
Unit 3Unit 3
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
Kumar
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing Algorithm
Mrinmoy Dalal
 

What's hot (19)

Computer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithmComputer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithm
 
Dda algo notes
Dda algo notesDda algo notes
Dda algo notes
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.
 
BRESENHAM’S LINE DRAWING ALGORITHM
BRESENHAM’S  LINE DRAWING ALGORITHMBRESENHAM’S  LINE DRAWING ALGORITHM
BRESENHAM’S LINE DRAWING ALGORITHM
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 
DDA algorithm
DDA algorithmDDA algorithm
DDA algorithm
 
Bresenham circle
Bresenham circleBresenham circle
Bresenham circle
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Cs580
Cs580Cs580
Cs580
 
Circle algorithm
Circle algorithmCircle algorithm
Circle algorithm
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygons
 
Line circle draw
Line circle drawLine circle draw
Line circle draw
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiion
 
Unit 3
Unit 3Unit 3
Unit 3
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing Algorithm
 

Viewers also liked

Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
Two dimensional geometric transformation
Two dimensional geometric transformationTwo dimensional geometric transformation
Two dimensional geometric transformation
japan vasani
 
dda algorithm
dda  algorithmdda  algorithm
dda algorithm
774474
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Advanced Computer Aided Design ACAD
Advanced Computer Aided Design ACADAdvanced Computer Aided Design ACAD
Advanced Computer Aided Design ACAD
Jordi Torner
 
Two dimentional transform
Two dimentional transformTwo dimentional transform
Two dimentional transform
Patel Punit
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
Kasun Ranga Wijeweera
 
Introduction to CAD/CAM
Introduction to CAD/CAMIntroduction to CAD/CAM
Introduction to CAD/CAM
DINBANDHU SINGH
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
Kamal Acharya
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformationsMohammad Sadiq
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformationsMohd Arif
 

Viewers also liked (13)

Lect14 lines+circles
Lect14 lines+circlesLect14 lines+circles
Lect14 lines+circles
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Two dimensional geometric transformation
Two dimensional geometric transformationTwo dimensional geometric transformation
Two dimensional geometric transformation
 
dda algorithm
dda  algorithmdda  algorithm
dda algorithm
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
 
Advanced Computer Aided Design ACAD
Advanced Computer Aided Design ACADAdvanced Computer Aided Design ACAD
Advanced Computer Aided Design ACAD
 
Two dimentional transform
Two dimentional transformTwo dimentional transform
Two dimentional transform
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
Introduction to CAD/CAM
Introduction to CAD/CAMIntroduction to CAD/CAM
Introduction to CAD/CAM
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformations
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformations
 

Similar to Lab lecture 2 bresenham

Computer graphics LINE DRAWING algorithm.pptx
Computer graphics LINE DRAWING algorithm.pptxComputer graphics LINE DRAWING algorithm.pptx
Computer graphics LINE DRAWING algorithm.pptx
R S Anu Prabha
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
PrathimaBaliga
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
SanthiNivas
 
Lect3 bresenham circlesandpolygons
Lect3 bresenham circlesandpolygonsLect3 bresenham circlesandpolygons
Lect3 bresenham circlesandpolygons
BCET
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
NaveenaKarthik3
 
Lecture-4-Scan_Conversion_Bresenhams_Algorithm.ppt
Lecture-4-Scan_Conversion_Bresenhams_Algorithm.pptLecture-4-Scan_Conversion_Bresenhams_Algorithm.ppt
Lecture-4-Scan_Conversion_Bresenhams_Algorithm.ppt
KhondokarMdMehediHas
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
Muhammad Fiaz
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
2013901097
 
Computer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipseComputer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipse
Hisham Al Kurdi, EAVA, DMC-D-4K, HCCA-P, HCAA-D
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
Amol Gaikwad
 
Unit 2
Unit 2Unit 2
Unit 2
ypnrao
 
Point Collocation Method used in the solving of Differential Equations, parti...
Point Collocation Method used in the solving of Differential Equations, parti...Point Collocation Method used in the solving of Differential Equations, parti...
Point Collocation Method used in the solving of Differential Equations, parti...
Suddhasheel GHOSH, PhD
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
KimTaehyung188352
 
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptxdddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
SubramaniyanChandras1
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
nehrurevathy
 
Shape drawing algs
Shape drawing algsShape drawing algs
Shape drawing algs
MusawarNice
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
IndhuMcamphil
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
Alamelu
 
Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.ppt
AliZaib71
 

Similar to Lab lecture 2 bresenham (20)

Computer graphics LINE DRAWING algorithm.pptx
Computer graphics LINE DRAWING algorithm.pptxComputer graphics LINE DRAWING algorithm.pptx
Computer graphics LINE DRAWING algorithm.pptx
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Lect3 bresenham circlesandpolygons
Lect3 bresenham circlesandpolygonsLect3 bresenham circlesandpolygons
Lect3 bresenham circlesandpolygons
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
 
Lecture-4-Scan_Conversion_Bresenhams_Algorithm.ppt
Lecture-4-Scan_Conversion_Bresenhams_Algorithm.pptLecture-4-Scan_Conversion_Bresenhams_Algorithm.ppt
Lecture-4-Scan_Conversion_Bresenhams_Algorithm.ppt
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
Computer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipseComputer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipse
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
 
Unit 2
Unit 2Unit 2
Unit 2
 
Point Collocation Method used in the solving of Differential Equations, parti...
Point Collocation Method used in the solving of Differential Equations, parti...Point Collocation Method used in the solving of Differential Equations, parti...
Point Collocation Method used in the solving of Differential Equations, parti...
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
 
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptxdddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
dddddddddddddddddddddddddddddddddddddddddddddddddddddAlgorithm.pptx
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
Shape drawing algs
Shape drawing algsShape drawing algs
Shape drawing algs
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
 
Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.ppt
 

Recently uploaded

Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
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
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
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
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
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
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
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
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 

Recently uploaded (20)

Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
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...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
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
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
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
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
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
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 

Lab lecture 2 bresenham

  • 2. 2 of 13 The Problem (cont…) What happens when we try to draw this on a pixel based display? How do we choose which pixels to turn on?
  • 3. 3 of 13 In Bresenham’s line drawing algorithm the incremental integer calculations are used to scan convert the lines, so that, the circles and the other curves can be displayed. ? ? ? ?
  • 4. 4 of 13 .The next sample positions can be plotted either at (3,2) or (3,3) ? ? ? ? ? (2,2) (3,2) (3,3)
  • 6. 6 of 13 For lines with positive slope m<1 The pixel positions on line can be identified by doing sampling at unit x intervals. The process of sampling begins from the pixel position (X0,Y0) and proceeds by plotting the pixels whose ‘Y’ value is nearest to the line path. If the pixel to be displayed occurs at a position (Xk, Yk) then the next pixel is either at (Xk+1,Yk) or (Xk+1,Yk+1) i.e, (3,2) or (3,3)  The ‘Y’ coordinate at the pixel position Xk+1 can be obtained from Y=m(Xk+1)+b . . . . . . . . . . ……. eq 1
  • 7. 7 of 13 the separation between (Xk+1,Yk) and (Xk+1,Y) is d1 and the separation between (Xk+1,Y) and (Xk+1, Yk+1) is d2 then d1 = y – yk and d2 = (Yk+1) – Y . (Xk, yk) (Xk, yk+1) (Xk+1, yk+1) (Xk+1,yk) P0 d1 d2
  • 8. 8 of 13 Y=m(Xk+1)+b . . . . . . . ……. eq 1 d1=y – yk d1=m(xk+1)+b – Yk ( from eqn (1) …..( 2) And d2= (Yk+1) – Y =(YK+1) – [m(Xk+1)+b] =(YK+1) – m(Xk+1) – b …….(3) The difference is given as d1-d2 = = m(Xk+1)+b-Yk-[(Yk+1)-m(Xk+1)-b] =m(Xk+1)+b-Yk-(Yk+1)+m(Xk+1)+b d1-d2 = 2m(X +1)-2Y +2b – 1 ………(4)
  • 9. 9 of 13 Contd.. A decision parameter Pk can be obtained by substituting m= dy/dx in equation 4 d1 – d2 = 2m(Xk+1)-2Yk+2b – 1 = 2 dy/dx (Xk+1) – 2Yk + 2b – 1 = 2 dy(Xk+1)-2 dx.Yk + 2b.dx -dx dx dx(d1-d2) = 2 dy(Xk+1)-2 dx.Yk + 2b.dx - dx = 2 dyXk+2 dy-2 dx.Yk + 2b.dx -dx = 2 dyXk- 2 dx.Yk + c Where, dx(d1-d2) = Pk and c= 2 dy+ dx(2b-1) Pk = 2 dyXk- 2 dx.Yk + c . . . . . . . . . . . . . . . . . . . … …(5 ) The value of c is constant and is independent of the pixel position. It can be deleted in the recursive calculations, of for Pk if d1 < d2 (i.e, Yk is nearer to the line path than Yk+1) then, Pk is negative. If Pk is –ve, a lower pixel (Yk)is plotted else, an upper pixel (Yk+1)is plotted. At k+1 step, the value of Pk is given as PK+1 = 2 dyXk+1- 2 dx.Yk+1 + c …………………………………..(6 ) (from 5)
  • 10. 10 of 13 (X0, y0) (X0, y0+1) (X0+1, y0+1) (X0+1,y0) P0 d1 d2 y=mx+c is the eq of line In col 2 the line is passing through x0+1 so the y value is given by y=m(x0+1)+c (green dot) Now we need to find out the values of d1 and d2 d1= y-y0 d2=(y0+1)-y d1=m(x0+1) – y0 and d2= (y0+1) - m(x0+1) d1-d2=[mx0+m – y0] - [(y0+1) - mx0-m] =mx0+m – y0 - y0-1 + mx0+m = 2mx0+2m –2y0-1 = 2mx0+2m –2mx0-1 (y=mx+c passes thr (x0, y0) so we can say y0=mx0+c) d1-d2 = 2mx0+2m –2mx0-1 d1-d2=2m-1 ( m= ∆y / ∆x) d1-d2 = 2∆y/ ∆x - 1 Col 1 Col 2 ∆x(d1-d2) = 2∆y - ∆x∆x(d1-d2) = 2∆y - ∆x
  • 11. 11 of 13 Bresenham’s algorithm Step 1: Enter the 2 end points for a line and store the left end point in (X0,Y0). Step 2: Plot the first point be loading (X0,Y0) in the frame buffer. Setp 3: determine the initial value of the decision parameter by calculating the constants dx, dy, 2dy and 2dy-2dx as P0 = 2dy –dx Step 4: for each Xk, conduct the following test, starting from k= 0 If Pk <0, then the next point to be plotted is at (Xk+1, Yk) and Pk+1 = Pk + 2dy Else, the next point is (Xk+1, Yk+1) and Pk+1 = Pk + 2dy –2dx (step 3) Step 5: iterate through step (4) dx times.
  • 12. 12 of 13 Task Let the given end points for the line be (30,20) and (40, 28) Track the line using Bresenham Algortithm.
  • 13. 13 of 13 The starting point (x0, y0)=(30,20) and the successive pixel positions are given in the following table K Pk (Xk+1, Yk+1) 0 6 (31,21) 1 2 (32,22 2 -2 33,22 3 14 34,23 4 10 35,24 5 6 36,25 6 2 37,26 7 -2 38,26 8 14 39,27
  • 14. 14 of 13 End points (30,20) (40,28) dx=x2-x1=40-30=10 dy= y2-y1=28-20=8 P0=2dy-dx=2X8-10 = 6 >0 pt(31,21) Pk+1= pk+2dy-2dx= 6+16-20 =2 >0 (32,22) Pk+1=2+16-20 =-2 <0 (33,22) Pk+1= pk+2dy =-2+16 = 14 >0 (34,23) Pk+1= pk+2dy-2dx=14+16-20=10>0 (35,24) Pk+1=10+16-20=6 >0 (36,25) Pk+1= 6+16-20=2>0 (37,26) Pk+1=2+16-20=-2 <0 (38,26) Pk+1= pk+2dy=-2+16=14>0 (39,27) Pk+1=pk+2dy-2dx= 14+16-20=10>0 (40,28)
  • 15. 15 of 13 Advantages of Bresenham’s Alg. It uses only integer calculations So, it is faster than DDA