stl2mask

Maintenance mode

A command-line tool to convert mesh segmentations (STL, OBJ) to binary masks and back, for use in medical image processing pipelines.

About

stl2mask is a command-line tool that converts 3D mesh segmentations (STL, OBJ) to binary mask images (e.g. NIfTI, MHA) and back. Given a mesh and a reference image that defines the output image space, stl2mask builds a distance volume from the mesh and thresholds it to produce a binary mask; the reverse mask2stl command turns a binary mask back into a mesh using the Marching Cubes algorithm.

The tool grew out of the need to move tumour and organ delineations between mesh-based modelling tools, such as OPT Tumour Models, and the voxel-based image formats used in treatment planning systems, without manually re-implementing this conversion for every project. It is installed as a standalone CLI via pipx or uv tool install, so it can be used independently of any particular Python environment.

Main Contributors

Technical Details

License
MIT
Last updated
Jul 1, 2026
Requires Python
>=3.10,<3.14

Dependencies