예제 #1
0
파일: psegutils.py 프로젝트: Ceubex/ocropy
def compute_boxmap(binary,scale,threshold=(.5,4),dtype='i'):
    objects = binary_objects(binary)
    bysize = sorted(objects,key=sl.area)
    boxmap = zeros(binary.shape,dtype)
    for o in bysize:
        if sl.area(o)**.5<threshold[0]*scale: continue
        if sl.area(o)**.5>threshold[1]*scale: continue
        boxmap[o] = 1
    return boxmap
예제 #2
0
def compute_boxmap(binary, scale, threshold=(.5, 4), dtype='i'):
    objects = binary_objects(binary)
    bysize = sorted(objects, key=sl.area)
    boxmap = zeros(binary.shape, dtype)
    for o in bysize:
        if sl.area(o)**.5 < threshold[0] * scale: continue
        if sl.area(o)**.5 > threshold[1] * scale: continue
        boxmap[o] = 1
    return boxmap
예제 #3
0
def estimate_scale(binary):
    objects = binary_objects(binary)
    bysize = sorted(objects,key=sl.area)
    scalemap = np.zeros(binary.shape)
    for o in bysize:
        if np.amax(scalemap[o])>0: continue
        scalemap[o] = sl.area(o)**0.5
    scale = np.median(scalemap[(scalemap>3)&(scalemap<100)])
    return scale
예제 #4
0
파일: psegutils.py 프로젝트: Ceubex/ocropy
def estimate_scale(binary):
    objects = binary_objects(binary)
    bysize = sorted(objects,key=sl.area)
    scalemap = zeros(binary.shape)
    for o in bysize:
        if amax(scalemap[o])>0: continue
        scalemap[o] = sl.area(o)**0.5
    scale = median(scalemap[(scalemap>3)&(scalemap<100)])
    return scale