def vis_result(image, seg, gt, title1='Segmentation', title2='Ground truth', savefile=None):
indices = np.where(seg >= 0.5)
indices_gt = np.where(gt >= 0.5)
im_norm = image / image.max()
rgb_image = color.gray2rgb(im_norm)
multiplier = [0., 1., 1.]
multiplier_gt = [1., 1., 0.]
im_seg = rgb_image.copy()
im_gt = rgb_image.copy()
im_seg[indices[0], indices[1], :] *= multiplier
im_gt[indices_gt[0], indices_gt[1], :] *= multiplier_gt
fig = plt.figure()
a = fig.add_subplot(1, 2, 1)
plt.imshow(im_seg)
a.set_title(title1)
a = fig.add_subplot(1, 2, 2)
plt.imshow(im_gt)
a.set_title(title2)
if savefile is None:
plt.show()
else:
plt.savefig(savefile)
plt.close()
评论列表
文章目录