Metadata-Version: 2.5
Name: bioimageflow-segmentation-tools
Version: 0.2.0
Summary: Segmentation tools for BioImageFlow
Project-URL: Homepage, https://github.com/Inria-SAIRPICO/bioimageflow
Project-URL: Documentation, https://bioimageflow.readthedocs.io/latest/
Project-URL: Repository, https://github.com/Inria-SAIRPICO/bioimageflow
Project-URL: Issues, https://github.com/Inria-SAIRPICO/bioimageflow/issues
Author: BioImageFlow Contributors
License-Expression: BSD-4-Clause
License-File: LICENSE
Keywords: bioimage-analysis,bioimageflow,microscopy,workflow
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.10
Requires-Dist: bioimageflow-core<0.4,>=0.3.0
Requires-Dist: imageio>=2.31.0
Requires-Dist: numpy>=1.23.5
Requires-Dist: scikit-image>=0.21.0
Requires-Dist: scipy>=1.10.0
Description-Content-Type: text/markdown

# bioimageflow-segmentation-tools

Segmentation-focused tool package for BioImageFlow.

## Tools

- `Cellpose3`: Cellpose v3 pretrained model wrapper.
- `CellposeSAM`: Cellpose-SAM pretrained model wrapper.
- `StarDistSegmenter`: StarDist 2D pretrained model wrapper.
- `ThresholdSegment`: threshold an intensity image and label connected foreground objects.
- `OtsuThresholdSegment`: compute a global Otsu threshold and label foreground objects.
- `LocalThresholdSegment`: compute a Sauvola local threshold and label foreground objects.
- `WatershedSegment`: split foreground regions from marker labels or connected components.
- `DistanceWatershedSegment`: split foreground with marker-free distance-transform watershed.
- `SplitTouchingObjects`: split clumped labels using distance-transform watershed.
- `FilterLabels`: remove labels by area, border contact, intensity, and shape constraints.
- `PostprocessLabels`: remove small labels and relabel label images sequentially.

Classical connected-component tools use face connectivity by default and treat `image > threshold` as foreground when `above` is enabled. Label inputs are validated as finite, integral, non-negative arrays, and object counts are based on distinct positive IDs rather than the largest ID.
Default label-output paths use TIFF rather than inheriting an input extension that may be lossy or unable to store UInt32 label IDs.

Heavy model dependencies are declared in isolated `EnvironmentSpec` objects and imported only inside `process_row`. Importing this package does not require Cellpose, TensorFlow, StarDist, or other model packages to be installed in the main process.
`Cellpose3`, `CellposeSAM`, and `StarDistSegmenter` lazily keep one model per worker-side tool instance.
Repeated calls with the same model selection reuse the weights; changing `model_type` or `model_name` replaces the cached model, and `clear_model_cache()` releases it explicitly.
Applications can invalidate remote worker caches by stopping the corresponding Wetlands environment.

The former `nnInteractive` wrapper was removed because nnInteractive requires a stateful volumetric inference session; its public point-list-to-2D-mask contract did not represent the upstream API.

## Example

```python
from bioimageflow_core import Arguments
from bioimageflow_segmentation_tools import ThresholdSegment

segment = ThresholdSegment()
result = segment.process_row(
    Arguments(
        input_image="input.tif",
        threshold=128.0,
        labels="labels.tif",
        above=True,
    )
)
```

Workflow graph construction with `segment(...)` requires installing the main-process `bioimageflow` orchestrator alongside this package.
