Elsevier

Computers & Graphics

Volume 26, Issue 3, June 2002, Pages 401-408
Computers & Graphics

Best Papers of CAD & CG 2001
BRDC: binary representation of displacement code for line

https://doi.org/10.1016/S0097-8493(02)00083-3Get rights and content

Abstract

In raster graphics, a line is displayed as a sequence of connected pixels that best approximate the line with minimum deviation. The displacement code of a line is a sequence of binary codes, each of which represents the displacement of a pixel on the line to its immediate predecessor pixel on the line. In fact, the displacement code records the entire process of drawing a line with successive pixels and it is deterministic for each specific line. In this paper, we study the important properties of the binary representation of displacement code, called BRDC, including calculation formula, periodicity, complement, decomposition etc. At last, we put forward an efficient adaptive multi-pixel line drawing algorithm based on exploited properties of BRDC, which demonstrates that BRDC is significant for designing efficient line drawing algorithms.

Introduction

Line is one of the most fundamental elements in computer graphics. In raster graphics, a line is displayed as a sequence of connected pixels, which best approximate the line with minimum deviation. Many efforts have been paid to developing efficient line drawing algorithms [1]. These algorithms can be classified into two types. One type relates to single-step algorithms, which generate one pixel on the line during each iteration. The other relates to multi-step algorithms, which generate multiple successive pixels on the line during each iteration. One of the best-known single-step algorithms is the Bresenham algorithm [2] proposed by Bresenham in 1965, which involves only arithmetic operations of integers, i.e., one integer addition and one sign judgment for each pixel’s generation. Because of its simplicity, it is well-suited for hardware implementation. Many attempts [3], [4], [5], [6], [7], [8] later have been tried to improve the efficiency of the Bresenham algorithm. One way to accelerate the line drawing process is generating multiple pixels on the line during each iteration [9], [10], [11], [12], [13]. Taking advantage of the symmetry of a line from either endpoint, the bi-directional method is proposed in [9] to draw a line from both directions. The double-step algorithm in [10] generates two pixels each time according to the line’s slope. Also in [11] a triple-step approach is proposed. Bao et al. analyzed all the possible configurations of four pixels, called the quadruple-step running codes of line, and proposed a Quad-step algorithm in [12]. A general N-step method proposed in [13] considers even larger steps to accelerate the process of line drawing. In these multi-step algorithms, a pre-determined fixed number, for example 2, 3, or 4 etc, of pixels are generated at each iteration. In addition, there are some other adaptive multi-step algorithms [14], [15], [16], [17], which adaptively determines the step according to the slopes of the lines. In [17], three kinds of pixel approximations of a line are discussed, and a new algorithm is given, which is 20 times faster than the original Bresenham algorithm.

After reviewing the published line drawing algorithms, we found that the entire line drawing process can be represented by the displacement codes, which record the displacement of each pixel on the line to its immediate predecessor pixel on the line. The major difference between various line drawing algorithms is how they determine the displacement code. The binary representation of displacement code (BRDC) is interesting for addressing line drawing problem, because: (1) For a given line, its BRDC is unique, and (2) the BRDC of a line can be determined prior according to its slope. (3) BRDC has lots of nice properties, which can be employed to improve the line drawing process. In the next section of this paper, we will first give a formal definition of BRDC. Then we examine the important properties of the BRDC, including calculation formula, periodicity, decomposition, etc. in 3 Properties of BRDC, 4 Decomposition of BRDC. Then in Section 5, we put forward an adaptive multi-pixel line drawing algorithm based on the BRDC, and we show that the BRDC is significant for designing efficient line drawing algorithms. In the last section some future work are addressed.

Section snippets

Definition of BRDC

A raster graphics display is logically a 2D grid of pixels as shown in Fig. 6. The task of drawing a line is to determine which pixels belong to the line. Due to the limited resolution of the display, it is an approximation process. For example, L is a line from A(xa,ya) to B(xb,yb), as shown in Fig. 1. Without loss of generality, we suppose that the slope m of line L is in the interval [0, 1]. The intersection of L and a grid line x=xi is (xi,Y(xi)), where xi=xa+i, i=0,1,2,…,xbxa, and Y(xi)=xa

Properties of BRDC

In this section, we study some important properties of BRDC. The first property is about the symmetry of BRDC.

Property 1

Let H and k be two integers satisfying 0<k<H. If H is an odd integer, then Ak is symmetric, i.e.Ak(i)=Ak(H−1−i).

Proof

Since H is odd, and T=H−12, thenT=H−1−TAccording to (3), there exists an integer m, such that Tk(i)=Tik+mH.

If Ak(i)=1, then 0⩽Tk(i)<k, i.e.0⩽T−ik+mH<k.Substituting T with H−1−T, we have0⩽T+(i+1)k−(m+1)H<k.So,Tk(H−1−i)=(T−(H−1−i)k)%H=(T+(1+i)k)%H=T+(1+i)k−(m+1)H<k.Then Ak(H−1−i

Decomposition of BRDC

Properties 4 and 5 imply that the length of each repeated simple segment is N+1 or N+2. In order to study the distribution of the different lengths of the simple segments, segment code Sk is defined for the BRDC Ak as follows: If 0<k<Hk, thenSk(i)=theithsegmentstartswith10followedbyN+10′s;1theithsegmentstartswith1followedbyN0′s.Otherwise, 0<Hk<k, thenSk(i)=theithsegmentstartswith00followedbyN1′s;1theithsegmentstartswith0followedbyN+11′s.According to Property 3:Ak(i)=1−AH−k(H−1−i),the

Adaptive multi-pixel algorithm

In this section, we propose an adaptive multi-pixel line drawing algorithm as the application of Properties 3–5, and Lemma 2.

As shown in Fig. 1, the pixel approximation of line L1 and L2 can be divided into many simple segments: horizontal segments and catercorner segments. This can be analyzed by their BRDC. For a line in the first hexadecant, according to Property 4, the repeated simple segment in its BRDC starts with a jumping code followed by a number of 0’s. By the definition of BRDC, the

Conclusions and future works

We have presented an abstract representation called the BRDC, and studied some important properties of the BRDC, such as periodicity, symmetric, conjugate complementary, etc. These properties are very useful for designing and analyzing line drawing algorithms. Then we proposed a method to decompose a BRDC into a simpler one. At last, based on the above results, we have developed an efficient adaptive multi-pixel line drawing algorithm, which demonstrates the feasibility of BRDC.

Future work

Acknowledgements

The project is partly supported by the National Natural Science Funds of China for Excellent Young Scholars (Grant No: 69925204) and Innovative Research Groups (Grant No: 60021201) and for Research (Grant No: 60033010). The authors wish to thank the anonymous reviewers for their valuable comments.

References (17)

  • M.L.P. van Lierop et al.

    Line rasterization algorithms that satisfy the subset line property

    CVGIP

    (1988)
  • C. Yao et al.

    Bi-directional incremental linear interpolation

    Computer and Graphics

    (1996)
  • P. Bao et al.

    Quadruple-step line generation

    Computers and Graphics

    (1989)
  • Tang Rongxi, Wang Jiaye, Peng Qunsheng. Computer graphics course. Beijing: Academic Press, 1990 [in...
  • J.E. Bresenham

    Algorithm for computer control of a digital plotter

    IBM System Journal

    (1965)
  • Liu Yong-Kui.Generating,clipping of line and curve. Ph.D. thesis, Zhejiang University, Hangzhou Zhejiang, 1997 [in...
  • H. Freeman

    Computer processing of line drawing images

    ACM Computing Surveys

    (1974)
  • J.G. Rokne et al.

    Fast line scan-conversion

    ACM Transactions on Graphics

    (1990)
There are more references available in the full text version of this article.

Cited by (3)

View full text