def compute_gradmaps(binary,scale):
# use gradient filtering to find baselines
boxmap = psegutils.compute_boxmap(binary,scale)
cleaned = boxmap*binary
DSAVE("cleaned",cleaned)
if args['usegause']:
# this uses Gaussians
grad = gaussian_filter(1.0*cleaned,(args['vscale']*0.3*scale,
args['hscale']*6*scale),order=(1,0))
else:
# this uses non-Gaussian oriented filters
grad = gaussian_filter(1.0*cleaned,(max(4,args['vscale']*0.3*scale),
args['hscale']*scale),order=(1,0))
grad = uniform_filter(grad,(args['vscale'],args['hscale']*6*scale))
bottom = ocrolib.norm_max((grad<0)*(-grad))
top = ocrolib.norm_max((grad>0)*grad)
return bottom,top,boxmap
评论列表
文章目录