Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
update colormap to a non-discrete one -- fixes #324
Browse files Browse the repository at this point in the history
  • Loading branch information
yalaudah committed Jun 1, 2020
1 parent 1ec0279 commit 11390db
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cv_lib/cv_lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
"""
Expand All @@ -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:
Expand All @@ -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.
Expand Down

0 comments on commit 11390db

Please sign in to comment.