Triangulation matting and alpha-aware focus stacking for macro specimen capture.
Built for photographing pinned insect specimens on a motion rig and producing clean, background-free stacks for photogrammetry / 3D Gaussian Splatting.
Each frame is shot three times — once against a black backdrop, once against white, and once on grey. Triangulation matting recovers a true alpha channel from that set, including genuine translucency such as insect wings, which a chroma key cannot.
- Matte — RAW black/white pairs to 16-bit RGBA TIFFs, with optional per-pixel background calibration, alpha curve, CA correction and defringing.
- Stack — alpha-aware focus stacking via shinestacker's pyramid fusion.
- Export — COLMAP-ready image + mask pairs, images written RGBA so downstream 3DGS trainers can use the matte directly.
A batch mode runs matte → stack → COLMAP across every rotation of an orbit one at a time, reclaiming each rotation's mattes as it goes, so peak disk stays at roughly one rotation instead of the whole capture.
MattePro is built for PiSlider macro scans and reads PiSlider's folder layout. Other rigs work if their captures are arranged the same way. Open the project root:
<project>/
├── cal_black.ARW flats — optional
├── cal_white.ARW
├── cal_grey.ARW
└── macro_project_2026-09-11/
└── orbit_001/
└── stack_001/
└── rot-052.477_aux+000.00/ one rotation (any name)
├── slot_A_black/ RAWs — required
├── slot_B_white/ RAWs — required
└── slot_C_grey/ RAWs — optional
Required. A rotation is any folder containing slot_A_black/ and
slot_B_white/ side by side; slot_C_grey/ is optional. The names are exact
and case-sensitive — without them MattePro finds 0 pairs. Frames are paired by
sorted filename, so each slot needs the same number of RAWs (extras in the
longer slot are ignored).
Flexible. Flats are found as loose files at the project root
(cal_black, flat_black, black_cal, …) or in a folder of the same name.
Any RAW rawpy reads works: ARW, CR3, CR2, NEF, RAF, DNG.
PiSlider extras, with fallbacks.
| From PiSlider | Used for | Without it |
|---|---|---|
stack_NNN/ folders |
capture-ordered COLMAP names (0001_…) |
names come from the rotation folder; COLMAP uses exhaustive matching |
orbit_NNN/ folders |
orbit prefix (o01_0001_…), multi-orbit matching |
treated as one orbit |
project.json |
the orientation set at capture | the camera's own orientation flag |
Output. matte/ and stacked/ are written inside each rotation folder.
images/, masks/, alpha_soft/, database.db and sparse/ are written at
the project root — the layout COLMAP and Brush read without configuration.
- Alpha is solved from unscaled linear RAW. Exposure is a display/output control and never enters the matte, or the background stops resolving to alpha 0.
- Stacked output is un-premultiplied before fusion and re-premultiplied after,
so
max(RGB) <= Aholds and edges do not glow. - Fused alpha is capped against a per-frame percentile, gated on whether any frame shows the pixel genuinely opaque — this suppresses defocus spread without eroding thin structures like antennae.
- Frame registration is available for focus breathing, which changes magnification across a bracket.
Python 3, NiceGUI, numpy, rawpy, tifffile, opencv-python, scipy, Pillow. Stacking additionally needs shinestacker on the path.
pyinstaller MattePro.spec