Skip to main content

PRIMO: Panoramic Reconstruction with Integrated Microscopy-Specific Optimization

Project description

PRIMO: Panoramic Reconstruction with Integrated Microscopy-Specific Optimization

Python library and command-line tool for stitching a set of overlapping tiles into a single 2D panorama.

Installation

pip install primo-stitch
  • Requires Python 3.10–3.12.
  • PRIMO depends on PyTorch. The default install pulls the CPU build; for GPU use, install the CUDA build of torch/torchvision first (see https://pytorch.org), then install PRIMO.
  • Matcher weights are downloaded automatically on first use (Hugging Face Hub / Torch Hub) and cached locally.

After installation you get the primo-stitch command and the importable primo package (install name primo-stitch, import name primo).

Command-line usage

primo-stitch is the main entry point.

# minimal — stitch a folder of tiles into a panorama
primo-stitch --tile_dir path/to/tiles --output_file panorama.png

# advanced
primo-stitch \
  --tile_dir path/to/tiles \
  --output_file panorama.png \
  --matcher "efficient loftr" \
  --device cuda:0 \
  --blending_mode full \
  --inference_size 0.5 \
  --batch_size 8 \
  --cache_dir cache/ \
  --logfile run.log

By default (full blending with --save_alpha_channel on), the panorama is written as .png (RGBA) regardless of the requested extension. Pass --no-save_alpha_channel to save a .jpg.

Options

Flag Default Description
--tile_dir (required) Directory with the input tiles
--output_file panorama.jpg Output panorama path (extension may be adjusted, e.g. .png when alpha is saved)
--cache_dir cache/ Cache directory (created automatically)
--matcher xfeat xfeat | efficient loftr | loftr
--device cpu cpu, cuda, cuda:0, ...
--blending_mode full collage | mosaic | full
--inference_size 0.3 Matcher input scale relative to the original (0.25, 0.5, 1, ...)
--batch_size 1 Matcher batch size (higher = faster, more memory)
--save_alpha_channel / --no-save_alpha_channel on Save the transparency channel; forces .png output in full mode
--logfile (none) Write a debug log to this file

Python API

from primo import Matcher, Stitcher

matcher = Matcher(
    model='xfeat',            # 'xfeat' | 'efficient loftr' | 'loftr'
    device='cuda:0',          # or 'cpu'
    inference_size=0.5,
    batch_size=8,
)

# the alignment device is taken from the matcher
stitcher = Stitcher(
    matcher,
    blending_mode='full',     # 'collage' | 'mosaic' | 'full'
    save_alpha_channel=True,
)

stitcher.stitch(
    input_dir='path/to/tiles',
    output_file='panorama.jpg',
    cache_dir='cache',
)

Matcher and Stitcher expose additional keyword arguments (alignment, photometric correction, blending) — see their signatures for the full set.

Demo

The interactive demo (live preview + machine-readable progress) is driven by primo-stitch-online and the run_online.sh wrapper. For normal use they are not needed; primo-stitch can also emit progress by adding --online, which writes a status.json and a preview.jpg while processing.

Authors

  • Gleb Nikolaev — Lomonosov Moscow State University
  • Savelii Shashkov — Lomonosov Moscow State University
  • Dmitriy Korshunov — Geological Institute of the Russian Academy of Sciences
  • Andrey Krylov — Lomonosov Moscow State University
  • Alexander Khvostikov (corresponding author) — Lomonosov Moscow State University

Citation

If you use PRIMO in your research, please cite (update pages/DOI with the final proceedings entry):

@inproceedings{primo2026,
  title     = {PRIMO: Panoramic Reconstruction with Integrated Microscopy-Specific Optimization},
  author    = {Nikolaev, Gleb and Shashkov, Savelii and Korshunov, Dmitriy and Krylov, Andrey and Khvostikov, Alexander},
  booktitle = {Proceedings of the 34th ACM International Conference on Multimedia (MM '26)},
  year      = {2026},
}

License

PRIMO's source code is licensed under the Apache License 2.0. It bundles third-party components under their own licenses (Apache-2.0, MIT); see THIRD_PARTY_LICENSES.md.

The accompanying paper is published by ACM under CC BY 4.0 (chosen via the ACM eRights process) — this is separate from the software license above.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

primo_stitch-0.1.0-py3-none-any.whl (114.5 kB view details)

Uploaded Python 3

File details

Details for the file primo_stitch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: primo_stitch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 114.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for primo_stitch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1419e5bc441afa29ff7ea9ddc1e012c16345d01f2fd07b70852e1e76ac9c4ce9
MD5 497690b42e68ed72144169d5aeafd86a
BLAKE2b-256 0243b5a766c5041ae3109337a48a1f4c948a29d07ce0531702c4a5b1db0e5852

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page