def run(self, ips, imgs, para = None):
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
gradient /= 8
if imgs.dtype == np.uint8: np.clip(gradient, 0, 255, gradient)
imgs[:] = gradient
评论列表
文章目录