用法:
skimage.segmentation.flood_fill(image, seed_point, new_value, *, footprint=None, connectivity=None, tolerance=None, in_place=False)
對圖像執行洪水填充。
從特定的seed_point 開始,找到等於或在種子值容差範圍內的連接點,然後設置為new_value。
- image:ndarray
一個 n 維數組。
- seed_point:元組或int
圖像中用作泛濫填充起點的點。如果圖像是一維的,這個點可以作為一個整數給出。
- new_value:圖片類型
設置整個填充的新值。這必須與圖像的 dtype 一致。
- footprint:ndarray,可選
用於確定每個評估像素的鄰域的足跡(結構元素)。它必須隻包含 1 和 0,具有與圖像相同的維數。如果未給出,則所有相鄰像素都被視為鄰域的一部分(完全連接)。
- connectivity:int 可選
用於確定每個評估像素的鄰域的數字。與中心的平方距離小於或等於連通性的相鄰像素被視為鄰居。如果足跡不是無,則忽略。
- tolerance:浮點數或 int 可選
如果 None (默認),相鄰值必須嚴格等於要填充的 seed_point 處的圖像值。這是最快的。如果提供了容差,則會填充與種子點相差在正或負容差範圍內的相鄰點(包括)。
- in_place:布爾型,可選
如果為 True,則將洪水填充應用於圖像。如果為 False,則在不修改輸入圖像的情況下返回洪水填充結果(默認)。
- filled:ndarray
返回一個與圖像形狀相同的數組,其中與種子點相連並等於(或在其容差範圍內)的區域中的值替換為 new_value。
- selem:DEPRECATED
已棄用以支持足跡。
參數:
返回:
其他參數:
注意:
此操作的概念類比是許多光柵圖形程序中的“油漆桶”工具。
例子:
>>> from skimage.morphology import flood_fill >>> 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 填充連接的,完全連接(包括對角線):
>>> flood_fill(image, (1, 1), 5) 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):
>>> flood_fill(image, (1, 1), 5, connectivity=1) 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]])
填充公差:
>>> flood_fill(image, (0, 0), 5, tolerance=1) 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用法及代碼示例
- 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_fill。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。