# Fast algorithm for line rasterization by using slope 1

• Published on
10-Apr-2015

• View
797

3

Embed Size (px)

Transcript

Fast Algorithm for Line Rasterization by Using Slope 1Hua Zhang*, Changqian Zhu* Jun Yang* hzhang@caep.ac.cn cqzhu@home.swjtu.edu.cn yangj@mail.lzjtu.cn * Dept. of Computer and Communication Engineering, Southwest Jiaotong University Institute of Computer Applications, China Academy of Engineering Physics AbstractIn this paper, a fast algorithm for line rasterization is presented by using approximate pixels. Slope 1 is used to decide which pixel is selected instead of using slope 1/2. Compared with Bresenhams middle point algorithm, three multiplications are reduced in each line raster process. Moreover, experiment shows that at least 6.315 percent of time is saved, and there are almost the same results for viewer compared with those of Bresenhams middle point algorithm.

y (0, 1) ? (1, 1)

?

(1, 1/2)

1. IntroductionLine rasterization is a basic subject of digital plotter, numerical control, and computer graphics. There are many papers, which discussed the efficiency and implementation of line rasterization, such as [1], [3], [4], [5], [7], [8], [9], [10] and [11]. Among these papers, Bresenhams middle point algorithm [1] is the most classical and widely used algorithm, which has the advantages of raster precision and calculation efficiency, and only integer operation is needed. Although Bresenhams middle algorithm is fast enough, numerous applications require higher speed, such as real simulation, visualization of large data sets, and rendering more complex objects. Many algorithms have discussed this problem. There are two kinds of algorithms for fasting the Bresenhams middle algorithm. One use hardware, such as [5], [7], [9], and [10]. Wu et al. [5] present a fast algorithm for line rasterization based on double-step technology. Gill [7] presents his fast algorithm which takes advantage of N-step technology. Earnshaw [9] and Castle et al. [10] take advantage of the repeated patterns that algorithm generates strait lines. On the other hand, Rokne [3] and Wright [4] present parallelization method for fasting the Bresenhams middle algorithm.

(0, 0)

(1, 0)

?

x

Figure 1. Basis of Bresenhams algorithm.

Since the upper fast algorithms just emphasize on algorithm itself, How about line in practical usage is? In a recent paper, Chen, Wang and Bresenham [8] give out detailed and clear results about this question after studying many current line drawing packages. One of the most important results is that 87.79 percent lines are less than or equal to 17 pixels. So, in this case, the fast algorithm based on the longer length of strait line may not have more advantage than we expect before. In this paper, a faster algorithm based on Bresenhams middle algorithm without line length limits is presented. Now, let us to consider this question: why should we raster the line? One of the important reasons is to show the natural objects on screen. Surely, when considering in digital plotter and numerical control, the precision is the most important factor. This paper just emphasize on the drawing lines on screen display. If a final result on scene can not be distinguished the difference between two images (rendered with different method) by eyes, approximate method could be a selection if it has some advantages, such as calculation efficiency(Bresenhams middle algorithm

0-7803-8963-8/05/\$20.00 2005 IEEE

508

Table 1. Bresehams algorithmvoid line(int x0,int y0, int xn,int yn) { int dx,dy,inCreE,inCreNE,d,x,y,flag=0;yes

Start

no

xn < x0

swapd(&x0,&xn) swapd(&y0,&yn)

if (xn