code: def convert_to_objects(
      data, cast_to_bool, preserve_label, background, connectivity
  ):
      # Compatibility with skimage
      connectivity = None if connectivity == 0 else connectivity
  
      caster = (
          skimage.img_as_bool if cast_to_bool else skimage.img_as_uint
      )
      data = caster(data)
  
      # If preservation is desired, just return the original labels
      if preserve_label and not cast_to_bool:
          return data
  
      return skimage.measure.label(
          data, background=background, connectivity=connectivity
      )
  
file_path: CellProfiler/src/frontend/cellprofiler/modules/convertimagetoobjects.py
imports: import skimage
  import skimage.measure
  from cellprofiler_core.module.image_segmentation import ImageSegmentation
  from cellprofiler_core.setting import Binary
  from cellprofiler_core.setting.text import Integer
label_desc: Use image node_id 1 for calling a global function with example usage: convert_to_objects(data, cast_to_bool, preserve_label, background, connectivity) and returns: skimage, data