SlideShare a Scribd company logo
1 of 14
BRESENHAM’S
LINE DRAWING ALGORITHM
Rasmi M
Assistant Professor
Department of Computer Science and Applications
St. Mary’s College Thrissur
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
INTRODUCTION
 Developed by JackBresenham.
 Raster line-generating algorithm.
 Scan conversion takes place using only incremental
integercalculations.
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
 Accurate and efficient than DDA line drawing
algorithm.
 Guarantees connected (gap-less) lines where
each point is drawn exactly 1 time.
 Also known as the midpoint line algorithm.
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
 The computer has to select pixels to draw aline.
 It has to select two points and then draw aline between them.
 It also needs some parameters forcomputations.
 Groupof pixels look like a matrix having x and y axis.
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
P
 We need a decision parameter todecide which pixel tochoose.
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
 Starting from the left endpoint (x0,y0) of a given line, we step to
each successive column and plot the pixel whose scan-line y value
is close to the line path.
 At the sample position xk+1 the vertical separations from the
line are labelled dupper and dlower.
DERIVATION
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
 The y coordinate on the line at xk+1 is calculated as
y=(mx+c)
 We know that the slope m=Δy/Δx
 Then,
dlower= y-yk
dupper=(yk+1)-y
 Replacing the value of y ;
dlower=m(xk+1)+c-yk
dupper=(yk+1)-m(xk+1)-c
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
 Now we substract
dlower-dupper=2m(xk+1)-2yk+2c-1 .
Replacing m;
Δx(dlower-dupper)=Δx(2Δy/Δx(xk+1)-2yk+2c-1)
=2Δy.xk-2Δx.yk+b
(b=-2yk+2c-1)
 Pk is the decision parameter. So,
Pk =Δx (dlower-dupper)
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
 The sign of pk depends on dlower-dupper.
 If pk<0(-ve),then we choose the lowerpixel.
 If pk>0(+ve),then we choose the upperpixel.
 Pk determines which pixel is to bechoosen.
Now, for pk+1
pk+1=2Δy.xk+1-2Δx.yk+1+b
So,
pk+1-pk=2Δy(xk+1-xk)-2Δx(yk+1-yk)
pk+1=pk=2Δy-2Δx(yk+1-yk)
 The term yk+1-yk,is either 0 or 1depending upon the sign of the
parameterpk.
 The first decision parameter p0 is calculatedas
p0=2Δy-Δx
BRESENHAM’S LINE DRAWING
ALGORITHM
1. Input the two line endpoints and store the left end point in (x0,y0).
2. Load (x0,y0) into the frame buffer that is plot the first point.
3. Calculate the constants x,y,2Δy-2Δx and obtain the starting value
for the decision parameter as
p0=2Δy-Δx
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
4. At each xk ,along the line, starting atk=0, perform the
followingtest:
 If pk<0, the next point to plot is (xk+1,yk) and
pk+1=pk+2Δy
 Otherwise,the next point to plot is (xk+1,yk+1) and
pk+1=pk+2Δy-2Δx
5.Repeat step 4 Δx times.
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
EXAMPLE
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
REFERENCE
Donald Hearn and M Pauline Baker, Computer Graphics, PHI,
New Delhi.
2. Zhigang Xiang and Roy Plasock, Computer Graphics,
Schaum’s Outlines.
 3. Deborah Morley, Understanding Computer Today And
Tomorrow, Introductory Edition.
Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College

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 algorithmRuchi Maurya
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingArvind Kumar
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithmAparna Joshi
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithmPooja Dixit
 
Attributes of Output Primitives
Attributes of Output PrimitivesAttributes of Output Primitives
Attributes of Output PrimitivesRenita Santhmayora
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithmMani Kanth
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithmAnkit Garg
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversionMohd Arif
 
Random scan displays and raster scan displays
Random scan displays and raster scan displaysRandom scan displays and raster scan displays
Random scan displays and raster scan displaysSomya Bagai
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformationsMohd Arif
 
Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)shalinikarunakaran1
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output PrimitivesPrathimaBaliga
 
Raster Scan and Raster Scan Displays
Raster Scan and Raster Scan DisplaysRaster Scan and Raster Scan Displays
Raster Scan and Raster Scan DisplaysSaravana Priya
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.Mohd Arif
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmMani Kanth
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer GraphicsLaxman Puri
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clippingMdAlAmin187
 

What's hot (20)

Computer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithmComputer graphics - bresenham line drawing algorithm
Computer graphics - bresenham line drawing algorithm
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clipping
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
 
Attributes of Output Primitives
Attributes of Output PrimitivesAttributes of Output Primitives
Attributes of Output Primitives
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
 
Random scan displays and raster scan displays
Random scan displays and raster scan displaysRandom scan displays and raster scan displays
Random scan displays and raster scan displays
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformations
 
Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Halftoning in Computer Graphics
Halftoning  in Computer GraphicsHalftoning  in Computer Graphics
Halftoning in Computer Graphics
 
Raster Scan and Raster Scan Displays
Raster Scan and Raster Scan DisplaysRaster Scan and Raster Scan Displays
Raster Scan and Raster Scan Displays
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
DDA algorithm
DDA algorithmDDA algorithm
DDA algorithm
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 

Similar to Bresenham’s Line Drawing Algorithm Explained

Unit 2
Unit 2Unit 2
Unit 2ypnrao
 
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 algorithmsAmol Gaikwad
 
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.pptKhondokarMdMehediHas
 
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 dericationKumar
 
Bresenhems line Genration derivation for Mtech
Bresenhems line Genration derivation for MtechBresenhems line Genration derivation for Mtech
Bresenhems line Genration derivation for Mtechrahulkatre9
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsThirunavukarasu Mani
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentationLOKENDRA PRAJAPATI
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithmsMohammad Sadiq
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniyaTutorialsDuniya.com
 
Lect3 bresenham circlesandpolygons
Lect3 bresenham circlesandpolygonsLect3 bresenham circlesandpolygons
Lect3 bresenham circlesandpolygonsBCET
 
Lecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptLecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptGaganvirKaur
 

Similar to Bresenham’s Line Drawing Algorithm Explained (20)

Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
03.Scan Conversion.ppt
03.Scan Conversion.ppt03.Scan Conversion.ppt
03.Scan Conversion.ppt
 
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)
 
Unit 2
Unit 2Unit 2
Unit 2
 
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
 
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 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
 
Bresenhems line Genration derivation for Mtech
Bresenhems line Genration derivation for MtechBresenhems line Genration derivation for Mtech
Bresenhems line Genration derivation for Mtech
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentation
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
 
Computer graphics notes 2 tutorials duniya
Computer graphics notes 2   tutorials duniyaComputer graphics notes 2   tutorials duniya
Computer graphics notes 2 tutorials duniya
 
lecture 1.pptx
lecture 1.pptxlecture 1.pptx
lecture 1.pptx
 
Lect3 bresenham circlesandpolygons
Lect3 bresenham circlesandpolygonsLect3 bresenham circlesandpolygons
Lect3 bresenham circlesandpolygons
 
Lecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptLecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.ppt
 

More from St Mary's College,Thrissur,Kerala

More from St Mary's College,Thrissur,Kerala (20)

Creative writing and literature
Creative writing and literature Creative writing and literature
Creative writing and literature
 
Magnetic Tape
Magnetic TapeMagnetic Tape
Magnetic Tape
 
Online Data Storage
Online Data StorageOnline Data Storage
Online Data Storage
 
Mathematics:Cryptography
Mathematics:CryptographyMathematics:Cryptography
Mathematics:Cryptography
 
Mathematics:Arithmetical Functions
Mathematics:Arithmetical FunctionsMathematics:Arithmetical Functions
Mathematics:Arithmetical Functions
 
Physical education :Yoga For Stress Relief
Physical education :Yoga For Stress ReliefPhysical education :Yoga For Stress Relief
Physical education :Yoga For Stress Relief
 
Psychology:PAIN: Types, Theories and Assessment of pain
Psychology:PAIN: Types, Theories and  Assessment of pain Psychology:PAIN: Types, Theories and  Assessment of pain
Psychology:PAIN: Types, Theories and Assessment of pain
 
Economics:Functions
Economics:FunctionsEconomics:Functions
Economics:Functions
 
Mathematics:H-Complexity
Mathematics:H-ComplexityMathematics:H-Complexity
Mathematics:H-Complexity
 
Statistics:Probability Theory
Statistics:Probability TheoryStatistics:Probability Theory
Statistics:Probability Theory
 
Statistics:Fundamentals Of Statistics
Statistics:Fundamentals Of StatisticsStatistics:Fundamentals Of Statistics
Statistics:Fundamentals Of Statistics
 
Economics:Public Revenue
Economics:Public RevenueEconomics:Public Revenue
Economics:Public Revenue
 
Economics:Public Debt
Economics:Public  DebtEconomics:Public  Debt
Economics:Public Debt
 
Economics:Poverty-perspectives And Dimensions
Economics:Poverty-perspectives And DimensionsEconomics:Poverty-perspectives And Dimensions
Economics:Poverty-perspectives And Dimensions
 
Economics:Economic Integration
Economics:Economic IntegrationEconomics:Economic Integration
Economics:Economic Integration
 
Economics:Enviornmental Pollution
Economics:Enviornmental Pollution Economics:Enviornmental Pollution
Economics:Enviornmental Pollution
 
Computer Science:JavaScript
Computer Science:JavaScript Computer Science:JavaScript
Computer Science:JavaScript
 
Computer Science:Sql Set Operation
Computer Science:Sql Set OperationComputer Science:Sql Set Operation
Computer Science:Sql Set Operation
 
Computer Science:Java jdbc
Computer Science:Java jdbcComputer Science:Java jdbc
Computer Science:Java jdbc
 
Microbiology:General Principles of Food Preservation
Microbiology:General Principles of Food PreservationMicrobiology:General Principles of Food Preservation
Microbiology:General Principles of Food Preservation
 

Recently uploaded

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 

Recently uploaded (20)

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 

Bresenham’s Line Drawing Algorithm Explained

  • 1. BRESENHAM’S LINE DRAWING ALGORITHM Rasmi M Assistant Professor Department of Computer Science and Applications St. Mary’s College Thrissur
  • 2. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College INTRODUCTION  Developed by JackBresenham.  Raster line-generating algorithm.  Scan conversion takes place using only incremental integercalculations.
  • 3. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College  Accurate and efficient than DDA line drawing algorithm.  Guarantees connected (gap-less) lines where each point is drawn exactly 1 time.  Also known as the midpoint line algorithm.
  • 4. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College  The computer has to select pixels to draw aline.  It has to select two points and then draw aline between them.  It also needs some parameters forcomputations.  Groupof pixels look like a matrix having x and y axis.
  • 5. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College P  We need a decision parameter todecide which pixel tochoose.
  • 6. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College  Starting from the left endpoint (x0,y0) of a given line, we step to each successive column and plot the pixel whose scan-line y value is close to the line path.  At the sample position xk+1 the vertical separations from the line are labelled dupper and dlower. DERIVATION
  • 7. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College  The y coordinate on the line at xk+1 is calculated as y=(mx+c)  We know that the slope m=Δy/Δx  Then, dlower= y-yk dupper=(yk+1)-y  Replacing the value of y ; dlower=m(xk+1)+c-yk dupper=(yk+1)-m(xk+1)-c
  • 8. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College  Now we substract dlower-dupper=2m(xk+1)-2yk+2c-1 . Replacing m; Δx(dlower-dupper)=Δx(2Δy/Δx(xk+1)-2yk+2c-1) =2Δy.xk-2Δx.yk+b (b=-2yk+2c-1)  Pk is the decision parameter. So, Pk =Δx (dlower-dupper)
  • 9. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College  The sign of pk depends on dlower-dupper.  If pk<0(-ve),then we choose the lowerpixel.  If pk>0(+ve),then we choose the upperpixel.  Pk determines which pixel is to bechoosen. Now, for pk+1 pk+1=2Δy.xk+1-2Δx.yk+1+b So, pk+1-pk=2Δy(xk+1-xk)-2Δx(yk+1-yk) pk+1=pk=2Δy-2Δx(yk+1-yk)  The term yk+1-yk,is either 0 or 1depending upon the sign of the parameterpk.
  • 10.  The first decision parameter p0 is calculatedas p0=2Δy-Δx BRESENHAM’S LINE DRAWING ALGORITHM 1. Input the two line endpoints and store the left end point in (x0,y0). 2. Load (x0,y0) into the frame buffer that is plot the first point. 3. Calculate the constants x,y,2Δy-2Δx and obtain the starting value for the decision parameter as p0=2Δy-Δx Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
  • 11. 4. At each xk ,along the line, starting atk=0, perform the followingtest:  If pk<0, the next point to plot is (xk+1,yk) and pk+1=pk+2Δy  Otherwise,the next point to plot is (xk+1,yk+1) and pk+1=pk+2Δy-2Δx 5.Repeat step 4 Δx times. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
  • 12. EXAMPLE Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
  • 13. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College
  • 14. REFERENCE Donald Hearn and M Pauline Baker, Computer Graphics, PHI, New Delhi. 2. Zhigang Xiang and Roy Plasock, Computer Graphics, Schaum’s Outlines.  3. Deborah Morley, Understanding Computer Today And Tomorrow, Introductory Edition. Bresenham’s Line Drawing Algorithm, Rasmi M, St.Mary’s College