fusion-metrics
Objective quality metrics for image fusion — ported line by line from MATLAB and verified to round-off precision.
Developed by Vu Viet Anh (Vũ Việt Anh) · AI Engineer & Researcher, Hanoi University of Science and Technology
Quick start · Metrics · CLI · Verification · Citation · Tiếng Việt
Why
Image-fusion papers report QAB/F, MI, NCIE, FMI, VIF… but compute them with scattered MATLAB scripts and
ad-hoc Python re-implementations that quietly disagree: a different gray conversion, a one-pixel shift in
conv2(...,'same'), uint8 saturation in a histogram, a different edge-thinning rule. The same method can then
score differently from paper to paper.
fusion-metrics gives one reference implementation that anyone can pip install:
- MATLAB-faithful — each function is a line-by-line port of a reference
.mfile, keeping its name, argument order and numerical quirks. - Verified, not assumed — a self-test compares every metric with values produced by the original
.mfiles; agreement is at round-off level (≤ 1e-12). It runs in CI on Python 3.10–3.13. - Ready for benchmarks — score one image from Python, or a whole method folder from the command line to CSV.
🚀 Quick start
pip install git+https://github.com/VuVietAnh2309/fusion-metrics.git
import fusion_metrics as fm
A = fm.read_gray("MRI.png") # MATLAB imread + rgb2gray -> uint8
B = fm.read_gray("PET.png") # pseudo-colour images are converted to gray
F = fm.read_gray("fused.png")
fm.Q_ABF(A, B, F) # one metric
fm.evaluate(A, B, F, "information") # a preset -> {"Q_MI": ..., "Q_NCIE": ..., ...}
fm.evaluate(A, B, F) # all 18 metrics
📐 Metrics
Q_X(A, B, F) takes the two sources and the fused image; no-reference metrics take only F.
Inputs are grayscale uint8 or double in [0, 255].
| Function | Metric | Original reference |
|---|---|---|
Q_MLI(F) |
Mean local intensity, [0, 1] | — |
Q_En(F) |
Entropy | Roberts et al., J. Appl. Remote Sens. 2008 |
SF(F) |
Spatial frequency (4 directions) | Eskicioglu & Fisher, IEEE TCOM 1995 |
Q_AG(F) |
Average gradient (forward differences, [0, 1]) | — |
AG_VIFB(F) |
Average gradient, VIFB definition (0–255) | Zhang et al., VIFB, CVPRW 2020 |
Q_MI(A,B,F) |
Mutual information MI(A,F) + MI(B,F), bits | Qu et al., Electron. Lett. 2002 |
Q_NCIE(A,B,F) |
Nonlinear correlation information entropy | Wang, Shen & Jin, 2008 |
Q_TE_Nava(A,B,F) |
Tsallis entropy, q = 0.43137 | Nava et al., Proc. SPIE 2007 |
Q_FMI(A,B,F) |
Feature mutual information on edge maps, w = 3 | Haghighat et al., Comput. Electr. Eng. 2011 |
Q_ABF(A,B,F) |
Edge-based QAB/F | Xydeas & Petrović, Electron. Lett. 2000 |
Q_M(A,B,F) |
Multiscale edge preservation (Haar, 2 levels) | Wang & Liu, ICSP 2008 |
Q_SF(A,B,F) |
Relative spatial-frequency error | Zheng et al., Inf. Fusion 2007 |
Q_FSIM(A,B,F) |
Feature similarity, (FSIM(A,F) + FSIM(B,F)) / 2 | Zhang et al., IEEE TIP 2011 |
Q_PSNR(A,B,F) |
Mean of PSNR(F,A) and PSNR(F,B) | — |
Q_CC(A,B,F) |
Mean correlation coefficient | — |
Q_SCD(A,B,F) |
Sum of the correlations of differences | Aslantas & Bendes, AEU 2015 |
VIF_Sheikh(A,B,F) |
VIF(A,F) + VIF(B,F) | Sheikh & Bovik, IEEE TIP 2006 |
Q_VIFF(A,B,F) |
Visual information fidelity for fusion | Han et al., Inf. Fusion 2013 |
The taxonomy follows Liu et al., “Objective assessment of multiresolution image fusion algorithms for context enhancement in night vision”, IEEE TPAMI 2012. Please cite the original paper of every metric you report.
Presets
| Preset | Metrics |
|---|---|
image |
Q_MLI, Q_En, SF, AG_VIFB |
information |
Q_MI, Q_NCIE, Q_TE_Nava, Q_FMI |
feature |
Q_ABF, Q_M, Q_SF, Q_FSIM |
similarity |
Q_PSNR, Q_CC, Q_SCD, VIF_Sheikh, Q_VIFF |
all |
all 18 |
💻 Command line
# one fused image
fusion-metrics MRI.png PET.png fused.png --preset feature
# a whole method: files matched by name across three folders -> per-image CSV + mean
fusion-metrics --dirs data/MRI data/PET results/MyMethod --preset all --csv mymethod.csv
fusion-metrics --list # metrics and presets
Add --json for machine-readable output, or --reader cv to use the OpenCV gray conversion instead of MATLAB's.
⚠️ Conventions that change the numbers
- Gray conversion.
read_grayreproduces MATLABimread+rgb2gray(0.298936, 0.587043, 0.114021, rounded) — use it to match MATLAB.read_gray_cvuses OpenCV's 0.299 / 0.587 / 0.114, common in Python code bases. Loading withcv2.imread(path, 0)directly gives yet another result. - Data type matters for
Q_MI. Onuint8input MATLAB saturates255 + 1to 255, merging the top gray level into the previous histogram bin. The port reproduces this from the array's dtype — read images asuint8. - Edge maps for
Q_FMI. MATLAB'sedge()thins edges inside a compiled mex file. The port reproduces its rule (non-maximum suppression with<=towards the left/upper and<towards the right/lower neighbour), which matches values computed in MATLAB. - Summation order.
Q_FMIbranches on exact zero tests, so its sums follow MATLAB's left-to-right order; NumPy's pairwise summation would shift results by up to 5e-3.
✅ Verification
python verify/selftest.py # ~20 s, prints "ALL OK"; no MATLAB/Octave needed
The self-test scores 7 seeded synthetic cases chosen to hit every code path — structured, noise, saturated 0/255,
low range [0, 40], {0, 1} images, odd size 255×257, and 512×512 — and compares the Python values with those produced by
the original .m files in GNU Octave:
- 17/17 metrics agree with relative error ≤ 1.7e-12 (most ≈ 1e-15), and
edge_sobelreproduces the stored edge maps pixel for pixel. - One documented exception:
Q_VIFFon the saturated case differs by 2.7e-5. Its perfectly flat regions put local variances at round-off level, right at the.mfile's 1e-10 thresholds, where the result depends on the summation order insidefilter2(which differs between MATLAB, Octave and SciPy). On real imagesQ_VIFFagrees to 1e-14.
A cross-check on real PET/SPECT–MRI pairs from the public Harvard Whole Brain Atlas gave the same picture: every metric
within 4e-12 of the .m files on identical pixel arrays.
Regenerate the reference values (needs GNU Octave)
conda create -p ./octave -c conda-forge octave octave-image octave-signal
cd verify
python make_reference_cases.py && octave-cli run_reference.m \
&& python selftest.py --export && python selftest.py
verify/octave_shims/ supplies dwt2 (Haar, MATLAB's default 'sym' mode — Octave has no Wavelet Toolbox) and
imgradientxy with MATLAB's border convention. They are only used when running the .m files in Octave.
🗂️ Repository layout
fusion-metrics/
├── fusion_metrics/ # the Python package (+ CLI in cli.py)
├── matlab/ # reference .m implementations
├── matlab_added/ # MATLAB references for AG_VIFB and VIF_Sheikh
├── verify/ # self-test, reference cases/values, Octave scripts and shims
├── examples/ # minimal API example
└── assets/ # README figures
🧭 Roadmap
The matlab/ folder holds 15 more reference metrics without a Python port yet: Q_C, Q_CB, Q_CV, Q_CE, Q_CI,
Q_EI, Q_H, Q_NMI, Q_P, Q_S, Q_TE, Q_UIQI, Q_Y, Q_NABF, MS_SSIM. Contributions are welcome —
a port is accepted once it passes the self-test against its .m file.
📝 Citation
If fusion-metrics helps your work, please cite it (GitHub's “Cite this repository” button gives the same entry)
and the original paper of each metric you report:
@software{vu2026fusionmetrics,
author = {Vu, Viet Anh},
title = {fusion-metrics: MATLAB-faithful objective quality metrics for image fusion},
year = {2026},
version = {1.0.0},
url = {https://github.com/VuVietAnh2309/fusion-metrics}
}
👤 Author
Vu Viet Anh (Vũ Việt Anh) — author and maintainer of the Python package, CLI and verification suite.
AI Engineer & MSc student in Computer Science, Hanoi University of Science and Technology (HUST).
📄 License
The package is MIT-licensed. Q_FSIM, Q_VIFF and VIF_Sheikh are translations of third-party code that remains
under its authors' terms (educational and research use only) — see NOTICE. Reference .m files keep their
original copyright headers.
The .m files in matlab/ are the reference implementations used for verification; files derived from published
toolboxes keep their original headers.
Questions, bug reports and new metric ports: GitHub Issues.
Metadata
Release files for fusion-metrics 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fusion_metrics-1.0.0.tar.gz | 25.4 kB | With provenance | Details for fusion_metrics-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fusion_metrics-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for fusion_metrics-1.0.0-py3-none-any.whl |
Total release size: 50.7 kB
Release files / fusion_metrics-1.0.0.tar.gz
| Download URL | fusion_metrics-1.0.0.tar.gz |
|---|---|
| Size | 25.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
415c31801c38930d64796527d42e85ff344fa9eca32f6e0ffb7429d2e55bb8b9
|
|
BLAKE2b-256 checksum How to use checksums |
360990089e427bc31f219468c0ac81564f5117d9dd1e31fdd93553fffb46a02c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / fusion_metrics-1.0.0-py3-none-any.whl
| Download URL | fusion_metrics-1.0.0-py3-none-any.whl |
|---|---|
| Size | 25.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
18fda465ad671a3db35c413ab4beed75324ee3190e306133451ea60a777fcd37
|
|
BLAKE2b-256 checksum How to use checksums |
930aeba4e05ea44934ea7be21f32935e5b4dcc6d4888cec88cf391da7c2f4e69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logSecurity for fusion-metrics 1.0.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for fusion_metrics-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logA 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.