计算机应用 ›› 2011, Vol. 31 ›› Issue (04): 1057-1061.DOI: 10.3724/SP.J.1087.2011.01057

• 图形图像技术 • 上一篇    下一篇

基于像素链的直线绘制算法

朱晓林1,蔡勇1,张建生2   

  1. 1. 西南科技大学 计算机科学与技术学院,四川 绵阳 621010
    2. 西南科技大学 制造科学与工程学院,四川 绵阳 621010
  • 收稿日期:2010-10-26 修回日期:2010-11-29 发布日期:2011-04-08 出版日期:2011-04-01
  • 通讯作者: 朱晓林
  • 作者简介:朱晓林(1984-),男,山东济宁人,硕士研究生,主要研究方向:计算机图形图像;
    蔡勇 (1962-),男,四川绵阳人,教授,博士,主要研究方向:计算机图形图像处理、虚拟现实;
    张建生(1980-),男,河北唐山人,讲师,硕士,主要研究方向:逆向工程、计算可视化。
  • 基金资助:
    国家自然科学基金资助项目(60873058)

Line drawing algorithm based on pixel chain

Xiao-lin ZHU1,Yong CAI1,Jiang-sheng ZHANG2   

  1. 1. School of Computer Science and Technology, Southwest University of Science and Technology, Mianyang Sichuan 621010, China
    2. School of Manufacturing Science and Engineering, Southwest University of Science and Technology, Mianyang Sichuan 621010, China
  • Received:2010-10-26 Revised:2010-11-29 Online:2011-04-08 Published:2011-04-01
  • Contact: Xiao-lin ZHU

摘要: 针对直线生成算法在直线斜率大于0.5时的低效率问题,提出一种基于像素链的直线绘制算法。将直线看做是由许多条平行像素链或对角像素链拼接而成,提出并利用逆向生成直线的类Bresenham算法,将斜率在0.5~1的直线绘制转换为斜率在0~0.5的直线绘制,一次判断生成一条像素链。仿真实验表明,基于像素链的算法生成的直线与Bresenham算法生成直线一致,且计算量显著减少。该算法只有加法和乘法两种整数运算,适合硬件实现,其绘制速度是Bresenham算法的4倍。

关键词: 计算机图形学, 直线绘制算法, Bresenham算法, 逆向生成直线, 整数运算

Abstract: In order to increase the efficiency of the line drawing algorithm when the slope of the line is greater than 0.5, a line drawing algorithm based on pixel chain was proposed. A straight line was treated as an aggregation of several horizontal pixel chains or diagonal pixel chains. An algorithm of line drawing in a reverse direction, which was similar to Bresenham algorithm, was introduced, by which the slope between 0.5 and 1 was converted to that between 0 and 0.5 while generating line. One pixel chain was generated by one judgment. The simulation results show the straight line generated by new algorithm is as same as that generated by Bresenham algorithm, but the calculation is greatly reduced. The new algorithm has generated two integer arithmetic: addition and multiplication, and it is suitable for hardware implementation. The generation speed of the new algorithm is 4 times of Bresenham algorithm with the same complexity of design.

Key words: computer graphics, line drawing algorithm, Bresenham algorithm, line generation in reverse direction, integer arithmetic

中图分类号: