0% found this document useful (0 votes)
10 views

Breshham Line Drawing Algorithm

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Breshham Line Drawing Algorithm

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Bresenham’s Line

Algorithm
Bresenham’s Line Algorithm
 A highly efficient incremental
method for scan converting lines.
 Using only incremental integer
calculation.
By testing the sign of an
integer parameter, whose
value is proportional to the
difference between the
separation of two pixel
positions from the actual
line path.
Bresenham’s Line Algorithm
 A highly efficient incremental
method for scan converting lines.
 Using only incremental integer
calculation.
By testing the sign of an
integer parameter, whose
value is proportional to the
difference between the
separation of two pixel
positions from the actual
line path.
Bresenham’s Line Algorithm
Bresenham’s Line Algorithm
Bresenham’s Line Algorithm

yk+1
} d2
y
}d 1

yk

xk+1
Bresenham’s Line Algorithm
d1 = y - yk = m (xk + 1) + b - yk
d2 = (yk + 1) - y = yk + 1 - m (xk + 1) –b
d1 - d2 = 2 m (xk + 1) - 2 yk + 2b -1
Bresenham’s Line Algorithm

Pk = ∆X ( d1 - d2) =
2 ∆Y . xk - 2 ∆X . yk + c

c = constante = 2 ∆Y + ∆X (2b -1)


Let's get rid of multiplications
Pk+1 = 2 ∆Y . xk+1 - 2 ∆X .y + c
Pk+1 - Pk = 2 ∆Y (xk+1 - xk) -2 ∆X (yk+1 - yk)
(get rid of the constance)
Pk+1 = Pk + 2 ∆Y - 2 ∆X (yk+1 - yk)

Pk+1 = Pk + 2∆Y
or
= Pk + 2(∆Y – ∆X)
with (yk+1 - yk) = 0 or 1 depending on Pk sign
Bresenham’s Line Algorithm

P0 =∆X (d1-d2)
=∆X[2m(x0+1)-2y0+2b-1]
=∆X[2(mx0+b-y0)+2m-1]
m=∆y/x

0
P0=2∆Y -∆X
Bresenham’s Line Algorithm
 Example: Digitize the line with endpoint
(20,10) and (30,18) P0=2∆Y –∆X
∆XX=10 ∆YY= 8 Pk+1 = Pk + 2∆Y
P0=2∆YY –∆x=
x=6
x=6 or
2∆YY =16 = Pk + 2(∆Y – ∆X)
2(∆YY – ∆XX)=-
)=-4
Bresenham algorithm: summary
• Several good ideas:
– use of symmetry to reduce complexity
– choice limited to two pixels
– error function for choice criterion
– stay in integer arithmetics
• Very straightforward:
– good for hardware implementation
– good for assembly language

You might also like