ocrd_cis/ocropy/common.py
def estimate_thresholds(flat, bignore=0.1, escale=1.0, lo=5, hi=90):
    '''estimate low and high thresholds.
    ``bignore``: ignore this much of the border/margin area for threshold estimation
    ``escale``: scale for estimating a mask over the text region
    ``lo``: percentile for black estimation
    ``hi``: percentile for white estimation
    Return a float tuple of low/black and high/white
    '''
    d0, d1 = flat.shape
    o0, o1 = int(bignore * d0), int(bignore * d1)
    est = flat[o0:d0 - o0, o1:d1 - o1]
    if escale > 0:
        # by default, we use only regions that contain
        # significant variance; this makes the percentile
        # based low and high estimates more reliable
        e = escale
        v = est - filters.gaussian_filter(est, e * 20.0)
        v = filters.gaussian_filter(v ** 2, e * 20.0) ** 0.5
        v = (v > 0.3 * np.amax(v))
        v = morphology.binary_dilation(v, structure=np.ones((int(e * 50), 1)))
        v = morphology.binary_dilation(v, structure=np.ones((1, int(e * 50))))
        est = est[v]
    lo = stats.scoreatpercentile(est.ravel(), lo)
    hi = stats.scoreatpercentile(est.ravel(), hi)
    return lo, hi
estimate low and high thresholds.
    ``bignore``: ignore this much of the border/margin area for threshold estimation
    ``escale``: scale for estimating a mask over the text region
    ``lo``: percentile for black estimation
    ``hi``: percentile for white estimation
    Return a float tuple of low/black and high/white
    
estimate low and high thresholds.
estimate low and high thresholds .
def estimate_thresholds(flat, bignore=0.1, escale=1.0, lo=5, hi=90):
    d0, d1 = flat.shape
    o0, o1 = int(bignore * d0), int(bignore * d1)
    est = flat[o0:d0 - o0, o1:d1 - o1]
    if escale > 0:
        e = escale
        v = est - filters.gaussian_filter(est, e * 20.0)
        v = filters.gaussian_filter(v ** 2, e * 20.0) ** 0.5
        v = (v > 0.3 * np.amax(v))
        v = morphology.binary_dilation(v, structure=np.ones((int(e * 50), 1)))
        v = morphology.binary_dilation(v, structure=np.ones((1, int(e * 50))))
        est = est[v]
    lo = stats.scoreatpercentile(est.ravel(), lo)
    hi = stats.scoreatpercentile(est.ravel(), hi)
    return lo, hi
def estimate_thresholds ( flat , bignore = 0.1 , escale = 1.0 , lo = 5 , hi = 90 ) : d0 , d1 = flat . shape o0 , o1 = int ( bignore * d0 ) , int ( bignore * d1 ) est = flat [ o0 : d0 - o0 , o1 : d1 - o1 ] if escale > 0 : e = escale v = est - filters . gaussian_filter ( est , e * 20.0 ) v = filters . gaussian_filter ( v ** 2 , e * 20.0 ) ** 0.5 v = ( v > 0.3 * np . amax ( v ) ) v = morphology . binary_dilation ( v , structure = np . ones ( ( int ( e * 50 ) , 1 ) ) ) v = morphology . binary_dilation ( v , structure = np . ones ( ( 1 , int ( e * 50 ) ) ) ) est = est [ v ] lo = stats . scoreatpercentile ( est . ravel ( ) , lo ) hi = stats . scoreatpercentile ( est . ravel ( ) , hi ) return lo , hi
estimate low and high thresholds.
estimate low and high thresholds .
'''estimate low and high thresholds.
    ``bignore``: ignore this much of the border/margin area for threshold estimation
    ``escale``: scale for estimating a mask over the text region
    ``lo``: percentile for black estimation
    ``hi``: percentile for white estimation
    Return a float tuple of low/black and high/white
    ''' # by default, we use only regions that contain # significant variance; this makes the percentile # based low and high estimates more reliable
flat
bignore
escale
lo
hi