code: def get_kmeans_points(src_ijv, dest_ijv, max_points):
      """Get representative points in the objects using K means
  
      src_ijv - get some of the foreground points from the source ijv labeling
      dest_ijv - get the rest of the foreground points from the ijv labeling
                  objects
  
      returns a vector of i coordinates of representatives and a vector
              of j coordinates
      """
  
      ijv = np.vstack((src_ijv, dest_ijv))
      if len(ijv) <= max_points:
          return ijv[:, 0], ijv[:, 1]
      random_state = np.random.RandomState()
      random_state.seed(ijv.astype(int).flatten())
      kmeans = KMeans(
          n_clusters=max_points, tol=2, random_state=random_state
      )
      kmeans.fit(ijv[:, :2])
      return (
          kmeans.cluster_centers_[:, 0].astype(np.uint32),
          kmeans.cluster_centers_[:, 1].astype(np.uint32),
      )
  
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 6 for calling a global function with example usage: get_kmeans_points(src_ijv, dest_ijv, max_points) and returns: kmeans,  kmeans, ijv,  ijv