本文整理汇总了Python中skimage.filters.thresholding.threshold_li函数的典型用法代码示例。如果您正苦于以下问题:Python threshold_li函数的具体用法?Python threshold_li怎么用?Python threshold_li使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了threshold_li函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_li_camera_image
def test_li_camera_image():
image = skimage.img_as_ubyte(data.camera())
threshold = threshold_li(image)
ce_actual = _cross_entropy(image, threshold)
assert 62 < threshold_li(image) < 63
assert ce_actual < _cross_entropy(image, threshold + 1)
assert ce_actual < _cross_entropy(image, threshold - 1)
示例2: test_li_coins_image
def test_li_coins_image():
image = skimage.img_as_ubyte(data.coins())
threshold = threshold_li(image)
ce_actual = _cross_entropy(image, threshold)
assert 94 < threshold_li(image) < 95
assert ce_actual < _cross_entropy(image, threshold + 1)
# in the case of the coins image, the minimum cross-entropy is achieved one
# threshold below that found by the iterative method. Not sure why that is
# but `threshold_li` does find the stationary point of the function (ie the
# tolerance can be reduced arbitrarily but the exact same threshold is
# found), so my guess some kind of histogram binning effect.
assert ce_actual < _cross_entropy(image, threshold - 2)
示例3: test_li_astro_image
def test_li_astro_image():
image = skimage.img_as_ubyte(data.astronaut())
threshold = threshold_li(image)
ce_actual = _cross_entropy(image, threshold)
assert 64 < threshold < 65
assert ce_actual < _cross_entropy(image, threshold + 1)
assert ce_actual < _cross_entropy(image, threshold - 1)
示例4: test_li_coins_image_as_float
def test_li_coins_image_as_float():
coins = skimage.img_as_float(data.coins())
assert 0.37 < threshold_li(coins) < 0.38
示例5: test_li_coins_image
def test_li_coins_image():
coins = skimage.img_as_ubyte(data.coins())
assert 95 < threshold_li(coins) < 97
示例6: test_li_camera_image
def test_li_camera_image():
camera = skimage.img_as_ubyte(data.camera())
assert 63 < threshold_li(camera) < 65
示例7: test_li_constant_image
def test_li_constant_image(self):
with pytest.raises(ValueError):
threshold_li(np.ones((10,10)))
示例8: test_li_constant_image
def test_li_constant_image(self):
assert threshold_li(np.ones((10, 10))) == 1.
示例9: test_li_negative_int
def test_li_negative_int(self):
image = self.image - 2
assert int(threshold_li(image)) == 0
示例10: test_li_constant_image_with_nan
def test_li_constant_image_with_nan():
image = np.array([8, 8, 8, 8, np.nan])
assert threshold_li(image) == 8
示例11: test_li_inf_minus_inf
def test_li_inf_minus_inf():
image = np.array([np.inf, -np.inf])
assert threshold_li(image) == 0
示例12: test_li_inf_image
def test_li_inf_image():
image = np.array([np.inf, np.nan])
assert threshold_li(image) == np.inf
示例13: test_li_nan_image
def test_li_nan_image():
image = np.full((5, 5), np.nan)
assert np.isnan(threshold_li(image))
示例14: test_li_coins_image_as_float
def test_li_coins_image_as_float():
coins = skimage.img_as_float(data.coins())
assert 94/255 < threshold_li(coins) < 95/255
示例15: test_li_astro_image
def test_li_astro_image():
img = skimage.img_as_ubyte(data.astronaut())
assert 66 < threshold_li(img) < 68