用法:
skimage.segmentation.flood(image, seed_point, *, footprint=None, connectivity=None, tolerance=None)
對應於洪水填充的掩碼。
從特定的seed_point 開始,找到等於或在種子值容差範圍內的連接點。
- image:ndarray
一個 n 維數組。
- seed_point:元組或int
圖像中用作泛濫填充起點的點。如果圖像是一維的,這個點可以作為一個整數給出。
- footprint:ndarray,可選
用於確定每個評估像素的鄰域的足跡(結構元素)。它必須隻包含 1 和 0,具有與圖像相同的維數。如果未給出,則所有相鄰像素都被視為鄰域的一部分(完全連接)。
- connectivity:int 可選
用於確定每個評估像素的鄰域的數字。距中心的平方距離大於或等於連通性的相鄰像素被視為鄰居。如果足跡不是無,則忽略。
- tolerance:浮點數或 int 可選
如果為 None(默認),則相鄰值必須嚴格等於圖像在 seed_point 處的初始值。這是最快的。如果給出了一個值,將在每個點進行比較,如果在初始值的公差範圍內,也將填充(包括)。
- mask:ndarray
返回一個與圖像形狀相同的布爾數組,其中連接到種子點並等於(或在其容差範圍內)的區域的 True 值。所有其他值為 False。
- selem:DEPRECATED
已棄用以支持足跡。
參數:
返回:
其他參數:
注意:
此操作的概念類比是許多光柵圖形程序中的“油漆桶”工具。這個函數隻返回代表填充的掩碼。
如果出於內存原因需要索引而不是掩碼,用戶可以簡單地對結果運行
numpy.nonzero
例子:
>>> from skimage.morphology import flood >>> image = np.zeros((4, 7), dtype=int) >>> image[1:3, 1:3] = 1 >>> image[3, 0] = 1 >>> image[1:3, 4:6] = 2 >>> image[3, 6] = 3 >>> image array([[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 2, 2, 0], [0, 1, 1, 0, 2, 2, 0], [1, 0, 0, 0, 0, 0, 3]])
用 5 填充連接的,完全連接(包括對角線):
>>> mask = flood(image, (1, 1)) >>> image_flooded = image.copy() >>> image_flooded[mask] = 5 >>> image_flooded array([[0, 0, 0, 0, 0, 0, 0], [0, 5, 5, 0, 2, 2, 0], [0, 5, 5, 0, 2, 2, 0], [5, 0, 0, 0, 0, 0, 3]])
用 5 填充連接的點,不包括對角點(連接 1):
>>> mask = flood(image, (1, 1), connectivity=1) >>> image_flooded = image.copy() >>> image_flooded[mask] = 5 >>> image_flooded array([[0, 0, 0, 0, 0, 0, 0], [0, 5, 5, 0, 2, 2, 0], [0, 5, 5, 0, 2, 2, 0], [1, 0, 0, 0, 0, 0, 3]])
填充公差:
>>> mask = flood(image, (0, 0), tolerance=1) >>> image_flooded = image.copy() >>> image_flooded[mask] = 5 >>> image_flooded array([[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 2, 2, 5], [5, 5, 5, 5, 2, 2, 5], [5, 5, 5, 5, 5, 5, 3]])
相關用法
- Python skimage.segmentation.flood_fill用法及代碼示例
- Python skimage.segmentation.felzenszwalb用法及代碼示例
- Python skimage.segmentation.find_boundaries用法及代碼示例
- Python skimage.segmentation.active_contour用法及代碼示例
- Python skimage.segmentation.relabel_sequential用法及代碼示例
- Python skimage.segmentation.clear_border用法及代碼示例
- Python skimage.segmentation.watershed用法及代碼示例
- Python skimage.segmentation.expand_labels用法及代碼示例
- Python skimage.segmentation.random_walker用法及代碼示例
- Python skimage.segmentation.slic用法及代碼示例
- Python skimage.segmentation.join_segmentations用法及代碼示例
- Python skimage.feature.graycomatrix用法及代碼示例
- Python skimage.color.lab2lch用法及代碼示例
- Python skimage.draw.random_shapes用法及代碼示例
- Python skimage.feature.blob_doh用法及代碼示例
- Python skimage.feature.blob_dog用法及代碼示例
- Python skimage.filters.unsharp_mask用法及代碼示例
- Python skimage.registration.optical_flow_tvl1用法及代碼示例
- Python skimage.filters.rank.noise_filter用法及代碼示例
- Python skimage.exposure.histogram用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.segmentation.flood。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。