Skip to main content

OpenFocus Logo OpenFocus

OpenFocus delivers focus stacking quality that rivals commercial-grade software, while staying fully open source and easy to extend.

Python 3.10+ License: MIT GitHub Repository Download DOI

广告位招租 / Ad Space for Rent

📢 News

Earlier releases are in the Changelog.

⬇️ Download & Install

No setup needed — grab a build from the Releases page:

Platform File Type
Windows 10/11 (64-bit) OpenFocus-*-setup.exe Installer (recommended)
Windows 10/11 (64-bit) OpenFocus-*-windows-x64.zip Portable (unzip and run)
macOS Apple Silicon (M1–M4) OpenFocus-*-macos.dmg Disk image (drag to Applications)
macOS Apple Silicon (M1–M4) OpenFocus-*-macos-arm64.zip Portable (unzip)

The app is unsigned, so the first launch may show a security prompt:

  • Windows: SmartScreen → "More info" → "Run anyway". The first start may take 30–60 s.
  • macOS: right-click → Open, or run xattr -cr /Applications/OpenFocus.app in Terminal.

Full details, including the portable mode and the log folder, are in the User Manual.

💻 Command Line Usage

Beyond the GUI, OpenFocus ships as a pip-installable CLI on PyPI — Windows, macOS and Linux, no Python GUI stack required:

pip install openfocus          # all 8 fusion methods (4 classical + OpenFocus A/B/C)
pip install "openfocus[ai]"    # + the AI (StackMFF-V3) model, weights included
pip install "openfocus[raw]"   # + camera RAW input (rawpy / LibRaw)
openfocus --input ./stack_folder --output ./result/fused.png

Examples:

# Fuse a folder of images with guided filter, no registration
openfocus -i ./stack_folder -o ./result/fused.png

# DTCWT with ECC registration, 8 threads
openfocus -i ./stack_folder -o ./result/fused.png -m dtcwt -a ecc -t 8

# AI fusion forced to CPU with a custom tile size
openfocus -i ./stack_folder -o ./result/fused.png -m stackmffv3 --cpu --tile-size 512

# Explicit file list instead of a folder; video files also work as input
openfocus -i img1.jpg img2.jpg img3.jpg -o fused.png -m gfgfgf

# Batch mode: fuse every folder into one output directory
openfocus --input ./stackA ./stackB --output-dir ./results

Exit codes: 0 success, 1 processing error, 2 usage error. Run openfocus --help for all options. From a source checkout, the same interface works as python main.py ….

📖 Documentation

🛠️ Building from Source

For contributors and platforms without pre-built packages:

conda create -n openfocus python=3.10
conda activate openfocus
pip install -r requirements.txt
python main.py

Packaging with PyInstaller: see docs/BUILD_COMMANDS.md.

Table of Contents

🔭 Overview

OpenFocus is a PyQt6-based multi-focus registration and fusion workstation that delivers commercial-grade alignment and blending results. The project is fully open source (MIT License) and runs on CPU by default with optional GPU acceleration for the StackMFF V3 neural model.

OpenFocus UI

AI fusion: StackMFF V3

The default fusion method classifies every pixel by its most probable source frame. Input is a real 10-frame macro stack of a PCB; the focus sweeps across the board between frames.

Focus sweep through the input stack

All ten frames differ in which part is sharp - frames 01-05 hold the switch and its lettering, 06-10 are defocused. The fused result has to keep the sharp version of every region:

The ten input frames

Compared with Guided Filter on the same registered stack, the AI result keeps the letter edges crisper and the board surface cleaner. Both crops come from the same region of the same stack (Laplacian sharpness 27.1 vs 28.5):

Guided Filter vs StackMFF V3

On a synthetic stack with known ground truth it leads every fusion method on both PSNR and SSIM, and leaves fewer ghost pixels than any classical method:

Ground-truth benchmark

Benchmark reproducible with python tools/synthetic_benchmark.py --noise 3.

✨ Highlights

  • Eight fusion methods — four classical plus OpenFocus A/B/C, with three registration modes (fast similarity, ECC, homography).
  • Focus-stack workflow — stack browser, wipe compare, depth maps, retouch brush, batch processing, quick preview.
  • Microscopy-ready — 16-bit end to end, µm/px from TIFF metadata, dust-map flat-field correction, publication scale bars, textured OBJ export.
  • Headless CLI — the same pipeline as openfocus, with batch mode, --dry-run, --resume and JSON output for scripting.
  • Projects and recovery — .ofproj sessions, crash auto-recovery, undo/redo, per-method settings remembered across restarts.
  • Four UI languages — English, 中文, 日本語, Español.

🧪 Algorithms

Fusion Algorithms

  • Guided Filter: Fast edge-preserving fusion (Li et al., 2013).
  • DCT Multi-Focus Fusion: Block-wise DCT variance with consistency verification — the fastest method.
  • Dual-Tree Complex Wavelet Transform (DTCWT): Multi-scale, multi-orientation fusion with one consistent decision per pixel and level.
  • GFG-FGF: Gaussian-like four-neighbourhood gradient operator + fast guided filter (Fu et al., 2024), well suited to microscopy.
  • StackMFF V3: Pretrained deep model that classifies every pixel by its most probable source frame, with soft (probability-weighted) and hard (per-pixel frame pick) outputs (GPU optional).
  • OpenFocus A / B / C: Variance-weighted average, variance depth-map pick, and Laplacian-pyramid fusion.

Registration Algorithms

  • OpenFocus (fast): Bounded similarity alignment (translation + rotation + scale) with brightness equalization and auto-crop — sub-second per frame.
  • ECC: Intensity-based alignment by maximizing the enhanced correlation coefficient for precise, sub-pixel registration.
  • Homography: Feature-based projective alignment (SIFT + RANSAC) for global perspective changes.

License Notice: Every fusion/registration algorithm included comes from open-source research implementations. When using or redistributing them, please follow each algorithm’s original license terms in addition to the OpenFocus MIT license.

📚 References

  • M. B. A. Haghighat, A. Aghagolzadeh, and H. Seyedarabi, "Multi-focus image fusion for visual sensor networks in DCT domain," Computers & Electrical Engineering, vol. 37, no. 5, pp. 789-797, 2011.
  • J. J. Lewis, R. J. O'Callaghan, S. G. Nikolov, D. R. Bull, and N. Canagarajah, "Pixel- and region-based image fusion with complex wavelets," Information Fusion, vol. 8, no. 2, pp. 119-130, 2007.
  • S. Li, X. Kang, and J. Hu, "Image fusion with guided filtering," IEEE Transactions on Image Processing, vol. 22, no. 7, pp. 2864-2875, 2013.
  • 付宏语, 巩岩, 汪路涵, 等. 多聚焦显微图像融合算法[J]. Laser & Optoelectronics Progress, 2024, 61(6): 0618022-0618022-9.
  • X. Xie, StackMFF V3: Order-Invariant Focus Stacking via Pixel-Wise Source Classification, 2026. Code, pretrained weights and benchmark: github.com/Xinzhe99/StackMFF-V3.

🤝 Contribution

We welcome community contributions of all kinds:

  1. Issues: Report bugs, request features, or propose UX enhancements.
  2. Algorithm & Performance Work: Share new fusion/registration ideas, optimizations.

If you use the AI fusion mode, please also cite the underlying method: StackMFF V3.

Bug reports or suggestions? Please open an issue so we can follow up quickly.

📚 Citing OpenFocus

If OpenFocus contributes to your research or work, please cite it — it makes the project visible to others who need it:

@software{xie_openfocus,
  author  = {Xie, Xinzhe},
  title   = {{OpenFocus}: An Open-Source Multi-Focus Image Fusion Workstation},
  year    = {2026},
  url     = {https://github.com/Xinzhe99/OpenFocus},
  doi     = {10.5281/zenodo.23050823},
  license = {MIT}
}

The repository's About sidebar has a Cite this repository button (generated from CITATION.cff). Every release is archived on Zenodo with a versioned DOI — the DOI above always resolves to the latest release; cite the specific version DOI when your work depends on a particular one.

If you publish images created with OpenFocus, a note such as "Created with OpenFocus – https://github.com/Xinzhe99/OpenFocus" is appreciated (not required).

📄 License

This project is released under the MIT License. Feel free to use, modify, and distribute within the terms of the license.

If OpenFocus helps you, please consider leaving a ⭐ on the repository!

⭐ Star History

Star History Chart

Metadata

Release files for openfocus 1.65.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openfocus 1.65.3
File Size Uploaded Provenance
openfocus-1.65.3.tar.gz 832.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for openfocus 1.65.3
File Interpreter ABI Platform
openfocus-1.65.3-py3-none-any.whl Python 3 none any Details

Total release size: 1.6 MB

Release files / openfocus-1.65.3.tar.gz

Download URL openfocus-1.65.3.tar.gz
Size 832.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3fcb9f4292dcbcd7d31b6773923676b2df3b2a2fd077a7602d03679eb7c729aa
BLAKE2b-256 checksum
How to use checksums
611ed9910ebcffd678c178635a61d44cf4a8fa62408812f975ebd9715b1a925c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.19

Release files / openfocus-1.65.3-py3-none-any.whl

Download URL openfocus-1.65.3-py3-none-any.whl
Size 767.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
02825925e18a64396121fea41f220fd0fcb0c4cc4ae3b9737e7bbcb54c260dee
BLAKE2b-256 checksum
How to use checksums
51c21460a9a88f3ca846bc0491b22df2cff7f4d955abcf4b814ef4d266c4a964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.19

Security for openfocus 1.65.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page