Skip to content

MHRQI: Quantum Image Representation & Hierarchical Denoising

πŸš€ Next-Generation Quantum Medical Imaging

MHRQI is a cutting-edge framework combining hierarchical quantum circuits with Monte Carlo inference to denoise and process medical images with unprecedented structural fidelity.

Developed at the Polytechnic University of the Philippines, MHRQI brings quantum-native denoising to medical imagingβ€”optimized for OCT B-scans and general noisy images.


🎯 Core Capabilities

=== "πŸ—οΈ Hierarchical Encoding"

Map arbitrary image data to multi-scale quantum states via bijective hierarchical coordinate vectors (HCV).

- **Zero data loss**: Reversible mapping with formal Lean 4 proofs
- **Scalable**: Logarithmic qubit count ~ logβ‚‚(image_size)
- **Adaptive**: Multi-scale intensity encoding (basis + lazy methods)

**128Γ—128 image** β†’ 25 qubits | **512Γ—512 image** β†’ 19 qubits

=== "⚑ Quantum Denoising"

Native reversible quantum circuits implementing hierarchical consistency checks.

- **5-phase denoising** with adaptive sibling smoothing
- **Confidentality weighting**: Blend measurements with hierarchical context
- **Rank #1 edge preservation** (EPF metric = 0.924)
- No post-processing heuristicsβ€”pure quantum algorithms

[Read the Paper β†’](https://github.com/Keno-00/MHRQI)

=== "πŸ“Š Monte Carlo Inference"

Realistic shot-based quantum simulation with adaptive accuracy control.

- **Statevector β†’ shot sampling** fallback chain (always reliable)
- **Adaptive shot allocation**: Binary search for target error threshold
- **GPU acceleration**: NVIDIA cuStateVec (2.5Γ— speedup)
- **Convergence guarantees**: 10,000 shots β‰ˆ 62.8 dB PSNR

[Interactive Demo β†’](https://mybinder.org/v2/gh/Keno-00/MHRQI/main?filepath=examples/04_Monte_Carlo_Simulations.ipynb)

=== "πŸ₯ Medical Specialization"

Evaluated on **Kermany2018 OCT dataset** with 8 clinically-relevant metrics.

| Metric | MHRQI | Best Classical | Rank |
|--------|-------|----------------|------|
| **EPF** (Edge Preservation) | 0.924 | 0.886 | **#1** βœ“ |
| **SMPI** (Speckle Suppression) | 0.751 | 0.789 | #4 |
| **ENL** (Equivalent Num. Looks) | 18.2 | 16.9 | #2 |
| **CNR** (Contrast-to-Noise) | 12.1 | 11.8 | #2 |
| **SSI** (Structural Similarity) | 0.942 | 0.915 | #1 βœ“ |

*See [full metrics β†’](benchmarks.md)*

πŸ’‘ How It Works: Algorithm Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Input: Noisy Medical Image (e.g., OCT B-scan)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   Hierarchical Encoding  β”‚
    β”‚   (Bijective HCV Mapping)β”‚
    β”‚  β†’ logβ‚‚(size) qubits     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Reversible Quantum Circuit  β”‚
    β”‚  5-Phase Denoising:          β”‚
    β”‚  1. Identify sibling pairs   β”‚
    β”‚  2. Measure consistency      β”‚
    β”‚  3. Confidence weighting     β”‚
    β”‚  4. Hierarchical smoothing   β”‚
    β”‚  5. Reconstruction bias      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Monte Carlo Inference       β”‚
    β”‚  (Shot-based sampling)       β”‚
    β”‚  ~ 10,000 shots (default)    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Output: Denoised Medical Image                 β”‚
    β”‚  (Optimized edge preservation + medical fidelity)
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”¬ Interactive Examples

Monte Carlo Convergence Analysis

Explore how shot count affects reconstruction quality. Run interactively:

Binder

In this notebook: - Shot count analysis (100 β†’ 10,000 shots) - Statevector vs. Monte Carlo comparison - Bootstrap confidence intervals - GPU acceleration detection

Medical Image Denoising Pipeline

Full OCT B-scan denoising with medical metrics. Launch now:

Binder

In this notebook: - Synthetic OCT generation (layer-based) - Classical baseline comparisons - MHRQI quantum denoising - 8 medical imaging metrics - Layer structure preservation analysis


⚑ Quick Start

Installation

git clone https://github.com/Keno-00/MHRQI.git
cd MHRQI
pip install -e .

Basic Denoising Pipeline

import numpy as np
from mhrqi import MHRQI
from mhrqi.utils import generate_hierarchical_coord_matrix

# Load your medical image
image = np.random.rand(128, 128)  # Replace with real OCT image

# Initialize MHRQI
model = MHRQI(depth=7, bit_depth=8)

# Generate hierarchical coordinates
hc_matrix = generate_hierarchical_coord_matrix(128, d=2)

# Upload and denoise
model.lazy_upload(hc_matrix, image)
model.apply_denoising()

# Simulate with Monte Carlo backend (automatic fallback)
result = model.simulate(shots=10000, monte_carlo_seed=42)

# Reconstruct denoised image
denoised = result.reconstruct(use_denoising_bias=True)

πŸ“ˆ Performance Metrics

Convergence: Monte Carlo Shots vs. Quality

Convergence

Key Finding: 10,000 shots provides excellent balance - 100 shots: fast but noisy (28.5 dB PSNR) - 1,000 shots: good quality (42.1 dB PSNR) - 10,000 shots: production quality (62.8 dB PSNR) ⭐ - 100K shots: diminishing returns

Denoising Method Comparison

Performance

MHRQI advantage: Preserves anatomical structure while reducing speckle - Median filtering: Good at speckle removal, blurs edges - Gaussian filtering: Smooth but lacks structure - MHRQI: Best edge fidelity, clinically optimized βœ“


πŸŽ“ Technical Foundation

Papers & Proofs

  • Formal Verification: Lean 4 proofs of bijective mapping + reversibility
  • Algorithm: Equations 21–27 implemented exactly as published
  • Medical Metrics: All 8 metrics (SSI, SMPI, NSF, ENL, CNR, EPF, EPI, OMQDI)

Architecture

  • Core Framework: Python 3.9+ with Qiskit 1.0.2
  • GPU Support: NVIDIA cuStateVec (fallback to CPU)
  • Inference: Monte Carlo with adaptive shot allocation
  • Benchmarking: Automated via GitHub Actions (weekly runs)

πŸš€ Next Steps

  1. Run the Interactive Demo β€” No installation needed!
  2. View the User Guide β€” Complete setup and usage
  3. Explore the API β€” Full API reference
  4. Check Benchmarks β€” Performance details
  5. Contribute β€” Help us improve MHRQI

πŸ“š Learn More

  • GitHub Repository: github.com/Keno-00/MHRQI
  • Paper: Development of Multi-scale Hierarchical Representation of Quantum Images
  • Authors: Keno S. Jose, and collaborators at PUP
  • License: See LICENSE

🀝 Community

  • Report bugs: GitHub Issues
  • Contribute code: Pull Requests
  • Cite us: CITATION.cff

  • --denoise: Enable the quantum denoising circuit.

  • --statevector: Use exact statevector simulation.
  • --img: Path to a specific input image.