示例#1
0
 def run(self, ips, snap, img, para=None):
     edge = sobel(snap)
     img[:] = 0
     img[snap > para['thr2']] = 2
     img[snap < para['thr1']] = 1
     ips.lut = self.buflut
     mark = watershed(edge, img.astype(np.uint16))
     return (mark == 2) * 255
示例#2
0
 def run(self, ips, imgs, para=None):
     dist = -ndimg.distance_transform_edt(imgs)
     pts = find_maximum(dist, para['tor'], False)
     buf = np.zeros(imgs.shape, dtype=np.uint16)
     buf[pts[:, 0], pts[:, 1], pts[:, 2]] = 1
     markers, n = ndimg.label(buf, np.ones((3, 3, 3)))
     line = watershed(dist, markers, line=True, conn=para['con'] + 1)
     imgs[line == 0] = 0
示例#3
0
 def run(self, ips, snap, img, para=None):
     img[:] = snap
     dist = -ndimg.distance_transform_edt(snap)
     pts = find_maximum(dist, para['tor'], False)
     buf = np.zeros(ips.size, dtype=np.uint16)
     buf[pts[:, 0], pts[:, 1]] = 1
     markers, n = ndimg.label(buf, np.ones((3, 3)))
     line = watershed(dist, markers)
     img[line == 0] = 0
 def run(self, ips, snap, img, para=None):
     img[:] = snap > 0
     dist = -ndimg.distance_transform_edt(snap)
     pts = find_maximum(dist, para['tor'], False)
     buf = np.zeros(ips.size, 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)
     msk = apply_hysteresis_threshold(img, 0, 1)
     img[:] = snap * ~((line == 0) & msk)
    def run(self, ips, snap, img, para=None):
        dist = ndimg.distance_transform_edt(snap)
        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)
示例#6
0
 def run(self, ips, snap, img, para=None):
     edge = sobel(snap)
     img[:] = 0
     img[snap > para['thr2']] = 2
     img[snap < para['thr1']] = 1
     ips.lut = self.buflut
     mark = watershed(edge, img, line=True)
     if para['type'] == 'line':
         img[mark == 0] = ips.range[1]
     elif para['type'] == 'up area':
         img[mark != 1] = ips.range[1]
     elif para['type'] == 'down area':
         img[mark != 2] = ips.range[1]
 def run(self, ips, imgs, para=None):
     imgs[:] = imgs > 0
     dist = -ndimg.distance_transform_edt(imgs)
     pts = find_maximum(dist, para['tor'], False)
     buf = np.zeros(imgs.shape, dtype=np.uint32)
     buf[pts[:, 0], pts[:, 1], pts[:, 2]] = 2
     imgs[pts[:, 0], pts[:, 1], pts[:, 2]] = 2
     markers, n = ndimg.label(buf, np.ones((3, 3, 3)))
     line = watershed(dist, markers, line=True, conn=para['con'] + 1)
     msk = apply_hysteresis_threshold(imgs, 0, 1)
     imgs[:] = imgs > 0
     imgs *= 255
     imgs *= ~((line == 0) & msk)
示例#8
0
    def run(self, ips, snap, img, para=None):
        self.ips.lut[:] = self.buflut
        ndimg.gaussian_filter(snap, para['sigma'], output=img)
        mark = img < para['thr'] if para['ud'] else img > para['thr']

        markers, n = ndimg.label(mark, np.ones((3, 3)), output=np.uint16)
        if not para['ud']: img[:] = 255 - img
        mark = watershed(img, markers, line=True, conn=para['con'] + 1)
        mark = np.multiply((mark == 0), 255, dtype=np.uint8)
        if para['type'] == 'white line':
            img[:] = mark
        if para['type'] == 'gray line':
            np.minimum(snap, mark, out=img)
        if para['type'] == 'white line on ori':
            #img //=2
            np.maximum(snap, mark, out=img)
示例#9
0
    def run(self, ips, snap, img, para=None):
        #denoised = rank.median(img, disk(para['sigma']))
        #gradient = rank.gradient(denoised, disk(para['gdt']))
        ndimg.gaussian_filter(snap, para['sigma'], output=img)

        markers, n = ndimg.label(ips.mask(), np.ones((3, 3)), output=np.uint32)
        if not para['ud']: img[:] = 255 - img
        mark = watershed(img, markers, line=True, conn=para['con'] + 1)
        mark = np.multiply((mark == 0), 255, dtype=np.uint8)

        if para['type'] == 'white line':
            img[:] = mark
        if para['type'] == 'gray line':
            np.minimum(snap, mark, out=img)
        if para['type'] == 'white line on ori':
            np.maximum(snap, mark, out=img)
示例#10
0
    def run(self, ips, snap, img, para=None):
        imgs = ips.imgs
        gradient = np.zeros(imgs.shape, dtype=np.float32)
        gradient += ndimg.sobel(imgs, axis=0, output=np.float32)**2
        gradient += ndimg.sobel(imgs, axis=1, output=np.float32)**2
        gradient += ndimg.sobel(imgs, axis=2, output=np.float32)**2
        gradient **= 0.5

        msk = np.zeros(imgs.shape, dtype=np.uint8)
        msk[imgs > para['thr2']] = 1
        msk[imgs < para['thr1']] = 2

        #rst = watershed(gradient, msk)
        rst = watershed(gradient, msk.astype(np.uint16))
        imgs[:] = (rst == 1) * 255
        ips.lut = self.buflut
示例#11
0
 def run(self, ips, snap, img, para=None):
     markers = img * 0
     markers[[0, -1]] = [[1], [2]]
     mark = watershed(img, markers, line=True, conn=1)
     img[:] = (mark == 0) * 255