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
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
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
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