def my_label2rgboverlay(labels, colors, image, alpha=0.2):
"""
Generates image with segmentation labels on top
Parameters
----------
labels: labels of one image (0, 1)
colors: colormap
image: image (0, 1, c), where c=3 (rgb)
alpha: transparency
"""
image_float = gray2rgb(img_as_float(rgb2gray(image) if
image.shape[2] == 3 else
np.squeeze(image)))
label_image = my_label2rgb(labels, colors)
output = image_float * alpha + label_image * (1 - alpha)
return output
评论列表
文章目录