class_docstr: Provide a single image based on omero pixels id
class_docstr_tok: ["Provide","a","single","image","based","on","omero","pixels","id"]
docstr: load an image plane from an omero server
  and return a 2-d grayscale image
docstr_tok: ["load","an","image","plane","from","an","omero","server","and","return","a","2-d","grayscale","image"]
code: def provide_image(self, image_set):
      """load an image plane from an omero server
      and return a 2-d grayscale image
      """
      # TODO: return 3d RGB images when c == None like loadimage.py does?
  
      if self.__is_cached:
          return self.__omero_image_plane
  
      gateway = self.__gateway
      pixels_id = self.__pixels_id
      z = self.__z
      c = self.__c
      t = self.__t
  
      # Retrieve the image data from the omero server
      pixels = self.__pixels
      omero_image_plane = gateway.getPlane(pixels_id, z, c, t)
  
      # Create a 'cellprofiler' image
      width = pixels.getSizeX().getValue()
      height = pixels.getSizeY().getValue()
      pixels_type = pixels.getPixelsType().getValue().getValue()
  
      # OMERO stores images in big endian format
      little_endian = False
      if pixels_type == INT_8:
          dtype = np.char
          scale = 255
      elif pixels_type == UINT_8:
          dtype = np.uint8
          scale = 255
      elif pixels_type == UINT_16:
          dtype = "<u2" if little_endian else ">u2"
          scale = 65535
      elif pixels_type == INT_16:
          dtype = "<i2" if little_endian else ">i2"
          scale = 65535
      elif pixels_type == UINT_32:
          dtype = "<u4" if little_endian else ">u4"
          scale = 2**32
      elif pixels_type == INT_32:
          dtype = "<i4" if little_endian else ">i4"
          scale = 2**32 - 1
      elif pixels_type == FLOAT:
          dtype = "<f4" if little_endian else ">f4"
          scale = 1
      elif pixels_type == DOUBLE:
          dtype = "<f8" if little_endian else ">f8"
          scale = 1
      else:
          raise NotImplementedError(
              "omero pixels type not implemented for %s" % pixels_type
          )
      # TODO: should something be done here with MaxSampleValue (like loadimages.py does)?
  
      image = np.frombuffer(omero_image_plane, dtype)
      image.shape = (height, width)
      image = image.astype(np.float32) / float(scale)
      image = cpimage.Image(image)
      self.__cpimage_data = image
      self.__is_cached = True
      return image
  
imports: import traceback
  import numpy
  import wx
  import cellprofiler_core.image
  import cellprofiler_core.module
  import cellprofiler_core.measurement
  import cellprofiler_core.preferences
  import cellprofiler_core.setting
  from cellprofiler_core.modules import default_cpimage_name
  import omero
  from omero.rtypes import rlong
  from omero.rtypes import rint
  from omero_version import omero_version
label_desc: Use image node_id 2 for calling the OmeroImageProvider obj's underlying member method code with example usage: obj.provide_image(image_set) and returns: image, self