コード例 #1
0
def test_niblack_sauvola_pathological_image():
    # For certain values, floating point error can cause
    # E(X^2) - (E(X))^2 to be negative, and taking the square root of this
    # resulted in NaNs. Here we check that these are safely caught.
    # see https://github.com/scikit-image/scikit-image/issues/3007
    value = 0.03082192 + 2.19178082e-09
    src_img = np.full((4, 4), value).astype(np.float64)
    assert not np.any(np.isnan(threshold_niblack(src_img)))
コード例 #2
0
def test_niblack_sauvola_pathological_image():
    # For certain values, floating point error can cause
    # E(X^2) - (E(X))^2 to be negative, and taking the square root of this
    # resulted in NaNs. Here we check that these are safely caught.
    # see https://github.com/scikit-image/scikit-image/issues/3007
    value = 0.03082192 + 2.19178082e-09
    src_img = np.full((4, 4), value).astype(np.float64)
    assert not np.any(np.isnan(threshold_niblack(src_img)))
コード例 #3
0
 def test_threshold_niblack_iterable_window_size(self):
     ref = np.array([[False, False, False, True, True],
                     [False, False, True, True, True],
                     [False, True, True, True, False],
                     [False, True, True, True, False],
                     [True, True, False, False, False]])
     thres = threshold_niblack(self.image, window_size=[3, 5], k=0.5)
     out = self.image > thres
     assert_array_equal(ref, out)
コード例 #4
0
 def test_threshold_niblack(self):
     ref = np.array(
         [[False, False, False, True, True],
          [False, True, True, True, True],
          [False, True, True, True, False],
          [False, True, True, True, True],
          [True, True, False, False, False]]
     )
     thres = threshold_niblack(self.image, window_size=3, k=0.5)
     out = self.image > thres
     assert_equal(ref, out)