CRF是对FCN等处理后的图像进行优化处理,不进行训练和学习示 例代码如下,向crf函数输入,原始图像,FCN分割后的图像输出优化后的图像, import sys import numpy as np import pydensecrf.densecrf as dcrf import cv2,os # Get im{read,write} from somewhere. try: from cv2 import imread, imwrite except ImportError: # Note that, sadly, skimage unconditionally import scipy and matplotlib, # so you'll need them if you don't have OpenCV. But you probably have them. from skimage.io import imread, imsave imwrite = imsave # TODO: Use scipy instead. from pydensecrf.utils import unary_from_labels, create_pairwise_bilateral, create_pairwise_gaussian def crf(x,y,z): fn_im = 'unet_pred/%s'%x fn_anno = 'mask/%s'%y fn_output = 'crf/%s'%z ################################## ### Read images and annotation ### ################################## img = imread(fn_im) # Convert the annotation's RGB color to a single 32-bit integer color 0xBBGGRR anno_rgb = imread(fn_anno).astype(np.uint32) #anno_rgb = anno_rgb.astype(np.uint32
CRF对分割图像进行优化处理
最新推荐文章于 2025-05-21 20:38:25 发布