Class LabelsToSeeds

java.lang.Object
sc.fiji.snt.seed.LabelsToSeeds

public final class LabelsToSeeds extends Object
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) and 1.0 (largest label). If all labels share the same volume, confidence is set to 1.0.
Author:
Tiago Ferreira
  • Method Details

    • compute

      public static List<SeedPoint> compute(ij.ImagePlus imp, double minConfidence, String type, String source)
      Computes one SeedPoint per non-zero label in imp.
      Parameters:
      imp - a 2D or 3D labels image. Channel and frame come from imp's active position
      minConfidence - floor of the volume -> confidence map, in [0, 1]. The smallest label gets this value, the largest gets 1.0.
      type - SeedPoint.type for every produced seed (e.g. "soma"). null -> ""
      source - SeedPoint.source for 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 whether imp is a binary mask, i.e. all non-zero voxels share a single value.
      Parameters:
      imp - the candidate image. null triggers an IllegalArgumentException.
      Returns:
      true if exactly one distinct non-zero value is present. An all-zero image returns false
    • 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 for compute(ImagePlus, double, String, String). Operates on the active C/T 3D slice of mask; 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 - if true, use the more permissive structuring element (8-/26-connected); else use face-connected (4-/6-connected).
      Returns:
      a labeled ImagePlus with one distinct integer per component. Background remains 0. Same dimensions and calibration as mask.