neu_proc.ops.measure

Readings over a label array: voxel counts, component counts.

Label 0 is background, always, and is never reported (neu-vol convert --background normalises a source’s background to 0, and cc3d treats 0 as background regardless). The background count is arr.size - sum(sizes(arr).values()).

Functions

component_sizes(arr[, connectivity, sort, descending]) → dict[int, numpy.ndarray]

{label: sizes of its connected components, largest first}, excluding label 0.

flat_component_sizes(arr[, connectivity, sort, descending]) → numpy.ndarray

Every component size in the volume, pooled across labels.

sizes(arr, *[, exclude_margin, sort, descending, ...]) → dict[int, int]

{label: voxel count} for every label present except 0.

Module Contents

neu_proc.ops.measure.component_sizes(arr, connectivity=26, *, sort: bool = False, descending=True) → dict[int, numpy.ndarray]

{label: sizes of its connected components, largest first}, excluding label 0.

Each component lies inside one label, so a single scatter of arr into a table indexed by component id finds every component’s label; the cost does not grow with the number of labels.

neu_proc.ops.measure.flat_component_sizes(arr, connectivity=26, *, sort: bool = False, descending=True) → numpy.ndarray

Every component size in the volume, pooled across labels.

neu_proc.ops.measure.sizes(arr, *, exclude_margin: int = 0, sort: bool = False, descending=True, skip_relabel: bool = False) → dict[int, int]

{label: voxel count} for every label present except 0.

exclude_margin reports only labels present in the interior, exclude_margin voxels in from every face, with their full counts. skip_relabel skips the fastremap.renumber step, for arrays whose labels are already small integers.