old_contents: import numpy as np
  
  
  # ==============================================================================
  #                                                              PIXELS_WITH_VALUE
  # ==============================================================================
  def pixels_with_value(img, val):
      """ Given an image as a numpy array, and a value representing the
          pixel values, eg [128,255,190] in an RGB image, then it returns
          a 2D boolean array with a True for every pixel position that has
          that value.
      """
      return np.all(img==np.array(val), axis=2)
  
  
  # ==============================================================================
  #                                                                   RGB2SEGLABEL
  # ==============================================================================
  def rgb2seglabel(img, colormap, channels_axis=False):
      """ Given an RGB image stored as a numpy array, and a colormap that
          maps from label id to an RGB color for that label, it returns a
          new numpy array with color chanel size of 1 where the pixel
          intensity values represent the class label id.
      """
      height, width, _ = img.shape
      if channels_axis:
          label = np.zeros([height, width,1], dtype=np.uint8)
      else:
          label = np.zeros([height, width], dtype=np.uint8)
      for id in range(len(id2label)):
          label[np.all(img==np.array(idcolormap[id]), axis=2)] = id
      return label
  
new_contents: import numpy as np
  
  
  # ==============================================================================
  #                                                              PIXELS_WITH_VALUE
  # ==============================================================================
  def pixels_with_value(img, val):
      """ Given an image as a numpy array, and a value representing the
          pixel values, eg [128,255,190] in an RGB image, then it returns
          a 2D boolean array with a True for every pixel position that has
          that value.
      """
      return np.all(img==np.array(val), axis=2)
  
  
  # ==============================================================================
  #                                                                   RGB2SEGLABEL
  # ==============================================================================
  def rgb2seglabel(img, colormap, channels_axis=False):
      """ Given an RGB image stored as a numpy array, and a colormap that
          maps from label id to an RGB color for that label, it returns a
          new numpy array with color chanel size of 1 where the pixel
          intensity values represent the class label id.
  
      Args:
          img:            (np array)
          colormap:       (list) list of pixel values for each class label id
          channels_axis:  (bool)(default=False) Should it return an array with a
                          third (color channels) axis of size 1?
      """
      height, width, _ = img.shape
      if channels_axis:
          label = np.zeros([height, width,1], dtype=np.uint8)
      else:
          label = np.zeros([height, width], dtype=np.uint8)
      for id in range(len(id2label)):
          label[np.all(img==np.array(idcolormap[id]), axis=2)] = id
      return label
  
subject: Extend docstring for rgb2seglabel()