skimage 0.17.2

NotesParametersReturnsBackRef
reconstruction(seed, mask, method='dilation', selem=None, offset=None)

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 structuring element 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 structuring element, 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.

Notes

The algorithm is taken from . Applications for greyscale reconstruction are discussed in and .

Parameters

seed : ndarray

The seed image (a.k.a. marker image), which specifies the values that are dilated or eroded.

mask : ndarray

The maximum (dilation) / minimum (erosion) allowed value at each pixel.

method : {'dilation'|'erosion'}, optional

Perform 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'.

selem : ndarray, optional

The 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, optional

The coordinates of the center of the structuring element. Default is located on the geometrical center of the selem, in that case selem dimensions must be odd.

Returns

reconstructed : ndarray

The result of morphological reconstruction.

Perform a morphological reconstruction of an image.

Examples

This example is valid syntax, but we were not able to check execution
>>> import numpy as np
... from skimage.morphology import reconstruction

First, we create a sinusoidal mask image with peaks at middle and ends.

This example is valid syntax, but we were not able to check execution
>>> x = np.linspace(0, 4 * np.pi)
... y_mask = np.cos(x)

Then, we create a seed image initialized to the minimum mask value (for reconstruction by dilation, min-intensity values don't spread) and add "seeds" to the left and right peak, but at a fraction of peak value (1).

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

The reconstructed image (or curve, in this case) is exactly the same as the mask image, except that the peaks are truncated to 0.5 and 0. The middle peak disappears completely: Since there were no seed values in this peak region, its reconstructed value is truncated to the surrounding value (-1).

As a more practical example, we try to extract the bright features of an image by subtracting a background image created by reconstruction.

This example is valid syntax, but we were not able to check execution
>>> y, x = np.mgrid[:20:0.5, :20:0.5]
... bumps = np.sin(x) + np.sin(y)

To create the background image, set the mask image to the original image, and the seed image to the original image with an intensity offset, h.

This example is valid syntax, but we were not able to check execution
>>> h = 0.3
... seed = bumps - h
... background = reconstruction(seed, bumps)

The resulting reconstructed image looks exactly like the original image, but with the peaks of the bumps cut off. Subtracting this reconstructed image from the original image leaves just the peaks of the bumps

This example is valid syntax, but we were not able to check execution
>>> hdome = bumps - background

This operation is known as the h-dome of the image and leaves features of height h in the subtracted image.

See :

Back References

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

skimage.morphology.greyreconstruct.reconstruction

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