docstr: Test the feature: local_histogram.
docstr_tok: ["Test","the","feature",":","local_histogram","."]
code: def test_local_histogram(self):
      """Test the feature: local_histogram."""
  
      i = numpy.asarray(
          [[0, 1, 1, 1], [0, 1, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]]
      )
      e = numpy.asarray(
          [
              [0.5, 0.5],
              [0.5, 0.5],
              [0.16666667, 0.83333333],
              [0.25, 0.75],
              [0.66666667, 0.33333333],
              [0.66666667, 0.33333333],
              [0.33333333, 0.66666667],
              [0.33333333, 0.66666667],
              [0.83333333, 0.16666667],
              [0.88888889, 0.11111111],
              [0.55555556, 0.44444444],
              [0.5, 0.5],
              [1.0, 0.0],
              [1.0, 0.0],
              [0.66666667, 0.33333333],
              [0.5, 0.5],
          ]
      )
      r = local_histogram(i, bins=2, size=3)
      numpy.testing.assert_allclose(
          r, e, err_msg="local histogram: 2D image range failed"
      )
  
      m = [
          [False, False, False],
          [False, True, False],
          [False, False, False],
      ]
      e = e[:9][numpy.asarray(m).flatten()]
      r = local_histogram(i, bins=2, size=3, rang=(0, 1), mask=m)
      self.assertEqual(
          len(r), 1, "local histogram: 2D local range masked failed"
      )
      numpy.testing.assert_allclose(
          r, e, err_msg="local histogram: 2D local range masked failed"
      )
  
      i = numpy.asarray(
          [[0, 1, 1, 1], [0, 1, 0, 1], [0, 0, 0, 1], [1, 0, 0, 1]]
      )
      e = numpy.asarray([(0, 1)] * 16)
      r = local_histogram(i, size=3, bins=2, rang=(0.1, 1))
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="local histogram: 2D fixed range with excluded elements failed",
      )
  
      e = numpy.asarray([(0, 1)] * 16)
      r = local_histogram(i, size=3, bins=2, cutoffp=(50, 100))
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="local histogram: 2D rang over complete image \w cutoffp failed",
      )
  
      i = numpy.asarray([[1, 1, 1], [1, 1, 1], [1, 1, 1]])
      i = numpy.asarray([i, i, i])
      e = numpy.asarray([(0, 1)] * (9 * 3))
      r = local_histogram(i, size=3, bins=2, rang=(0, 1))
      numpy.testing.assert_allclose(
          r, e, err_msg="local histogram: 3D local range failed"
      )
  
      i = numpy.asarray([i, i, i])
      e = numpy.asarray([(0, 1)] * (9 * 3 * 3))
      r = local_histogram(i, size=3, bins=2, rang=(0, 1))
      numpy.testing.assert_allclose(
          r, e, err_msg="local histogram: 4D local range failed"
      )
  
file_path: medpy/tests/features_/intensity.py
imports: import unittest
  import math
  import numpy
  from medpy.features.intensity import intensities, centerdistance, centerdistance_xdminus1, indices, local_mean_gauss, local_histogram
  from medpy.features.utilities import join, append
  from medpy.core.exceptions import ArgumentError
label_desc: Use image node_id 1 for calling the TestIntensityFeatures obj's underlying member method code with example usage: obj.test_local_histogram() without return types