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
评论列表
文章目录