skimage 0.17.2

NotesParametersReturnsBackRef
flood_fill(image, seed_point, new_value, *, selem=None, connectivity=None, tolerance=None, in_place=False, inplace=None)

Starting at a specific :None:None:`seed_point`, connected points equal or within tolerance of the seed value are found, then set to :None:None:`new_value`.

Notes

The conceptual analogy of this operation is the 'paint bucket' tool in many raster graphics programs.

Parameters

image : ndarray

An n-dimensional array.

seed_point : tuple or int

The point in :None:None:`image` used as the starting point for the flood fill. If the image is 1D, this point may be given as an integer.

new_value : `image` type

New value to set the entire fill. This must be chosen in agreement with the dtype of :None:None:`image`.

selem : ndarray, optional

A 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 :None:None:`image`. If not given, all adjacent pixels are considered as part of the neighborhood (fully connected).

connectivity : int, optional

A number used to determine the neighborhood of each evaluated pixel. Adjacent pixels whose squared distance from the center is less than or equal to :None:None:`connectivity` are considered neighbors. Ignored if selem is not None.

tolerance : float or int, optional

If None (default), adjacent values must be strictly equal to the value of :None:None:`image` at :None:None:`seed_point` to 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, optional

If True, flood filling is applied to :None:None:`image` in place. If False, the flood filled result is returned without modifying the input :None:None:`image` (default).

inplace : bool, optional

This parameter is deprecated and will be removed in version 0.19.0 in favor of in_place. If True, flood filling is applied to :None:None:`image` inplace. If False, the flood filled result is returned without modifying the input :None:None:`image` (default).

Returns

filled : ndarray

An array with the same shape as :None:None:`image` is returned, with values in areas connected to and equal (or within tolerance of) the seed point replaced with :None:None:`new_value`.

Perform flood filling on an image.

Examples

This example is valid syntax, but we were not able to check execution
>>> 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]])

Fill connected ones with 5, with full connectivity (diagonals included):

This example is valid syntax, but we were not able to check execution
>>> 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]])

Fill connected ones with 5, excluding diagonal points (connectivity 1):

This example is valid syntax, but we were not able to check execution
>>> 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]])

Fill with a tolerance:

This example is valid syntax, but we were not able to check execution
>>> 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]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

skimage.morphology._flood_fill.flood_fill

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /skimage/morphology/_flood_fill.py#15
type: <class 'function'>
Commit: