A User-friendly, Scalable Toolkit for Multi-class Segmentation of Volumetric Images
SPROUT (Semi-automated Parcellation of Region Outputs Using Thresholding and Transformation)
SPROUT is an interpretable workflow for semi-automated, multi-class segmentation of volumetric images (e.g., CT, MRI). It requires no training data and is designed for researchers facing challenging segmentation tasks, such as structures with fine details or weak boundaries, where data for deep learning is scarce.
Y. He, M. Camaiti, L.E. Roberts, J.M. Mulqueeney, E. Ioannou, M. Didziokas, A. Goswami. 2024.
SPROUT: A User-friendly, Scalable Toolkit for Multi-class Segmentation of Volumetric Images
👉 If you want to jump straight in, see: Quickstart with Demo Data.
-
Python and Environment Setup
- Install Python: If Python is not already installed, we recommend downloading the Anaconda distribution. After providing your email, follow the download link and select the version suitable for your operating system.
- Set up Python Environment:
- For Windows users with Anaconda, open the Anaconda Prompt from the Start menu.
- For other installations, open a terminal with Python access.
-
Create and Configure Python Environment
- SPROUT supports Python 3.10. Required libraries and versions are:
NumPy: 1.26.4 Pandas: 2.2.1 Scikit-image: 0.22.0 Tifffile: 2024.2.12 imagecodecs: 2025.3.30 Pyyaml: 6.0.1 Trimesh: 4.3.1 Matplotlib: 3.8.3 open3d: 0.18.0
- Steps to create the environment:
- Create the environment:
conda create -n sprout python=3.10
- Activate the environment:
conda activate sprout
- Install dependencies:
pip install numpy==1.26.4 pandas==2.2.1 scikit-image==0.22.0 tifffile==2024.2.12 pyyaml==6.0.1 trimesh==4.3.1 matplotlib==3.8.3 open3d==0.18.0 imagecodecs==2025.3.30
- Create the environment:
- SPROUT supports Python 3.10. Required libraries and versions are:
SproutSAM is an optional module that enables prompt-based segmentation using foundation models like SAM and SAM2. If you wish to use SproutSAM, please install the following additional dependencies:
pip install torch torchvision torchaudio
pip install opencv-python-headless
https://pytorch.org/get-started/locally/
You also need to install the SAM and/or SAM2 libraries:
-
git clone https://github.com/facebookresearch/segment-anything.git cd segment-anything pip install -e .
-
git clone https://github.com/facebookresearch/sam2.git cd sam2 pip install -e .
💡 Strongly recommended: napari
SPROUT comes with a napari plugin for interactive 2D/3D visualization and editing of seeds, segmentation results, and more.
To install napari and the SPROUT plugin (napari-sprout
):
pip install napari
cd ./napari_sprout
pip install -e .
You can launch napari by running napari in the command line. The SPROUT plugin will appear under the Plugins menu in the napari UI.
SPROUT follows a two-step workflow for multi-class segmentation:
-
Seed Generation
The goal of this step is to reduce the regions of the image by breaking it into multiple distinct components (splits). There are two strategies:- Vanilla seed generation: generate multiple seeds by varying configurations such as thresholds and erosion steps.
- Adaptive seed generation: automatically combine information across seeds from different configurations to produce a often better and final seed.
-
Seed Growth
- Threshold-based growth: grows a seed by expanding the reduced components back toward their full target shapes. Growth is guided by image intensity and connectivity.
- SproutSAM: seeds are converted into prompts for a segmentation foundation model such as SAM, which then predicts the segmentation. These slice-wise predictions are then fused into a final 3D output.
🧪 Interactive Inspection & Editing
In practice, both seed and grow results often require visualisation, quality checking, or manual editing, depending on your segmentation goals.
To support this, SPROUT is fully integrated into the Napari ecosystem as a plugin, please see napari-sprout.
SPROUT processes 2D and 3D grayscale images stored in TIFF (.tif
, .tiff
) format.
- Supported file types:
.tif
,.tiff
- Image Type: 2D or 3D grayscale images
- Bit Depth: 8-bit, 16-bit, or 32-bit (floating point)
- File Structure:
- 2D images:
(Height, Width)
- 3D images:
(Depth, Height, Width)
- 2D images:
Unsupported inputs: Color images.
See Demo Data and Basic Usage for a quick start.
See Scenarios for advance usage in a Q&A style.
./demo_data
includes a dog skeleton dog_img.tif
, a foraminifera chamber segmentation foram_img.tif
and a 2D cell microscopy image 2d_cell.tif
. Their corresponding seed images are also provided in the same directory.
Additional demo data can be found here.
on a single image
python sprout.py --seeds --config path/to/seed_config.yaml
in batch mode
python sprout.py --seeds --batch --config path/to/batch_seed.yaml
For full details on YAML parameters and other configs see:
For example, see the YAML configuration files in ./template/
.
on a single image
python sprout.py --adaptive_seed --config path/to/adaptive_seed_config.yaml
in batch mode
python sprout.py --adaptive_seed --batch --config path/to/batch_adaptive_seed.yaml
For full details on YAML parameters and other configs see:
For example, see the YAML configuration files in ./template/
.
on a single image
python sprout.py --grow --config path/to/grow_config.yaml
in batch mode
python sprout.py --grow --batch --config path/to/batch_grow.yaml
For full details on YAML parameters and other configs see:
For example, see the YAML configuration files in ./template/
.
on a single image or a folder of images
python sprout.py --sam --config path/to/config.yaml
in batch mode
python sprout.py --sam --batch --config path/to/batch_config.yaml
For full details on YAML parameters and other configs see:
For example, see the YAML configuration files in ./template/
.
sprout.py
can run tasks in parallel using Python’s threading
. Just set num_threads
in your config to speed up processing, especially for large datasets.
SPROUT also provides a napari plugin (napari-sprout
): Plugins → SPROUT
From here, you can launch a set of tools to load, view, and edit your data.
-
SPROUT_main
GUI for running seed generation, adaptive seed generation, and growth.
Parameters match those used in the command-line scripts. -
SPROUT_load
Batch loader for multiple images or segmentations. -
SPROUT_edit
Interactive editing of segmentation results such as:-
Click to keep or remove regions
-
Re-assign class numbers (e.g. merge
i → j
, deletei → 0
) -
Split disconnected regions
-
-
SPROUT_map
Map regions to a semantic class scheme, e.g.1 → bone_1
,2 → bone_2
. -
SPROUT_tools
Miscellaneous tools, including:-
Inspect reference shapes (e.g. show a ball of radius 10 pixels)
-
Generate batch-processing CSVs, can provide per-image adaptive thresholds (e.g. Otsu)
-
-
SPROUT_info
Inspect information (e.g., resolutions, how many segmentation classes) of images or segmentations.
In addition to napari-sprout
, napari also provides powerful editing options (e.g. Brush to add regions, Erase to remove).
You can also visualize, inspect, and edit seeds or results using 3D image processing tools such as 3D Slicer, DragonFly, and AVIZO. Alternatively, you can generate meshes and view or edit them in mesh-based tools like MeshLab. See Extra section
Batch processing results of segmenting dog bones in CT scans with varying anatomy and postures.
Batch processing results of segmenting foram binary segmentation (supports segmentation masks as input too) with variable numbers of chambers
Gallery of other results
Note: All results underwent manual post-processing primarily to verify and correct segmentation errors.
You can use other tools to visualize and edit SPROUT's segmentation results, see Optional Tools for details.
In napari-sprout and plugins, we provided GUI version of editing results. You can also find the script-version in Helper Functions.
SPROUT was inspired by BounTI, a boundary-preserving threshold iteration approach:
M. Didziokas, E. Pauws, L. Kölby, R. H. Khonsari, M. Moazen. 2024.
BounTI: A user-friendly tool for automatic hard tissue segmentation. Journal of Anatomy 245, 829–841.
The script ./BounTI/run_bounti_mp.py
is designed to run BounTI and BounTI Flood using a multithreaded approach. It efficiently processes a list of initial thresholds in parallel, leveraging multiple threads for improved performance.