计算机工程与应用 ›› 2011, Vol. 47 ›› Issue (21): 188-190.

• 图形、图像、模式识别 • 上一篇    下一篇

一种快速的多线宽直线反走样算法

骆朝亮,谢 忠   

  1. 中国地质大学 信息工程学院,武汉 430074
  • 收稿日期:1900-01-01 修回日期:1900-01-01 出版日期:2011-07-21 发布日期:2011-07-21

Rapid algorithm for anti-aliasing of arbitrary width line drawing

LUO Chaoliang,XIE Zhong   

  1. Faculty of Information Engineering,China University of Geosciences,Wuhan 430074,China
  • Received:1900-01-01 Revised:1900-01-01 Online:2011-07-21 Published:2011-07-21

摘要: 对于直线绘制中出现的锯齿现象称为走样,消除走样的方法称为反走样,通过对直线走样产生的原因进行理论上的分析,了现有的反走样技术。通过对经典的DDA直线绘制算法和Wu直线反走样绘制算法的研究,在二者结合的基础上,给出了一种任意宽度和复杂背景色下的直线反走样快速绘制算法:对于直线f(x)=mx+b,0≤m≤1,x轴上每移动一个像素单位,根据直线所需绘制的宽度,在y轴上进行跨度像素着色,填充的色深取决于该像素到对应直线边缘线的距离、原有背景色和当前直线绘制色。对算法进行了去浮点优化,给出了复杂度分析和实验结果。实践证明,该算法有很好的执行效率和反走样效果。

关键词: 直线绘制, 反走样, 数值微分分析法(DDA), 快速

Abstract: This paper theoretically analyzes anti-aliasing problem.A solution based on the classical DDA(Digital Differential Analyzer) algorithm and Wu anti-aliasing algorithm is proposed to address the issue.The solution offers an efficient line drawing algorithm which is applicable to arbitrary line width and complex background color.Specifically the algorithm makes pixel by pixel move along x(y) axis while filling span pixels along line direction of y(x) based on line width.The filling color is dependent on three factors including current pixel’s distance from the line’s centerline,original background color and current line drawing color.This algorithm is further optimized with floating-point and complexity analysis.Experiment result and application of the new algorithm are presented.

Key words: line drawing, anti-aliasing, Digital Differential Analyzer(DDA), rapid