From 11390db602f8612d0278331e061bd7eb5d7c0c1a Mon Sep 17 00:00:00 2001 From: yalaudah Date: Mon, 1 Jun 2020 18:56:04 +0000 Subject: [PATCH] update colormap to a non-discrete one -- fixes #324 --- cv_lib/cv_lib/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cv_lib/cv_lib/utils.py b/cv_lib/cv_lib/utils.py index 8af56d16..c8df123a 100644 --- a/cv_lib/cv_lib/utils.py +++ b/cv_lib/cv_lib/utils.py @@ -8,6 +8,7 @@ import numpy as np from matplotlib import pyplot as plt + def normalize(array): """ Normalizes a segmentation mask array to be in [0,1] range @@ -16,7 +17,8 @@ def normalize(array): min = array.min() return (array - min) / (array.max() - min) -def mask_to_disk(mask, fname, cmap_name="Paired"): + +def mask_to_disk(mask, fname, n_classes, cmap_name="rainbow"): """ write segmentation mask to disk using a particular colormap """ @@ -30,7 +32,8 @@ def image_to_disk(mask, fname, cmap_name="seismic"): cmap = plt.get_cmap(cmap_name) Image.fromarray(cmap(normalize(mask), bytes=True)).save(fname) -def decode_segmap(label_mask, colormap_name="Paired"): + +def decode_segmap(label_mask, colormap_name="rainbow"): """ Decode segmentation class labels into a colour image Args: @@ -48,6 +51,7 @@ def decode_segmap(label_mask, colormap_name="Paired"): return out + def load_log_configuration(log_config_file): """ Loads logging configuration from the given configuration file.