code: def figure_to_image(figure, *args, **kwargs):
      """Convert a figure to a numpy array"""
      #
      # Save the figure as a .PNG and then load it using imageio.imread
      #
      fd = io.BytesIO()
      kwargs = kwargs.copy()
      kwargs["format"] = "png"
      figure.savefig(fd, *args, **kwargs)
      image = imageio.imread(fd.getvalue())
      return image[:, :, :3]
  
file_path: CellProfiler/src/frontend/cellprofiler/gui/tools.py
imports: import io
  import centrosome.cpmorphology
  import imageio
  import matplotlib
  import matplotlib.figure
  import matplotlib.transforms
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: figure_to_image(figure) and returns: image