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
评论列表
文章目录