Skip to content

Interactive Segmentation

Interactive Segmentation classifies voxels by example. You paint a few voxels as void (pore) or solid, and a random forest1 learns from them, in the spirit of ilastik,2 to label every voxel from features of its neighbourhood rather than from its grey level alone. That lets it separate phases whose grey levels overlap, or follow brightness that drifts across a scan.

  • Solves a two-class pixel classification, slice by slice in XY
  • Method a random forest on multiscale intensity, edge and texture features, from scikit-learn and scikit-image
  • Reports a binary image at the source's size and voxel size
  • How to run it Interactive Segmentation in the User guide

The method

  1. Normalise each slice to \([0, 1]\) with the image's global minimum and maximum, the same bounds everywhere.
  2. Features. Every XY slice that contains painted voxels is described pixel by pixel, at \(n_\sigma\) smoothing scales spaced geometrically from \(\sigma_\text{min}\) to \(\sigma_\text{max}\) (0.5, 1 and 2 voxels by default): intensity, edge strength (Sobel magnitude) and the two eigenvalues of the Hessian, which respond to ridges and blobs. That's \(4 n_\sigma\) numbers per pixel, 12 by default.
  3. Training. A forest of \(n_\text{trees}\) trees (default 50), each at most \(d_\text{max}\) levels deep (default 12), is trained on up to \(n_\text{train}\) painted pixels (default 5000), drawn at random with at most half from each phase, so a long stroke in one phase can't crowd out the other.
  4. Preview. The forest labels one complete slice, so you can paint more and retrain. An XZ or YZ preview is assembled from the XY slices it crosses, so it shows exactly what the full run will produce.
  5. Run. The same forest labels every XY slice of the volume. A pixel is pore when its score \(s\) exceeds the cutoff \(c\) (default 0.5). Pixels you painted keep your label.
Setting Symbol Default Range Meaning
Smallest feature scale (voxels) \(\sigma_\text{min}\) 0.5 0.1–8 Smallest smoothing scale.
Largest feature scale (voxels) \(\sigma_\text{max}\) 2 0.1–8 Largest smoothing scale, at least \(\sigma_\text{min}\).
Number of feature scales \(n_\sigma\) 3 1–4 Number of scales.
Number of trees \(n_\text{trees}\) 50 1–100 Size of the forest.
Maximum tree depth \(d_\text{max}\) 12 1–16 Maximum depth of each tree.
Training samples \(n_\text{train}\) 5000 2–50,000 Painted pixels used for training.
Random seed 0 Seeds the sample draw and the forest, so a run is repeatable.
Void score cutoff \(c\) 0.5 0.001–0.999 Score above which a pixel is void (pore).

Limits

Images can be up to 600 voxels along each axis. The work of a full run, voxels × \(n_\sigma\) × \(n_\text{trees}\) × \(d_\text{max}\), can't exceed that of a \(600^3\) image with the default settings, so a larger forest needs a smaller image. A preview predicts complete XY slices, one for each XY slice you painted on and each slice the preview crosses, and their pixels together can't exceed 15 million. When a request is over a limit, crop or resize the image, paint on fewer XY slices, preview in XY, or return to the default settings.

Reading the result

  • Slice by slice. The forest works in XY, so it doesn't use information from neighbouring slices. Noise that varies from slice to slice can show as streaks in an XZ or YZ view.
  • The score isn't a probability. \(s\) is the average of the trees' pore fractions, a vote, not a calibrated probability. Moving \(c\) trades pore for solid at the boundaries; it doesn't express a confidence level.
  • Paint where it's wrong. A forest only knows the textures it was shown. Examples from several depths, and right at the pore walls, help more than many strokes in the middle of a large pore.
  • Repeatability. With the same examples, settings and Random seed, a run gives the same image.

References


  1. L. Breiman, "Random forests," Machine Learning 45 (2001) 5–32. doi:10.1023/A:1010933404324 ↩

  2. S. Berg et al., "ilastik: interactive machine learning for (bio)image analysis," Nature Methods 16 (2019) 1226–1232. doi:10.1038/s41592-019-0582-9 ↩