當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python skimage.filters.threshold_li用法及代碼示例

用法:

skimage.filters.threshold_li(image, *, tolerance=None, initial_guess=None, iter_callback=None)

通過 Li 的迭代最小交叉熵方法計算閾值。

參數

image(N, M[, ..., P]) ndarray

灰度輸入圖像。

tolerance浮點數,可選

當一次迭代中閾值的變化小於該值時,完成計算。默認情況下,這是 image 中強度值之間最小差異的一半。

initial_guessfloat 或 Callable[[array[float]], float], 可選

Li 的迭代方法使用梯度下降來找到最佳閾值。如果圖像強度直方圖包含兩個以上的模式(峰值),則梯度下降可能會陷入局部最優。迭代的初始猜測可以幫助算法找到globally-optimal 閾值。一個浮點值定義了一個特定的起點,而一個可調用對象應該接受一個圖像強度數組並返回一個浮點值。示例有效的可調用對象包括 numpy.mean(默認)、lambda arr: numpy.quantile(arr, 0.95),甚至是 skimage.filters.threshold_otsu()

iter_callback可調用[[浮點],任意],可選

在算法的每次迭代中將在閾值上調用的函數。

返回

threshold浮點數

上閾值。強度高於此值的所有像素都被假定為前景。

參考

1

Li C.H. and Lee C.K. (1993) “Minimum Cross Entropy Thresholding” Pattern Recognition, 26(4): 617-625 DOI:10.1016/0031-3203(93)90115-D

2

Li C.H. and Tam P.K.S. (1998) “An Iterative Algorithm for Minimum Cross Entropy Thresholding” Pattern Recognition Letters, 18(8): 771-776 DOI:10.1016/S0167-8655(98)00057-9

3

Sezgin M. and Sankur B. (2004) “Survey over Image Thresholding Techniques and Quantitative Performance Evaluation” Journal of Electronic Imaging, 13(1): 146-165 DOI:10.1117/1.1631315

4

ImageJ AutoThresholder code, http://fiji.sc/wiki/index.php/Auto_Threshold

例子

>>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_li(image)
>>> binary = image > thresh

相關用法


注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.filters.threshold_li。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。