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


Python cucim.skimage.morphology.remove_small_holes用法及代碼示例

用法:

cucim.skimage.morphology.remove_small_holes(ar, area_threshold=64, connectivity=1, in_place=False)

刪除小於指定尺寸的連續孔。

參數

arndarray(任意形狀,int 或 bool 類型)

包含感興趣的連接組件的數組。

area_thresholdint,可選(默認值:64)

將被填充的連續孔的最大麵積(以像素為單位)。替換 min_size

connectivityint, {1, 2, ..., ar.ndim},可選(默認值:1)

定義像素鄰域的連通性。

in_place布爾值,可選(默認值:False)

如果 True ,刪除輸入數組本身中的連接組件。否則,請製作副本。

返回

outndarray,與輸入相同的形狀和類型ar

已移除連接組件內帶有小孔的輸入數組。

拋出

TypeError

如果輸入數組的類型無效,例如浮點數或字符串。

ValueError

如果輸入數組包含負值。

注意

如果數組類型是 int,則假定它包含 already-labeled 個對象。標簽不保留在輸出圖像中(此函數始終輸出布爾圖像)。建議使用該函數後完成貼標。

例子

>>> import cupy as cp
>>> from cucim.skimage import morphology
>>> a = cp.array([[1, 1, 1, 1, 1, 0],
...               [1, 1, 1, 0, 1, 0],
...               [1, 0, 0, 1, 1, 0],
...               [1, 1, 1, 1, 1, 0]], bool)
>>> b = morphology.remove_small_holes(a, 2)
>>> b
array([[ True,  True,  True,  True,  True, False],
       [ True,  True,  True,  True,  True, False],
       [ True, False, False,  True,  True, False],
       [ True,  True,  True,  True,  True, False]])
>>> c = morphology.remove_small_holes(a, 2, connectivity=2)
>>> c
array([[ True,  True,  True,  True,  True, False],
       [ True,  True,  True, False,  True, False],
       [ True, False, False,  True,  True, False],
       [ True,  True,  True,  True,  True, False]])
>>> d = morphology.remove_small_holes(a, 2, in_place=True)
>>> d is a
True

相關用法


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