code: def run(self, workspace):
      objects = workspace.object_set.get_objects(self.object_name.value)
  
      alpha = numpy.zeros(objects.shape)
  
      convert = True
  
      if self.image_mode == "Binary (black & white)":
          pixel_data = numpy.zeros(objects.shape, bool)
      elif self.image_mode == "Grayscale":
          pixel_data = numpy.zeros(objects.shape)
      elif self.image_mode == "uint16":
          pixel_data = numpy.zeros(objects.shape, numpy.int32)
          convert = False
      else:
          pixel_data = numpy.zeros(objects.shape + (3,))
  
      for labels, _ in objects.get_labels():
          mask = labels != 0
  
          if numpy.all(~mask):
              continue
  
          if self.image_mode == "Binary (black & white)":
              pixel_data[mask] = True
  
              alpha[mask] = 1
          elif self.image_mode == "Grayscale":
              pixel_data[mask] = labels[mask].astype(float) / numpy.max(
                  labels
              )
  
              alpha[mask] = 1
          elif self.image_mode == "Color":
              if self.colormap.value == DEFAULT_COLORMAP:
                  cm_name = get_default_colormap()
              elif self.colormap.value == "colorcube":
                  # Colorcube missing from matplotlib
                  cm_name = "gist_rainbow"
              elif self.colormap.value == "lines":
                  # Lines missing from matplotlib and not much like it,
                  # Pretty boring palette anyway, hence
                  cm_name = "Pastel1"
              elif self.colormap.value == "white":
                  # White missing from matplotlib, it's just a colormap
                  # of all completely white... not even different kinds of
                  # white. And, isn't white just a uniform sampling of
                  # frequencies from the spectrum?
                  cm_name = "Spectral"
              else:
                  cm_name = self.colormap.value
  
              cm = matplotlib.cm.get_cmap(cm_name)
  
              mapper = matplotlib.cm.ScalarMappable(cmap=cm)
  
              if labels.ndim == 3:
                  for index, plane in enumerate(mask):
                      pixel_data[index, plane, :] = mapper.to_rgba(
                          centrosome.cpmorphology.distance_color_labels(
                              labels[index]
                          )
                      )[plane, :3]
              else:
                  pixel_data[mask, :] += mapper.to_rgba(
                      centrosome.cpmorphology.distance_color_labels(
                          labels
                      )
                  )[mask, :3]
  
              alpha[mask] += 1
          elif self.image_mode == "uint16":
              pixel_data[mask] = labels[mask]
  
              alpha[mask] = 1
  
      mask = alpha > 0
  
      if self.image_mode == "Color":
          pixel_data[mask, :] = (
              pixel_data[mask, :] / alpha[mask][:, numpy.newaxis]
          )
      elif self.image_mode != "Binary (black & white)":
          pixel_data[mask] = pixel_data[mask] / alpha[mask]
  
      image = Image(
          pixel_data,
          parent_image=objects.parent_image,
          convert=convert,
          dimensions=len(objects.shape),
      )
  
      workspace.image_set.add(self.image_name.value, image)
  
      if self.show_window:
          if image.dimensions == 2:
              workspace.display_data.ijv = objects.ijv
          else:
              workspace.display_data.segmented = objects.segmented
  
          workspace.display_data.pixel_data = pixel_data
  
          workspace.display_data.dimensions = image.dimensions
  
file_path: CellProfiler/src/frontend/cellprofiler/modules/convertobjectstoimage.py
imports: import centrosome.cpmorphology
  import matplotlib.cm
  import numpy
  from cellprofiler_core.image import Image
  from cellprofiler_core.module import Module
  from cellprofiler_core.preferences import get_default_colormap
  from cellprofiler_core.setting.choice import Choice, Colormap
  from cellprofiler_core.setting.subscriber import LabelSubscriber
  from cellprofiler_core.setting.text import ImageName
label_desc: Use image node_id 4 for calling the ConvertObjectsToImage obj's underlying member method code with example usage: obj.run(workspace) without return types