针对任意形状的多边形及孔洞区域,提出基于边界跟踪的填充算法。用细化算法对图像进行单线化预处理,分别跟踪各个封闭曲线的边界,从第1个边界点坐标出发,根据跟踪方向对每个边界点进行有向直线填充,遇到边界点时停止,将各填充图与原图进行合并。实验结果表明,该算法不受图形边界状况和自身形状的影响,能适应任意类型的封闭区域;沿边界点进行处理,避免了对背景点的重复计算;对于多孔洞的封闭图形,能对各个孔洞进行独立处理,可灵活选择填充效果。
A filling algorithm based on boundary tracking was presented aiming at polygons with holes.The boundary data were preconditioned using thinning algorithm.Secondly,all closed boundaries were tracked starting from the first boundary point coordinates and stopping at the same position.And according to the hint of directional curves,the filling method was applied to fill the polygons and holes regions.Finally,the filling results were merged.The experimental results show that the algorithm is not affected by the boundary conditions and the shape of the graph and can adapt to any type of closed region.Meanwhile,the algorithm processes points along the boundary and avoids the repeated computation of the background points.With the independent control on closed boundaries including holes,the flexible selection of filling effect is provided.