neu_proc.ops.dilate

Label dilation, three ways: edt, fastmorph and spherical.

edt runs on the GPU when one is available; the fastmorph methods have no GPU version and move a GPU array to the CPU with a warning (cpu_only()).

``edt`` is unbounded unless given ``max_distance``. Every background voxel takes the label of the nearest foreground voxel, so labels grow until they meet and no background is left: a Voronoi partition, not a dilation by a radius. On a 16^3 array with two 2^3 seeds, unbounded edt fills all 4096 voxels, fastmorph 128, spherical 64.

max_distance has the units of sampling: in nm with sampling=(z, y, x) in nm, otherwise in voxels, which on an anisotropic volume grows labels lopsidedly in tissue.

The three methods take disjoint parameters (edt: sampling; spherical: radius, anisotropy; fastmorph: iterations, mode). A parameter given to the wrong method is refused with the name of the method that takes it.

Attributes

Functions

accepted(method[, target]) → tuple[str, ...]

The keyword arguments method accepts, read from the implementation's signature.

dilate(arr[, method, max_distance, gpu])

Grow the labels in arr.

Module Contents

neu_proc.ops.dilate.accepted(method: str, target=None) → tuple[str, ...]

The keyword arguments method accepts, read from the implementation’s signature.

neu_proc.ops.dilate.dilate(arr, method: str = 'edt', *, max_distance: float | None = None, gpu: bool | None = None, **kwargs)

Grow the labels in arr.

max_distance bounds the edt method, which is otherwise unbounded; it has the units of sampling (with sampling=(40, 8, 8), 80 means 80 nm), or voxels without it. Other kwargs go to the implementation, after a check that it takes them.

With edt, a CPU array is computed on the GPU when one is available, which is faster even counting both transfers (see backend); the result is returned as numpy. gpu=False (or NEU_PROC_GPU=0) keeps it on the CPU.

neu_proc.ops.dilate.METHODS