用法:
cucim.skimage.filters.threshold_local(image, block_size, method='gaussian', offset=0, mode='reflect', param=None, cval=0)
基於局部像素鄰域計算閾值掩碼圖像。
也稱為自適應或動態閾值。閾值是像素局部鄰域的加權平均值減去常數。或者,閾值可以由給定函數使用‘generic’ 方法動態確定。
- image:(N, M) ndarray
輸入圖像。
- block_size:int
用於計算閾值的像素鄰域的奇數大小(例如 3、5、7、...、21、...)。
- method:{‘generic’, ‘gaussian’, ‘mean’, ‘median’},可選
用於確定加權平均圖像中局部鄰域的自適應閾值的方法。
- ‘generic’:使用自定義函數(見
param
參數) - ‘gaussian’:應用高斯濾波器(請參閱
param
參數以了解自定義 sigma 值) - ‘mean’:應用算術平均濾波器
- ‘median’:應用中值排名過濾器
默認情況下使用‘gaussian’ 方法。
- ‘generic’:使用自定義函數(見
- offset:浮點數,可選
從鄰域的加權平均值中減去常數以計算局部閾值。默認偏移量為 0。
- mode:{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’},可選
mode 參數確定如何處理數組邊界,其中 cval 是 mode 等於 ‘constant’ 時的值。默認為‘reflect’。
- param:{int,函數},可選
為 ‘gaussian’ 方法指定 sigma 或為 ‘generic’ 方法指定函數對象。此函數將局部鄰域的平麵數組作為單個參數,並返回計算的中心像素閾值。
- cval:浮點數,可選
如果模式為‘constant’,則填充過去輸入邊的值。
- threshold:(N, M) ndarray
閾值圖像。輸入圖像中高於閾值圖像中相應像素的所有像素都被視為前景。
參數:
返回:
參考:
例子:
>>> from skimage.data import camera >>> image = camera()[:50, :50] >>> binary_image1 = image > threshold_local(image, 15, 'mean') >>> func = lambda arr: arr.mean() >>> binary_image2 = image > threshold_local(image, 15, 'generic', ... param=func)
相關用法
- Python cucim.skimage.filters.threshold_li用法及代碼示例
- Python cucim.skimage.filters.threshold_mean用法及代碼示例
- Python cucim.skimage.filters.threshold_niblack用法及代碼示例
- Python cucim.skimage.filters.threshold_isodata用法及代碼示例
- Python cucim.skimage.filters.threshold_otsu用法及代碼示例
- Python cucim.skimage.filters.threshold_sauvola用法及代碼示例
- Python cucim.skimage.filters.threshold_yen用法及代碼示例
- Python cucim.skimage.filters.threshold_minimum用法及代碼示例
- Python cucim.skimage.filters.threshold_multiotsu用法及代碼示例
- Python cucim.skimage.filters.threshold_triangle用法及代碼示例
- Python cucim.skimage.filters.try_all_threshold用法及代碼示例
- Python cucim.skimage.filters.roberts_neg_diag用法及代碼示例
- Python cucim.skimage.filters.gabor用法及代碼示例
- Python cucim.skimage.filters.roberts_pos_diag用法及代碼示例
- Python cucim.skimage.filters.roberts用法及代碼示例
- Python cucim.skimage.filters.gabor_kernel用法及代碼示例
- Python cucim.skimage.filters.sobel_v用法及代碼示例
- Python cucim.skimage.filters.sobel_h用法及代碼示例
- Python cucim.skimage.filters.sobel用法及代碼示例
- Python cucim.skimage.filters.gaussian用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cucim.skimage.filters.threshold_local。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。