code: def test_filter_background():
      """Run on an image, filtering out the background
  
      This test makes sure that the grey_closing happens correctly
      over the user-specified radius.
      """
      #
      # Make an image with granularity at scale 2
      #
      i, j = numpy.mgrid[0:80, 0:80]
      image = (
          (i / 4).astype(int) % 2 == (j / 4).astype(int) % 2
      ).astype(float)
      #
      # Scale the pixels down so we have some dynamic range and offset
      # so the background is .2
      #
      image = image * 0.5 + 0.2
      #
      # Paint all background pixels on the edge and 1 in to be 0
      #
      image[:, :2][image[:, :2] < 0.5] = 0
      #
      # Paint all of the foreground pixels on the edge to be .5
      #
      image[:, 0][image[:, 0] > 0.5] = 0.5
      #
      # The pixel at 0,0 doesn't get a background of zero
      #
      image[0, 0] = 0.7
      #
      # The 4x4 blocks need two erosions before disappearing. The corners
      # need an additional two erosions before disappearing
      #
      expected = [0, 99, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
      module, workspace = make_pipeline(image, None, 1, 1, 5, 16)
      assert isinstance(
          module,
          cellprofiler.modules.measuregranularity.MeasureGranularity,
      )
      module.run(workspace)
      m = workspace.measurements
      assert isinstance(m, cellprofiler_core.measurement.Measurements)
      for i in range(1, 16):
          feature = module.granularity_feature(i, IMAGE_NAME)
          assert feature in m.get_feature_names("Image")
          value = m.get_current_image_measurement(feature)
          numpy.testing.assert_allclose(value, expected[i - 1])
  
imports: import sys
  import numpy
  import six.moves
  import cellprofiler_core.image
  import cellprofiler.modules.measuregranularity
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.workspace
  import tests.frontend.modules
label_desc: Use image node_id 8 for calling a global function with example usage: test_filter_background() without return types