def run(self, ips, snap, img, para = None):
		img[:] = snap>0
		dist = distance_transform_edt(snap, output=np.uint16)
		pts = find_maximum(dist, para['tor'], True)
		buf = np.zeros(ips.shape, dtype=np.uint32)
		buf[pts[:,0], pts[:,1]] = img[pts[:,0], pts[:,1]] = 2
		markers, n = ndimg.label(buf, np.ones((3,3)))
		line = watershed(dist, markers, line=True, conn=para['con']+1, up=False)
		msk = apply_hysteresis_threshold(img, 0, 1)
		img[:] = snap * ~((line==0) & msk)
Esempio n. 2
0
    def run(self, ips, snap, img, para=None):
        dist = distance_transform_edt(snap, output=np.uint16)
        markers, n = ndimg.label(snap == 0, np.ones((3, 3)))

        line = watershed(dist, markers, line=True)
        if para['type'] == 'segment with ori':
            img[:] = np.where(line == 0, 0, snap)
        if para['type'] == 'segment only':
            img[:] = (line > 0) * 255
        if para['type'] == 'white line':
            img[:] = (line == 0) * 255
        if para['type'] == 'gray line':
            img[:] = np.where(line == 0, dist, 0)
Esempio n. 3
0
 def run(self, ips, snap, img, para=None):
     return distance_transform_edt(snap)
Esempio n. 4
0
def build(msk):
    dis = distance_transform_edt(msk)
    ske = skeletonize(msk > 128)
    graph = sknw.build_sknw(ske, True)
    rst = build_graph(graph, dis, True)
    return rst
 def run(self, ips, imgs, para=None):
     imgs[:] = imgs > 0
     dtype = imgs.dtype if imgs.dtype in (np.float32,
                                          np.float64) else np.uint16
     dismap = distance_transform_edt(imgs, output=dtype)
     imgs[:] = np.clip(dismap, ips.range[0], ips.range[1])