bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / morphology / grayreconstruct / reconstruction
function
skimage.morphology.grayreconstruct:reconstruction
source: /dev/scikit-image/src/skimage/morphology/grayreconstruct.py :8
Signature
def reconstruction ( seed , mask , method = dilation , footprint = None , offset = None ) Summary
Perform a morphological reconstruction of an image.
Extended Summary
Morphological reconstruction by dilation is similar to basic morphological dilation: high-intensity values will replace nearby low-intensity values. The basic dilation operator, however, uses a footprint to determine how far a value in the input image can spread. In contrast, reconstruction uses two images: a "seed" image, which specifies the values that spread, and a "mask" image, which gives the maximum allowed value at each pixel. The mask image, like the footprint, limits the spread of high-intensity values. Reconstruction by erosion is simply the inverse: low-intensity values spread from the seed image and are limited by the mask image, which represents the minimum allowed value.
Alternatively, you can think of reconstruction as a way to isolate the connected regions of an image. For dilation, reconstruction connects regions marked by local maxima in the seed image: neighboring pixels less-than-or-equal-to those seeds are connected to the seeded region. Local maxima with values larger than the seed image will get truncated to the seed value.
Parameters
seed: ndarrayThe seed image (a.k.a. marker image), which specifies the values that are dilated or eroded.
mask: ndarrayThe maximum (dilation) / minimum (erosion) allowed value at each pixel.
method: {'dilation'|'erosion'}, optionalPerform reconstruction by dilation or erosion. In dilation (or erosion), the seed image is dilated (or eroded) until limited by the mask image. For dilation, each seed value must be less than or equal to the corresponding mask value; for erosion, the reverse is true. Default is 'dilation'.
footprint: ndarray, optionalThe neighborhood expressed as an n-D array of 1's and 0's. Default is the n-D square of radius equal to 1 (i.e. a 3x3 square for 2D images, a 3x3x3 cube for 3D images, etc.)
offset: ndarray, optionalThe coordinates of the center of the footprint. Default is located on the geometrical center of the footprint, in that case footprint dimensions must be odd.
Returns
reconstructed: ndarrayThe result of morphological reconstruction.
Notes
The algorithm is taken from [1]. Applications for grayscale reconstruction are discussed in [2] and [3].
Examples
import numpy as np from skimage.morphology import reconstruction✓
x = np.linspace(0, 4 * np.pi) y_mask = np.cos(x)✓
y_seed = y_mask.min() * np.ones_like(x) y_seed[0] = 0.5 y_seed[-1] = 0 y_rec = reconstruction(y_seed, y_mask)✓
y, x = np.mgrid[:20:0.5, :20:0.5] bumps = np.sin(x) + np.sin(y)✓
h = 0.3 seed = bumps - h background = reconstruction(seed, bumps)✓
hdome = bumps - background
✓Aliases
-
skimage.morphology.reconstruction