uv venv --python 3.12
uv pip install primo-stitch
uv run primo-stitch \
--tile_dir=folder_with_tiles \
--output_file=panorama.jpg \
--device=cpu \
--matcher=xfeat \
--blending_mode=collage \
--inference_size=0.3
Interactive research demo
PRIMO
Panoramic Reconstruction In Microscopy with Optimization
Stitch microscopy tiles into seamless panoramas — with global geometric alignment, distortion correction, and photometric normalization built for real acquisitions.
Three-stage pipeline
From overlapping tiles to analysis-ready panoramas
PRIMO combines deep feature matching with gradient-based global optimization — handling irregular layouts, lens distortion, and uneven illumination in one modular flow.
-
1
Feature matching
Pairwise correspondences via modern DL matchers (XFeat, LoFTR, Efficient LoFTR) on regular grids or blind tile-to-tile search for arbitrary orderings.
-
2
Global alignment
Sequential registration followed by bundle adjustment with optional Brown–Conrady distortion correction — all refined via autograd and AdamW.
-
3
Compositing
Global photometric normalization, GraphCut seam masking, and multi-band blending remove exposure drift and visible seams across large panoramas.
Python package
Install PRIMO from PyPI
Beyond this web demo, PRIMO is published as a Python package on PyPI. Use the command-line tool for quick experiments or embed the library in your own pipelines.
from primo import Matcher, Stitcher
matcher = Matcher(
model='xfeat', # 'xfeat' | 'efficient loftr' | 'loftr'
device='cuda:0', # or 'cpu'
inference_size=0.5,
)
stitcher = Stitcher(
matcher,
blending_mode='full', # 'collage' | 'mosaic' | 'full'
)
stitcher.stitch(
input_dir='path/to/tiles',
output_file='panorama.png',
)
Comparison with baselines
Stitching artifacts on microscopy panoramas
Side-by-side results on real microscopy panoramas — the same tile set stitched with a baseline method and with PRIMO.
Step through common geometric and photometric failure modes below.
Competing method MIST
PRIMO
Pairwise stitching leaves visible seams and offset structures where tile overlaps should align. PRIMO’s global bundle adjustment corrects drift across the full panorama instead of accumulating error tile by tile.
Competing method MIST
PRIMO
Lens distortion amplifies registration error at tile borders. PRIMO jointly refines homographies with Brown–Conrady distortion parameters, keeping structures continuous across the field of view.
Competing method Microsoft ICE
PRIMO
Sequential alignment lets small per-tile errors compound into large-scale geometric drift. Global optimization in PRIMO distributes correction across all overlaps, preserving tissue-scale geometry.
Competing method Microsoft ICE
PRIMO
Gaps and collapsed regions appear when a stitcher cannot place tiles in irregular or incomplete layouts. PRIMO handles approximate grids and missing acquisitions without leaving holes in the panorama.
Competing method PanoramaStudio
PRIMO
Per-tile exposure and white-balance differences survive naive compositing as visible color bands. PRIMO applies global photometric normalization before blending so adjacent tiles match in overlap regions.
Competing method BigStitcher
PRIMO
Without vignetting correction, seams and exposure ramps remain even when geometry is roughly correct. PRIMO estimates an illumination map and per-tile gains, then blends with seam-aware masking for a uniform panorama.
Competing method Microsoft ICE
PRIMO
On wide panoramas, uncorrected photometric drift accumulates across hundreds of tiles. PRIMO keeps intensity consistent over large fields — critical for segmentation and quantitative microscopy.
Visual assessment
Qualitative comparison across microscopy datasets
Each row is one microscopy dataset. Its input tiles were stitched with every method listed in the table (default settings where applicable), then rated by operator visual inspection for geometric alignment and photometric consistency.
Per cell: left mark — geometric alignment; right mark — photometric consistency.
| Dataset modality | Adobe Photoshop Commercial | PanoramaStudio 4 Pro Commercial | PTGui 13.3 Commercial | Image Compositor Editor (ICE) Free | MIST Open-Source | BigStitcher Open-Source | PRIMO Open-Source, ours |
|---|---|---|---|---|---|---|---|
| NIST Steel Mosaic DIC | ✕ ✕ | ✓ ± | ✓ ✓ | ✓ ± | ✓ ✕ | Not applicable | ✓ ✓ |
| vEMstitch SEM | ✕ ✕ | ✓ ✓ | ✕ ✕ | ✕ ✓ | ✓ ✓ | ✓ ✓ | ✓ ✓ |
| Shading w/o corrections brightfield | ✕ ✕ | ✓ ✕ | ✕ ± | ✓ ✕ | ✕ ✕ | Not applicable | ✓ ± |
| Shading with corrections brightfield | ✕ ✕ | ✓ ± | ✓ ± | ✓ ✓ | ✓ ± | Not applicable | ✓ ✓ |
| PanoMic-Geo, ours optical-reflected | ± ± | ✓ ± | ✓ ✓ | ✓ ± | ✕ ✕ | Not applicable | ✓ ✓ |
| PanoMic-GeoBig, ours optical-reflected | ✕ ✕ | ✓ ✕ | ✕ ✕ | ± ✕ | ✕ ✕ | Not applicable | ✓ ✓ |
| PanoMic-Metal, ours SEM | ✕ ✕ | ✓ ✕ | ✕ ✕ | ± ✕ | ✓ ✕ | ✓ ✕ | ✓ ✓ |
| PanoMic-Synth, ours synthetic | ✓ ✕ | ✓ ✓ | ✓ ✓ | ± ✕ | ✕ ✕ | ✓ ✕ | ✓ ✓ |
Black-box evaluation
Tile-based metrics across stitching methods
We compare stitching methods quantitatively without access to their internals: each source tile is reverse-registered onto the stitched panorama, and metrics are computed between the original tile and its projected crop inside the valid mask. The same pipeline applies to open-source and commercial tools alike.
Reverse tile registration locates each input tile on the final panorama; fidelity, structural, and perceptual scores are aggregated per dataset (mean across panoramas).
Reported metrics include structural and perceptual scores (SSIM, HFI-SSIM, CW-SSIM, LPIPS) as well as photometric fidelity (MSE, ΔE, JSD).
Why PRIMO
Built for microscopy, not vacation photos
General-purpose stitchers often fail on artifact-heavy acquisitions. PRIMO targets geometric drift, missing tiles, vignetting, and exposure variation that appear in real microscopy workflows.
Regular & irregular layouts
Works on mechanical grids and manually acquired tile sets with approximate or incomplete layouts — no strict stage model required.
Distortion-aware alignment
Jointly optimizes tile homographies with Brown–Conrady lens parameters, starting from a no-distortion prior and refining from overlap consistency.
Global photometric consistency
Estimates a Gaussian-mixture illumination map and per-tile gains from overlapping regions — critical for segmentation and quantitative analysis.
Strong perceptual quality
On multi-domain benchmarks, PRIMO leads on structural metrics (SSIM, LPIPS) while maintaining competitive fidelity across optical, SEM, and synthetic data.
Optimization core
Global consistency by design
Alignment and photometric correction share the same principle: minimize disagreement between corresponding pixels in overlapping tile pairs.
Bundle adjustment
Minimize reprojection error over inlier matches Ω:
Σ(i,j)∈Ω ‖ Him̃ij − Hjm̃ji ‖² → min
Homographies Hi are refined with automatic differentiation; optional Brown–Conrady distortion D is applied to match points before reprojection.
Photometric normalization
Match corrected intensities in overlap regions:
Icorri(x) = gi · Ii(x) / M(x) Σ(i,j)∈Ω (Icorri − Icorrj)² → min
Per-tile gains gi and a Gaussian-mixture illumination map M(x) compensate vignetting and exposure variation across the panorama.
Multi-domain evaluation
PanoMic & real-world microscopy
PRIMO is evaluated on optical reflected-light geology sections, large irregular layouts, SEM panoramas, and synthetic panoramas with controlled artifacts — plus public benchmarks without ground-truth stitches.
-
Geo
Polished geological sections, manual grids
-
GeoBig
Up to ~190 tiles, irregular layouts
-
Metal
Large-scale SEM panoramas
-
Synth
Controlled illumination & distortion
This web demo lets you run PRIMO on prepared tile sets or your own uploads, track progress live, and explore results in a deep-zoom viewer — try the gallery for precomputed examples across domains.
Ready to stitch?
Start from a prepared dataset or upload your own tiles. No account required — your session keeps track of jobs privately.