def opencv_wrapper(imgs, opencv_func, argv):
ret_imgs = []
imgs_copy = imgs
if imgs.shape[3] == 1:
imgs_copy = np.squeeze(imgs)
for img in imgs_copy:
img_uint8 = np.clip(np.rint(img * 255), 0, 255).astype(np.uint8)
ret_img = opencv_func(*[img_uint8]+argv)
if type(ret_img) == tuple:
ret_img = ret_img[1]
ret_img = ret_img.astype(np.float32) / 255.
ret_imgs.append(ret_img)
ret_imgs = np.stack(ret_imgs)
if imgs.shape[3] == 1:
ret_imgs = np.expand_dims(ret_imgs, axis=3)
return ret_imgs
# Binary filters.
评论列表
文章目录