morphogen.analysis.random_sets

Random sets and random functions probed by structuring elements (Matheron 1975; Serra 1982; Jeulin 2021).

A structuring element K placed at every point x probes a set A: the dilation A (+) K' = {x : K_x hits A} and the erosion A (-) K' = {x : K_x inside A} (K' the transposed element). A random closed set is characterized by its Choquet capacity T(K) = P(K hits A) = 1 - Q(K), Q(K) = P(K inside A^c), which for an ergodic set is the volume fraction of A (+) K' in one realization. Pairs of points give the covariance (T({0, h}) = 2 p - C(h)), segments the lineal path of the complement, balls the spherical contact distribution. A grey-level image Z (a random function) is probed by its erosion by pairs of points: the morphological covariance E[min(Z(x), Z(x + h))]; the Minkowski functionals of its excursion sets {Z > u} are curves of the level u.

Periodic images are probed on the torus; other images by minus sampling: only the positions where the element lies inside the box are counted.

class morphogen.analysis.random_sets.Capacity(element: str, sizes: ndarray, values: ndarray, volume_fraction: float)[source]

Bases: object

Choquet capacity T(K) of a phase for structuring elements of growing size: the radius of balls, the length of segments, the distance of pairs of points, the edge of cubes (sizes, in length units).

property complement: ndarray

Q(K) = P(K inside A^c) = 1 - T(K).

contact_distribution() → ndarray[source]

H(r) = 1 - Q(K_r) / q: the distribution function of the distance from a point of the complement to the phase, measured with the element (the spherical contact distribution for balls, the linear one for segments).

class morphogen.analysis.random_sets.MorphologicalCovariance(lags: dict[str, ndarray], values: dict[str, ndarray], volume_fraction: float)[source]

Bases: AxisFunction

Mean of the erosion (or dilation) of a grey-level image by pairs of points along the x, y and z axes; volume_fraction holds the mean of the image.

morphogen.analysis.random_sets.choquet_capacity(image, element: str = 'ball', sizes=None, *, phase: int = 1, direction=(1, 0, 0), periodic=None) → Capacity[source]

Choquet capacity T(K) = P(K hits A) of phase (the set A) for structuring elements K of the given sizes (length units), estimated as the volume fraction of the dilation of A by K.

element: "ball" (radius; digital balls of the voxel centres closer than the radius, through the Euclidean distance map), "segment" (length, along the grid direction, e.g. (1, 1, 0)), "pair" (two points distant of the size along direction: T = 2 p - C(h)) or "cube" (edge). Segments, pairs and cubes have points on the grid: their sizes are rounded to whole steps and the measured sizes are returned. sizes defaults to one voxel steps up to a quarter of the box (half of it for segments and pairs).

morphogen.analysis.random_sets.dilation(image, element: str, size: float, *, phase: int = 1, direction=(1, 0, 0), periodic=None)[source]

Indicator of A (+) K': the voxels x where K_x hits the phase (K as in choquet_capacity(), the element anchored at its first point or its centre).

morphogen.analysis.random_sets.erosion(image, element: str, size: float, *, phase: int = 1, direction=(1, 0, 0), periodic=None)[source]

Indicator of A (-) K': the voxels x where K_x lies inside the phase (outside a non-periodic box counts as outside the phase).

morphogen.analysis.random_sets.opening(image, element: str, size: float, *, phase: int = 1, direction=(1, 0, 0), periodic=None)[source]

(A (-) K') (+) K: the union of the translates of K inside the phase.

morphogen.analysis.random_sets.closing(image, element: str, size: float, *, phase: int = 1, direction=(1, 0, 0), periodic=None)[source]

(A (+) K') (-) K: the complement of the opening of the complement.

morphogen.analysis.random_sets.morphological_covariance(image, *, max_lag: int | None = None, periodic=None, operation: str = 'erosion') → MorphologicalCovariance[source]

E[min(Z(x), Z(x + h))] (erosion by pairs of points; operation="dilation": the maximum) of a grey-level image along the three axes, lags 0..max_lag voxels (default half the box). For a binary image the erosion gives the covariance.

morphogen.analysis.random_sets.minkowski_curves(image, thresholds, *, periodic=None) → dict[str, ndarray][source]

Densities of the four Minkowski functionals of the excursion sets {Z > u} of a grey-level image for the levels thresholds: the volume fraction, the specific surface, the integral of mean curvature and the Euler characteristic per unit volume.