skimage 0.17.2

NotesParametersReturnsBackRef
local_minima(image, selem=None, connectivity=None, indices=False, allow_borders=True)

The local minima are defined as connected sets of pixels with equal gray level (plateaus) strictly smaller than the gray levels of all pixels in the neighborhood.

Notes

This function operates on the following ideas:

  1. Make a first pass over the image's last dimension and flag candidates for local minima by comparing pixels in only one direction. If the pixels aren't connected in the last dimension all pixels are flagged as candidates instead.

For each candidate:

  1. Perform a flood-fill to find all connected pixels that have the same gray value and are part of the plateau.

  2. Consider the connected neighborhood of a plateau: if no bordering sample has a smaller gray level, mark the plateau as a definite local minimum.

Parameters

image : ndarray

An n-dimensional array.

selem : ndarray, optional

A structuring element used to determine the neighborhood of each evaluated pixel ( True denotes a connected pixel). It must be a boolean array and have the same number of dimensions as :None:None:`image`. If neither selem nor :None:None:`connectivity` are given, all adjacent pixels are considered as part of the neighborhood.

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.

indices : bool, optional

If True, the output will be a tuple of one-dimensional arrays representing the indices of local minima in each dimension. If False, the output will be a boolean array with the same shape as :None:None:`image`.

allow_borders : bool, optional

If true, plateaus that touch the image border are valid minima.

Returns

minima : ndarray or tuple[ndarray]

If :None:None:`indices` is false, a boolean array with the same shape as :None:None:`image` is returned with True indicating the position of local minima ( False otherwise). If :None:None:`indices` is true, a tuple of one-dimensional arrays containing the coordinates (indices) of all found minima.

Find local minima of n-dimensional array.

See Also

skimage.morphology.h_maxima
skimage.morphology.h_minima
skimage.morphology.local_maxima

Examples

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

Find local minima by comparing to all neighboring pixels (maximal connectivity):

This example is valid syntax, but we were not able to check execution
>>> local_minima(image)
array([[False, False, False, False, False, False, False],
       [False,  True,  True, False, False, False, False],
       [False,  True,  True, False, False, False, False],
       [ True, False, False, False, False, False,  True]])
This example is valid syntax, but we were not able to check execution
>>> local_minima(image, indices=True)
(array([1, 1, 2, 2, 3, 3]), array([1, 2, 1, 2, 0, 6]))

Find local minima without comparing to diagonal pixels (connectivity 1):

This example is valid syntax, but we were not able to check execution
>>> local_minima(image, connectivity=1)
array([[False, False, False, False, False, False, False],
       [False,  True,  True, False,  True,  True, False],
       [False,  True,  True, False,  True,  True, False],
       [ True, False, False, False, False, False,  True]])

and exclude minima that border the image edge:

This example is valid syntax, but we were not able to check execution
>>> local_minima(image, connectivity=1, allow_borders=False)
array([[False, False, False, False, False, False, False],
       [False,  True,  True, False,  True,  True, False],
       [False,  True,  True, False,  True,  True, False],
       [False, False, False, False, False, False, False]])
See :

Back References

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

skimage.morphology.extrema.local_maxima skimage.morphology.extrema.h_minima skimage.morphology.extrema.h_maxima skimage.morphology.extrema.local_minima

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/extrema.py#429
type: <class 'function'>
Commit: