bundles / skimage latest / skimage / morphology / _flood_fill / flood_fill
function
skimage.morphology._flood_fill:flood_fill
source: /dev/scikit-image/src/skimage/morphology/_flood_fill.py :19
Signature
def flood_fill ( image , seed_point , new_value , * , footprint = None , connectivity = None , tolerance = None , in_place = False ) Summary
Perform flood filling on an image.
Extended Summary
Starting at a specific seed_point, connected points equal or within tolerance of the seed value are found, then set to new_value.
Parameters
image: ndarrayAn n-dimensional array.
seed_point: tuple or intThe point in
imageused as the starting point for the flood fill. If the image is 1D, this point may be given as an integer.new_value: `image` typeNew value to set the entire fill. This must be chosen in agreement with the dtype of
image.footprint: ndarray, optionalThe footprint (structuring element) used to determine the neighborhood of each evaluated pixel. It must contain only 1's and 0's, have the same number of dimensions as
image. If not given, all adjacent pixels are considered as part of the neighborhood (fully connected).connectivity: int, optionalA number used to determine the neighborhood of each evaluated pixel. Adjacent pixels whose squared distance from the center is less than or equal to
connectivityare considered neighbors. Ignored iffootprintis not None.tolerance: float or int, optionalIf None (default), adjacent values must be strictly equal to the value of
imageatseed_pointto be filled. This is fastest. If a tolerance is provided, adjacent points with values within plus or minus tolerance from the seed point are filled (inclusive).in_place: bool, optionalIf True, flood filling is applied to
imagein place. If False, the flood filled result is returned without modifying the inputimage(default).
Returns
filled: ndarrayAn array with the same shape as
imageis returned, with values in areas connected to and equal (or within tolerance of) the seed point replaced withnew_value.
Notes
The conceptual analogy of this operation is the 'paint bucket' tool in many raster graphics programs.
Examples
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✓
flood_fill(image, (1, 1), 5)
✓flood_fill(image, (1, 1), 5, connectivity=1)
✓flood_fill(image, (0, 0), 5, tolerance=1)
✓Aliases
-
skimage.morphology.flood_fill