code: def convert_image_to_objects(image):
      """Interpret an image as object indices
  
      image - a grayscale or color image, assumes zero == background
  
      returns - a similarly shaped integer array with zero representing background
                and other values representing the indices of the associated object.
      """
      assert isinstance(image, numpy.ndarray)
      if image.ndim == 2:
          unique_indices = numpy.unique(image.ravel())
          if len(unique_indices) * 2 > max(
              numpy.max(unique_indices), 254
          ) and numpy.all(
              numpy.abs(numpy.round(unique_indices, 1) - unique_indices)
              <= numpy.finfo(float).eps
          ):
              # Heuristic: reinterpret only if sparse and roughly integer
              return numpy.round(image).astype(int)
  
          def sorting(x):
              return [x]
  
          def comparison(i0, i1):
              return image.ravel()[i0] != image.ravel()[i1]
  
      else:
          i, j = numpy.mgrid[0 : image.shape[0], 0 : image.shape[1]]
  
          def sorting(x):
              return [x[:, :, 2], x[:, :, 1], x[:, :, 0]]
  
          def comparison(i0, i1):
              return numpy.any(
                  image[i.ravel()[i0], j.ravel()[i0], :]
                  != image[i.ravel()[i1], j.ravel()[i1], :],
                  1,
              )
  
      order = numpy.lexsort([x.ravel() for x in sorting(image)])
      different = numpy.hstack(
          [[False], comparison(order[:-1], order[1:])]
      )
      index = numpy.cumsum(different)
      image = numpy.zeros(image.shape[:2], index.dtype)
      image.ravel()[order] = index
      return image
  
imports: import logging
  import os
  import re
  import shutil
  import sys
  import tempfile
  import urllib.request
  from urllib.parse import parse_qs, unquote, urlparse
  from urllib.request import urlopen
  import boto3
  import numpy
  import pkg_resources
  import scipy.io
  from google.cloud import storage
  from google.cloud.exceptions import NotFound
  from google.auth.exceptions import DefaultCredentialsError
  from ..constants.image import ALL_IMAGE_EXTENSIONS, FILE_SCHEME, PASSTHROUGH_SCHEMES, SUPPORTED_MOVIE_EXTENSIONS
  from ..constants.measurement import FTR_WELL
  from .measurement import is_well_column_token, is_well_row_token
label_desc: Use image node_id 1 for calling a global function with example usage: convert_image_to_objects(image) and returns: image, numpy, list, unknown, list, numpy