0% found this document useful (0 votes)
20 views6 pages

7814 Et ET

This module covers Bresenham’s Line drawing procedure, highlighting its advantages over the DDA procedure by avoiding floating point calculations for better line approximation. It explains the decision parameter used to determine the closest pixel to the theoretical line and provides recursive equations for calculating pixel positions based on line slopes. The algorithm is summarized for both cases of line slopes being less than or greater than one.
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)
20 views6 pages

7814 Et ET

This module covers Bresenham’s Line drawing procedure, highlighting its advantages over the DDA procedure by avoiding floating point calculations for better line approximation. It explains the decision parameter used to determine the closest pixel to the theoretical line and provides recursive equations for calculating pixel positions based on line slopes. The algorithm is summarized for both cases of line slopes being less than or greater than one.
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/ 6

MODULE - 3

e-PG Pathshala
Subject : Computer Science
Paper: Computer Graphics and Visualization
Module: Bresenham’s Line drawing procedure
Module No: CS/CGV/3
Quadrant 1 – e-text
Learning Objectives:

 Understand the theory behind Bresenham’s Line drawing procedure


 Prove the advantages of Bresenham’s procedure over DDA procedure
 Solve example problem for better understanding of the concepts

In this module, let’s focus on Bresenham’s line drawing procedure which is


superior to DDA procedure as this avoids floating point calculations and gives a
better approximation for the theoretical line.
Bresenham is a scientist and is popular for his contributions to line drawing and
circle drawing procedures, and few others, which are not of our interest.
Assume a line with slope <1, the same discussion that we had during DDA
procedure is still valid here, i.e. sample the line along x-axis at unit x-intervals if the
line slopes are <=1 otherwise sample the line along y-axis.

Let’s start our assumptions with a line whose slope <1 i.e. the line is more
inclined towards x-axis, so it is obvious to sample the line along x-axis at unit x-
intervals and compute the corresponding y values. Also that to compute next points
on a line, we always starts with a known point on the line and tries computing the
next unknown point on the line using recursive equations.
So the next x i.e. xk+1=xk+1 and the next y i.e. yk+1 is to be computed. Let the
known plotted point on the line be (xk,yk).

Before we get into the derivation lets understand the underlying principle of
Bresenham’s procedure. To compute the next point on the line (Xk+1, Yk+1), a value
called ‘decision parameter’ is computed. Based on the result a pixel is chosen for
plotting.
As shown in the figure above let the line shown be the theoretical line and we
need to find the best possible approximation for this by computing Bresenham’s line.
For the next X position, Xk+1, the corresponding Y value could not be plotted as the
position (Xk+1, y) does not exist on the monitor. We have to choose between Yk and
Yk+1. i.e. next position to be plotted is either (Xk+1, Yk) or (Xk+1, Yk+1). Now how do
we decide among the two choices. The answer is, compute the vertical difference
between the possible pixel position and the position on the true theoretical line which
is.
Let dlower be the vertical difference between the position (y) on theoretical line and
the lower pixel (yk) and dupper be the vertical difference between the position (y) on
theoretical line and the upper pixel (yk+1). As evident if dlower is < dupper the theoretical
line is closer to the lower pixel so choose position (Xk+1, Yk) otherwise choose
position. The difference between dlower and dupper is considered as ‘decision
parameter’, as the sign of the difference operation helps us decide what y coordinate
position is to be chosen for the next x.
 ‘Decision parameter’ referred to as pk helps us decide which of the pixels is to
be chosen
 Whichever pixel position is close to the theoretical line, that pixel is chosen.

i.e. next X is Xk+1 = Xk+1, and next Y is Yk+1=Yk or Yk+1 depending on the sign of pk.

Let’s derive those recursive equations of the Bresenham’s procedure. To start


with we use slope-intercept form of line equation. Having known the position (xk,yk)
on the line, the next x position would be xk+1. From the slope-intercept form of line
equation, for the next x position we have

Now compute dupper and dlower as

Substituting for y the first equation we get


Now replace m with and cross multiplying the terms with the equation we
have

In the above step it is interesting to observer that division due to dy/dx is avoided by
cross multiplying dy/dx with the equations

Where pk is Δx(dlower-dupper). And we know that Xk+1 = Xk+1. The above equation
reduces to

Because Δx(2C-1) is a constant with Δx and C being constants for a given line with
end points we can replace Δx(2C-1) with a constant say ‘b’.

Let Pk+1 be the next decision parameter. We do this to find a recursive relation
between Pk and Pk+1. i.e. wherever there is k replace that with k+1 in the previous
equation to obtain Pk+1

Now taking the difference between Pk and Pk+1 we get

Now the sign of Pk is to be checked.

Case(i):
If pk <=0 the lower pixel (Xk+1,Yk ) is to be plotted, i.e. next x is Xk+1 and next y is Yk.
Therefore yk+1=yk. Now the previous equation for Pk+1 reduces to

Case(ii):
If pk >0 the upper pixel (Xk+1,Yk+1) is to be plotted, Therefore next y, yk+1=yk+1 ,
now substituting for yk+1 in the equation for Pk+1 we get

The initial decision parameter p0 is computed as below (use the following eq.)

replace k with 0 and compute c as shown.


If the point on the theoretical line is equidistant from either of the possible pixel
locations then either of the pixels could be plotted.
Now the algorithm steps can be summarized as follows for the case when |m|<=1
 Input the two end points
 Compute P0
 Check cases depending on the sign of P0
 Continue with the next decision parameters till the end of the line is reached

All this is well only for lines with slopes <1. What about other line types?
Now let’s summarize the equations as below,

When |m|<=1

Case (i): If pk<=0 the lower pixel (Xk+1,Yk) is to be plotted

and
Case (ii): If pk>0 the upper pixel (Xk+1,Yk+1) is to be plotted
and

When |m|>1

The roles of X and y get reversed.

Case (i): If pk<=0 the lower pixel (Xk+1,Yk) is to be plotted


If pk<=0 the left pixel (Xk,Yk+1) is to be plotted
and

Case (ii): If pk>0 the right pixel (Xk+1,Yk+1) is to be plotted

and
 Compute absolute values of ∆x, ∆y

|m|<=1, (P0=2∆y-∆x) |m| >1, (P0=2∆x-∆y)

m Pk<=0 Pk>0 Pk<=0 Pk>0


+ve
Xk+1=Xk+1 Xk+1=Xk+1 Xk+1=Xk Xk+1=Xk+1

Yk+1=Yk Yk+1=Yk+1 Yk+1=Yk+1 Yk+1=Yk+1

P(Xk+1,Yk) P(Xk+1,Yk+1) P(Xk,Yk+1) P(Xk+1,Yk+1)

Pk+1=Pk+2∆y Pk+1=Pk+2∆y- Pk+1=Pk+2∆x Pk+1=Pk+2∆x-


2∆x 2∆y

m Pk<=0 Pk>0 Pk<=0 Pk>0

-ve Xk+1=Xk+1 Xk+1=Xk+1 Xk+1=Xk Xk+1=Xk+1

Yk+1=Yk Yk+1=Yk-1 Yk+1=Yk-1 Yk+1=Yk-1

P(Xk+1,Yk) P(Xk+1,Yk-1) P(Xk,Yk-1) P(Xk+1,Yk-1)

Pk+1=Pk+2∆y Pk+1=Pk+2∆y- Pk+1=Pk+2∆x Pk+1=Pk+2∆x-


2∆x 2∆y

Summary:

We have discussed the Bresenham’s line drawing procedure.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy