code: def _apply_discrete_colormap(arr, cmap):
      
      res = np.zeros((arr.shape[1], arr.shape[2], 3), dtype=np.uint8)
      for k, v in cmap.items():
          res[arr[0] == k] = v
      return np.transpose(res, [2, 0, 1])
docs: Apply discrete colormap.
  
      Attributes
      ----------
      arr : numpy.ndarray
          1D image array to convert.
      color_map: dict
          Discrete ColorMap dictionary
          e.g:
          {
              1: [255, 255, 255],
              2: [255, 0, 0]
          }
  
      Returns
      -------
      arr: numpy.ndarray