code: def get_skeleton_points(labelset, shape, max_points):
      """Get points by skeletonizing the objects and decimating"""
      total_skel = np.zeros(shape, bool)
  
      for labels, indexes in labelset:
          colors = centrosome.cpmorphology.color_labels(labels)
          for color in range(1, np.max(colors) + 1):
              labels_mask = colors == color
              skel = centrosome.cpmorphology.skeletonize(
                  labels_mask,
                  ordering=scipy.ndimage.distance_transform_edt(
                      labels_mask
                  )
                  * centrosome.filter.poisson_equation(labels_mask),
              )
              total_skel = total_skel | skel
  
      n_pts = np.sum(total_skel)
  
      if n_pts == 0:
          return np.zeros(0, np.int32), np.zeros(0, np.int32)
  
      i, j = np.where(total_skel)
  
      if n_pts > max_points:
          #
          # Decimate the skeleton by finding the branchpoints in the
          # skeleton and propagating from those.
          #
          markers = np.zeros(total_skel.shape, np.int32)
          branchpoints = centrosome.cpmorphology.branchpoints(
              total_skel
          ) | centrosome.cpmorphology.endpoints(total_skel)
          markers[branchpoints] = np.arange(np.sum(branchpoints)) + 1
          #
          # We compute the propagation distance to that point, then impose
          # a slightly arbitrary order to get an unambiguous ordering
          # which should number the pixels in a skeleton branch monotonically
          #
          ts_labels, distances = centrosome.propagate.propagate(
              np.zeros(markers.shape), markers, total_skel, 1
          )
          order = np.lexsort((j, i, distances[i, j], ts_labels[i, j]))
          #
          # Get a linear space of self.max_points elements with bounds at
          # 0 and len(order)-1 and use that to select the points.
          #
          order = order[
              np.linspace(0, len(order) - 1, max_points).astype(int)
          ]
          return i[order], j[order]
  
      return i, j
  
imports: import numpy
  import scipy
  import centrosome
  import centrosome.cpmorphology
  import centrosome.filter
  import centrosome.propagate
  import centrosome.fastemd
  from sklearn.cluster import KMeans
  from cellprofiler_library.opts import measureimageoverlap
  from cellprofiler_library.functions.segmentation import convert_labels_to_ijv
  from cellprofiler_library.functions.segmentation import indices_from_ijv
  from cellprofiler_library.functions.segmentation import count_from_ijv
  from cellprofiler_library.functions.segmentation import areas_from_ijv
  from cellprofiler_library.functions.segmentation import cast_labels_to_label_set
label_desc: Use image node_id 5 for calling a global function with example usage: get_skeleton_points(labelset, shape, max_points) and returns: i,  j, np,  np, i,  j