Package sc.fiji.snt.seed
Class LabelsToSeeds
java.lang.Object
sc.fiji.snt.seed.LabelsToSeeds
Helper that turns a labels image (e.g. cellpose, Labkit, StarDist
segmentation output) into a list of
SeedPoints, one per non-zero
label.
For each label N:
- centroid is the voxel-average position multiplied by the image calibration to physical units;
- radius is the radius of the sphere whose volume equals the label's
total volume (
r = cbrt(3V / 4pi)); - confidence is the linear interpolation of the label's volume between
minConfidence(smallest label in the image) and1.0(largest label). If all labels share the same volume, confidence is set to1.0.
- Author:
- Tiago Ferreira
-
Method Summary
Modifier and TypeMethodDescriptionComputes oneSeedPointper non-zero label inimp.static <T extends net.imglib2.type.numeric.RealType<T>>
ij.ImagePlusconnectedComponents(ij.ImagePlus mask, boolean fullyConnected) Labels the connected components of a binary mask, returning a new labels image suitable forcompute(ImagePlus, double, String, String).static <T extends net.imglib2.type.numeric.RealType<T>>
booleanisBinaryMask(ij.ImagePlus imp) Detects whetherimpis a binary mask, i.e. all non-zero voxels share a single value.
-
Method Details
-
compute
public static List<SeedPoint> compute(ij.ImagePlus imp, double minConfidence, String type, String source) Computes oneSeedPointper non-zero label inimp.- Parameters:
imp- a 2D or 3D labels image. Channel and frame come fromimp's active positionminConfidence- floor of the volume -> confidence map, in[0, 1]. The smallest label gets this value, the largest gets1.0.type-SeedPoint.typefor every produced seed (e.g."soma").null->""source-SeedPoint.sourcefor every produced seed (e.g."labels-image:cellpose.tif")null->"".- Returns:
- a fresh list of seeds, one per label, in label-ID order. Empty if no non-zero labels are found.
-
isBinaryMask
public static <T extends net.imglib2.type.numeric.RealType<T>> boolean isBinaryMask(ij.ImagePlus imp) Detects whetherimpis a binary mask, i.e. all non-zero voxels share a single value.- Parameters:
imp- the candidate image.nulltriggers anIllegalArgumentException.- Returns:
trueif exactly one distinct non-zero value is present. An all-zero image returnsfalse
-
connectedComponents
public static <T extends net.imglib2.type.numeric.RealType<T>> ij.ImagePlus connectedComponents(ij.ImagePlus mask, boolean fullyConnected) Labels the connected components of a binary mask, returning a new labels image suitable forcompute(ImagePlus, double, String, String). Operates on the active C/T 3D slice ofmask; each non-zero voxel is treated as foreground, every distinct connected region gets a unique integer label. The result inherits the input's calibration.Connectivity is binary:
fullyConnected = true: 8-connected in 2D, 26-connected in 3D.fullyConnected = false: 4-connected in 2D, 6-connected in 3D.
- Parameters:
mask- a binary mask (any RealType; non-zero = foreground). Multi-label images can be passed safely: every non-zero voxel is collapsed to foreground first, so calling this on a labels image is equivalent to re-running CCA on its non-zero union.fullyConnected- iftrue, use the more permissive structuring element (8-/26-connected); else use face-connected (4-/6-connected).- Returns:
- a labeled
ImagePluswith one distinct integer per component. Background remains 0. Same dimensions and calibration asmask.
-