Regional extrema¶
Regional extrema detection module.
Detection of local minima in a membrane marked intensity image, allows finding seeds for the watershed algorithm. Detection of local maxima in a nuclei marked intensity image, allows finding nuclei position in the image.
- timagetk.algorithms.regionalext.regional_extrema(image, height, method='minima', **kwargs)[source]¶
Regional extrema detection algorithm.
Valid method values are:
minima, for detection of connected regional minima
maxima, for detection of connected regional maxima
- Parameters:
image (timagetk.SpatialImage or timagetk.MultiChannelImage) – Input image to use for regional extrema detection.
height (int or float) – The height of the regional extrema to detect.
method ({'minima', 'maxima'}) – The method to use for regional extrema detection,
DEF_RE_METHOD
by default.channel (str) – If a
MultiChannelImage
is used as input image, select the channel to use with this algorithm.connectivity ({4, 6, 8, 10, 18, 26}) – The connectivity of the structuring elements,
DEF_CONNECTIVITY
by default. Connectivity is among the 4-, 6-, 8-, 18-, 26-neighborhoods. 4 and 8 are for 2D images, the others for 3D images.params (str) – CLI parameter string used by
vt.cell_filter
method.
- Returns:
LabelledImage – Image with labelled regional minima or maxima.
- Raises:
TypeError – If
image
is not aLabelledImage
.ValueError – If the image returned by
vt.regionalext
isNone
.
See also
timagetk.third_party.vt_parser.REGIONALEXT_METHODS
,timagetk.third_party.vt_parser.DEF_RE_METHOD
,timagetk.third_party.vt_parser.DEF_CONNECTIVITY
,timagetk.third_party.vt_parser.regionalext_kwargs
,timagetk.third_party.vt_parser.general_kwargs
,timagetk.third_party.vt_parser.parallel_kwargs
Notes
A regional minimum, resp. maximum, M of an image I at elevation t is a connected component of pixels (or voxels) with the value t whose external boundary pixels (or voxels) have a value strictly greater, resp. less, than t [Soille]. The result image is then a binary image, where
1
indicate a regional minimum, resp. maximum.Providing a contrast criterion h remove the regional minima, resp. maxima, whose depth is higher, resp. lower, to this threshold level h. It is then called a h-minima transformation, resp. h-maxima. The result image is then a height image, i.e. the pixels (or voxels) values correspond to the depth of the regional extrema.
References
Examples
>>> import numpy as np >>> from timagetk.io.util import shared_dataset >>> from timagetk.io import imread >>> from timagetk.algorithms.regionalext import regional_extrema >>> from timagetk.visu.mplt import grayscale_imshow
>>> # Example #1 - height-5 local minima detection on 3D image: >>> image = imread(shared_dataset("p58")[0]) >>> regmin_img = regional_extrema(image, height=3, method='minima') >>> np.unique(regmin_img)
>>> # Example #2 - local minima detection on 2D image for various height values: >>> zslice = 10 >>> subimg = image.get_slice(zslice, 'z') >>> hmins = [10, 25, 50] >>> n_hmins = len(hmins) >>> extmin_imgs = {hmin: regional_extrema(subimg, hmin, "minima", connectivity=8) for hmin in hmins} >>> images = [subimg] + [extmin_imgs[hmin] for hmin in hmins] >>> titles = ["Original (z-slice: {})".format(zslice)] + ["H-minima (h: {})".format(hmin) for hmin in hmins] >>> grayscale_imshow(images, title=titles, val_range=['type']+['auto']*n_hmins, cmap=['gray']+['viridis']*n_hmins)