code: def test_decimate_k_means():
      r = numpy.random.RandomState()
      r.seed(64)
      img = r.uniform(size=(10, 10)) > 0.5
      workspace, module = make_workspace(
          dict(image=img), dict(image=img.transpose())
      )
      #
      # Pick a single point for decimation - the emd should be zero
      #
      module.max_points._Number__minval = 1
      module.max_points.value = 1
      module.run(workspace)
      assert (
          workspace.measurements[
              "Image",
              module.measurement_name(
                  cellprofiler.modules.measureimageoverlap.FTR_EARTH_MOVERS_DISTANCE
              ),
          ]
          == 0
      )
      #
      # Pick a large number of points to get the real EMD
      #
      workspace, module = make_workspace(
          dict(image=img), dict(image=img.transpose())
      )
      module.max_points._Number__minval = 1
      module.max_points.value = 100
      module.run(workspace)
      emd = workspace.measurements[
          "Image",
          module.measurement_name(
              cellprofiler.modules.measureimageoverlap.FTR_EARTH_MOVERS_DISTANCE
          ),
      ]
      #
      # The EMD after decimation is going to be randomly different,
      # but not by much.
      #
      workspace, module = make_workspace(
          dict(image=img), dict(image=img.transpose())
      )
      module.max_points._Number__minval = 1
      module.max_points.value = numpy.sum(img | img.transpose()) / 2
      module.run(workspace)
      decimated_emd = workspace.measurements[
          "Image",
          module.measurement_name(
              cellprofiler.modules.measureimageoverlap.FTR_EARTH_MOVERS_DISTANCE
          ),
      ]
      assert decimated_emd < emd * 2
      assert decimated_emd > emd / 2
  
imports: import io
  import numpy
  import numpy.random
  import numpy.testing
  import scipy.ndimage
  import cellprofiler_library.opts.measureimageoverlap
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler_core.module
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.preferences
  import cellprofiler_core.workspace
  from cellprofiler_core.constants.measurement import COLTYPE_FLOAT
  import cellprofiler.modules.measureimageoverlap
  import tests.frontend.modules
label_desc: Use image node_id 27 for calling a global function with example usage: test_decimate_k_means() without return types