Technical sectionDrawing lines by uniform packing
Introduction
Line is a very important primitive in computer graphics. Sometimes designs contain hundreds of lines that are to be refreshed or redrawn in a fraction of a second. This is why it is so important to draw these lines as efficiently as possible. This importance warranted development of a number of line algorithms. The first such algorithm was devised by Bresenham [1], [2] that avoided real numbers and division operations in computation for fast generation of line segments. Later on, Kappel [3] developed midpoint algorithm for drawing line segments. Parallel methods for generating lines have been discussed in Pang [4] and Wright [5]. In addition, a recursive bisection method was also developed in order to reduce computational complexity. But quality of line produced by this algorithm was inferior. This paper presents a new line-drawing algorithm for graphics systems based on the idea of uniform packing. Analysis shows that it is computationally more efficient than commonly used Bresenham's line drawing algorithm. The trade-off here is the slight degradation of the quality of lines drawn, measured in terms of quantitative measures such as the sum of squared errors of the plotted pixels, with respect to the mathematical line. Experimental results suggest that the sum of squared errors for our algorithm is quite comparable to that for Bresenham's algorithm, which produces probably minimum sum of squared errors.
Section snippets
Bresenham's algorithm
Bresenham developed an elegant line drawing algorithm in Ref. [1]. His algorithm uses only integer arithmetic and allows incremental calculations for finding next pixel coordinates. For lines with arbitrary real valued endpoint coordinates, a floating point version of the same algorithm can be adopted. Furthermore, Bresenham's incremental technique can be applied to integer computation of circles as well.
Pitteway [6] proposed a slightly different formulation of Bresenham's algorithm. This
New algorithm
If two consecutive pixels are put along the same horizontal line 1 unit apart, we define it to be a horizontal move. Similarly when two consecutive pixels are put along the diagonal of a unit square, we define it to be a diagonal move. Any straight line drawn on a computer display is a sequence of these two types of segments. The algorithm presented here depends on the idea of packing horizontal and diagonal moves uniformly.
We have considered only lines with slope from 0 to 1. The algorithm can
Time complexity analysis
To determine the number of iterations of the loop at line 3, we compare our algorithm with Euclid's algorithm for finding greatest common divisor(gcd). The recurrence for finding gcd of two numbers a and b where a ⩾ b is gcd(a,b)=gcd(b,a mod b).
It is known (see pp. 852–853 in Ref. [10]) that number of iterations to find the gcd using this recurrence is O(log b). In our algorithm, we have used the following recurrence to obtain our iterative implementation: line(h,d)=line(h – d mod h, d mod h).
Experimental results
Much of our experiments are dedicated to the comparison of our algorithm to the widely used Bresenham's algorithm both in terms of efficiency and quality of rendered lines.
Conclusion
We have introduced a new approach for line drawing that attempts to maintain a uniform packing density of horizontal segments and diagonal segments throughout the line. Experimental results show that the quality of lines drawn is comparable to the ones drawn by Bresenham's algorithm. Also, the computational effort in making decision as to the location of the pixels is logarithmic in number of segments in the line, rather than linear as in Bresenham's algorithm. However, the memory requirement
References (10)
Algorithm for computer control of a digital plotter
IBM Systems Journal
(1965)A Linear algorithm for incremental digital display of circular arcs
CACM
(1977)- Kappel M.R. An ellipse-drawing algorithm for faster displays. in: Fundamental algorithms for computer graphics,...
Line-drawing algorithms for parallel machines
IEEE Computer Graphics and Applications
(1990)Parallelization of bresenham's line and circle algorithms
IEEE Computer Graphics and Applications
(1990)
Cited by (6)
The design of a 2d graphics accelerator for embedded systems
2021, Electronics (Switzerland)A study of NURBS interpolation algorithm with limited chord error for EDM
2019, IEEE International Conference on Robotics and Biomimetics, ROBIO 2019Bresenham algorithm: Implementation and analysis in raster shape
2013, Journal of Computers (Finland)Study on the positioning of forestry insect pest based on DEM and digital monitoring technique
2011, Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)A novel pixel line based algorithm for line generation
2010, International Journal of Digital Content Technology and its ApplicationsSpeed-up of the disaggregation of emission inventories and increased resolution of disaggregated maps using landuse data
2009, Korean Journal of Chemical Engineering