ocrolib_ext.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:deep_ocr 作者: JinpengLI 项目源码 文件源码
def compute_gradmaps(binary, scale, usegauss, vscale, hscale, debug=False):
    # use gradient filtering to find baselines
    boxmap = psegutils.compute_boxmap(binary,scale)
    cleaned = boxmap*binary
    if debug:
        debug_show(cleaned, "cleaned")
    if usegauss:
        # this uses Gaussians
        grad = gaussian_filter(1.0*cleaned,(vscale*0.3*scale,
                                            hscale*6*scale),
                                            order=(1,0))
    else:
        # this uses non-Gaussian oriented filters
        grad = gaussian_filter(1.0*cleaned, (max(4, vscale*0.3*scale),
                                            hscale*scale ), order=(1,0))
        grad = uniform_filter(grad, (vscale, hscale*6*scale))
    if debug:
        debug_show(grad, "compute_gradmaps grad")
    bottom = ocrolib.norm_max((grad<0)*(-grad))
    top = ocrolib.norm_max((grad>0)*grad)
    if debug:
        debug_show(bottom, "compute_gradmaps bottom")
        debug_show(top, "compute_gradmaps top")
    return bottom, top, boxmap
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号