粘粘字符“花式分割”___draw guide lines
draw guide lines是粘粘字符“花式分割”算法中的第二大法宝,在《粘粘字符”花式分割”___原理概述》有提到guide lines包含四种线条:ascender line, mean line, base line, descender line,在粘粘字符“花式分割”算法中通过绘制mean line 和 base line 来帮助我们分割字符,本文主要讨论mean line 和base line的绘制方法。
对于draw guide lines, 原参考文献《The Robustness of “Connecting Characters Together” CAPTCHAs》的描述与我的理解如下所示:
1.First, from the left-most foreground to the right-most foreground, we draw horizontal lines every fixed-length pixels. The vertical position of each line is determined by the lowest foreground pixel in the corresponding columns.
直译:首先,从字符像素的最左侧到最右侧,绘制固定像素长度的水平线,这些水平线的垂直位置由每一列字符像素的最低点决定。
个人点评:这个我懂并且可以完成。
2.Second, assign a value to every horizontal line. The value is the sum of the differences between its coordinate values and coordinate values of its four nearest neighbors. The larger the value is the more protruding the line’s location is.
直译:第二,为每一段水平线赋值。该值是该水平线的坐标点与其四邻域的坐标点的差值,值越大,水平线的位置越明显。
个人点评:这一点不太明白。首先,水平线既然是线,那么它在高度方向可能是一个像素点,但在宽度方向上肯定不只一个点,所以这句话的意思是:水平线上每一点的坐标值与其四邻域点的坐标值的差值的和作为水平线的特征值?
3.Then draw a line to connect the lowest foreground pixels of every fixed-length horizontal line whose value is lower than an experiential threshold.The remaining horizontal lines whose values are higher than the threshold are ignored.
直译:将特征值低于某经验阈值的水平线链接起来,其余高于阈值的水平线将被忽略。
个人点评:原参考文献在experiential threshold一词处有标注参考文献,我也找到了设计该词的参考文献,但很可惜我没有看懂。所以这一步的关键是experiential threshold的取值,不知道如果我理解为水平线最集中的区域是否可行呢?
4.Finally, extend the left-most and right-most points to both ends horizontally. The original horizontal lines are modified to our expected base line (see Fig. 7 (b)). The mean line is drawn by lifting the base line with a given value, which is 4/5 of the largest vertical distance of the highest gray pixel in every column to the base line.
直译:最后,最左侧与最右侧的点均水平连接起来,该线作为我们的base line。在base line的每一列像素中找到垂直距离最大的字符像素点,将base line与该最大点距离的4/5作为mean line的绘制点,这样我们即可得到mean line。
个人点评:如果能顺利得到base line的话,我也能轻而易举的得到mean line。
原参考文献的研究对象是Yahoo的验证码图片,原文献中绘制的base line与mean line如下图,我按照自己的理解绘制的guide lines如下下图,堪称“别人家的”和“我家的”版本的典型范例!
我绘制出的这种东东显然不能用来参与“花式分割”,不过观察我的研究对象,其实比Yahoo的验证码图片略微简单一些,不需要S曲线的guide line,因此我采用直线的方法来draw guide lines。
base line的确定方法:找到每一列像素的最高点(相对于原点),统计这些像素中拥有相同X值最多的X坐标作为base line的X轴,Y轴从有效字符左侧极限至右侧极限即可。
guide line的确定方法:找到每一列像素的最低点(相对于原点),统计这些像素中拥有相同X值最多的X坐标作为guide line的参考点。若参考点与有效字符最高点的距离小于1/5的有效字符高度,那么将以1/5的有效字符高度点作为guide line的X坐标,否则以参考点作为guide line的X坐标。
以此方式draw guide lines,得到的guide lines不如原参考文献那么婀娜多姿,但是应该能帮助我顺利分割我的研究对象。
粘粘字符“花式分割”___fix broken characters
粘粘字符“花式分割”___loop and guideline
粘粘字符“花式分割”___guideline principle