class_docstr: Represents the images for a particular iteration of a pipeline
  
  An image set is composed of one image provider per image in the set.
  The image provider loads or creates an image, given a dictionary of keys
  (which might represent things like the plate/well for the image set or the
  frame number in a movie, etc.)
docstr: Return the image associated with the given name
  
  name - name of the image within the image_set
  must_be_color - raise an exception if not a color image
  must_be_grayscale - raise an exception if not a grayscale image
  must_be_rgb - raise an exception if 2-d or if # channels not 3 or 4,
                discard alpha channel.
docstr_tok: ["Return","the","image","associated","with","the","given","name","name","-","name","of","the","image","within","the","image_set","must_be_color","-","raise","an","exception","if","not","a","color","image","must_be_grayscale","-","raise","an","exception","if","not","a","grayscale","image","must_be_rgb","-","raise","an","exception","if","2-d","or","if","#","channels","not","3","or","4",",","discard","alpha","channel","."]
code: def get_image(
      self,
      name,
      must_be_binary=False,
      must_be_color=False,
      must_be_grayscale=False,
      must_be_rgb=False,
  ):
      """Return the image associated with the given name
  
      name - name of the image within the image_set
      must_be_color - raise an exception if not a color image
      must_be_grayscale - raise an exception if not a grayscale image
      must_be_rgb - raise an exception if 2-d or if # channels not 3 or 4,
                    discard alpha channel.
      """
      name = str(name)
      if name not in self.__images:
          image = self.get_image_provider(name).provide_image(self)
  
      else:
          image = self.__images[name]
  
      if image.multichannel:
          if must_be_binary:
              raise ValueError("Image must be binary, but it was color")
  
          if must_be_grayscale:
              pd = image.pixel_data
  
              pd = pd.transpose(-1, *list(range(pd.ndim - 1)))
  
              if (
                  pd.shape[-1] >= 3
                  and numpy.all(pd[0] == pd[1])
                  and numpy.all(pd[0] == pd[2])
              ):
                  return GrayscaleImage(image)
  
              raise ValueError(
                  "Image must be grayscale, but it was color"
              )
  
          if must_be_rgb:
              if image.pixel_data.shape[-1] not in (3, 4):
                  raise ValueError(
                      "Image must be RGB, but it had %d channels"
                      % image.pixel_data.shape[-1]
                  )
  
              if image.pixel_data.shape[-1] == 4:
                  LOGGER.warning("Discarding alpha channel.")
  
                  return RGBImage(image)
  
          return image
  
      if must_be_binary and image.pixel_data.dtype != bool:
          raise ValueError("Image was not binary")
  
      if must_be_grayscale and image.pixel_data.dtype.kind == "b":
          return GrayscaleImage(image)
  
      if must_be_rgb:
          raise ValueError("Image must be RGB, but it was grayscale")
  
      if must_be_color:
          raise ValueError("Image must be color, but it was grayscale")
  
      return image
  
file_path: CellProfiler/src/subpackages/core/cellprofiler_core/image/_image_set.py
imports: import logging
  import numpy
  from ._grayscale_image import GrayscaleImage
  from ._rgb_image import RGBImage
  from .abstract_image import VanillaImage
label_desc: Use image node_id 2 for calling the ImageSet obj's underlying member method code with example usage: obj.get_image(name, must_be_binary, must_be_color, must_be_grayscale, must_be_rgb) and returns: image, image, GrayscaleImage, GrayscaleImage, RGBImage