Image Deblurring with Quaternion Methods
Comprehensive guide to quaternion-based image deblurring using QSLST and Newton-Schulz methods.
🎯 Overview
QuatIca provides state-of-the-art quaternion methods for image deblurring, comparing:
- QSLST-FFT: Fast FFT-based Tikhonov regularization
- QSLST-Matrix: Matrix-based Tikhonov implementation
- Newton-Schulz (NS): Iterative pseudoinverse method
- Higher-Order NS (HON): Cubic convergence variant
🚀 Quick Start
Basic Deblurring
# Default parameters (32×32, fast)
python run_analysis.py image_deblurring
# High quality (64×64, recommended)
python run_analysis.py image_deblurring --size 64 --lam 1e-3 --snr 40 --ns_mode fftT --fftT_order 3 --ns_iters 12
Parameter Options
# Image size
--size 32 # 32×32 grid (fast)
--size 64 # 64×64 grid (recommended)
--size 128 # 128×128 grid (high quality)
# Regularization
--lam 1e-3 # Tikhonov parameter (default: 1e-3)
--lam 1e-1 # Stronger regularization
--lam 1e-5 # Lighter regularization
# Noise level
--snr 30 # 30 dB signal-to-noise ratio
--snr 40 # 40 dB SNR (default)
--snr 50 # 50 dB SNR (less noise)
# Newton-Schulz options
--ns_mode fftT # FFT-based (recommended)
--ns_mode dense # Dense matrix method
--ns_mode sparse # Sparse matrix method
# FFT solver settings
--fftT_order 2 # Quadratic convergence (Newton-Schulz)
--fftT_order 3 # Cubic convergence (Higher-Order NS)
--ns_iters 12 # Number of iterations
🔬 Algorithm Details
Problem Formulation
Image Deblurring as Linear System: - Clean image: x (unknown) - Observed image: b (blurred + noise) - Blur operator: A (convolution matrix) - Goal: Solve Ax = b for x
Tikhonov Regularization:
Solution: x_λ = (A^T A + λI)^(-1) A^T b
Method Comparison
Method | Speed | Accuracy | Memory | Best For |
---|---|---|---|---|
QSLST-FFT | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | Production use |
QSLST-Matrix | ⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐ | Small images, validation |
NS (fftT) | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | General purpose |
HON (fftT) | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | High accuracy |
QSLST-FFT Algorithm
Why it's fast: FFT diagonalizes the circulant blur matrix A^T A
# Frequency domain solution
for each frequency (u,v):
X̂[u,v] = conj(Ĥ[u,v]) * B̂[u,v] / (|Ĥ[u,v]|² + λ)
Complexity: O(N log N) vs O(N³) for direct methods
Newton-Schulz FFT Methods
Inverse Newton-Schulz: Solves T^(-1) where T = A^T A + λI
Per-frequency implementation: Parallelizable across frequency bins
📊 Performance Analysis
Execution Time (64×64 image)
Method | Time | Relative Speed |
---|---|---|
QSLST-FFT | ~0.1s | 1× (baseline) |
NS (fftT, order-2) | ~0.3s | 3× |
HON (fftT, order-3) | ~0.5s | 5× |
QSLST-Matrix | ~2.5s | 25× |
Quality Metrics
PSNR (Peak Signal-to-Noise Ratio): Higher is better - Excellent: >40 dB - Good: 30-40 dB - Acceptable: 20-30 dB
SSIM (Structural Similarity): Higher is better (0-1 range) - Excellent: >0.95 - Good: 0.85-0.95 - Acceptable: 0.70-0.85
🎛️ Parameter Tuning Guide
Regularization Parameter (λ)
Effect of λ: - Too small (λ < 1e-5): Amplifies noise, overfitting - Optimal (λ ≈ 1e-3): Balances smoothing and detail preservation - Too large (λ > 1e-1): Over-smoothing, loss of details
Tuning strategy:
# Test different values
python run_analysis.py image_deblurring --lam 1e-5 # Less smoothing
python run_analysis.py image_deblurring --lam 1e-3 # Balanced (recommended)
python run_analysis.py image_deblurring --lam 1e-1 # More smoothing
Newton-Schulz Iterations
Convergence behavior: - Order-2: Linear convergence, needs ~12-20 iterations - Order-3: Cubic convergence, needs ~8-12 iterations
Optimal settings:
# Balanced accuracy/speed
--ns_mode fftT --fftT_order 3 --ns_iters 12
# Maximum accuracy
--ns_mode fftT --fftT_order 3 --ns_iters 20
# Fast testing
--ns_mode fftT --fftT_order 2 --ns_iters 10
🖼️ Output Analysis
Generated Files (in output_figures/
)
image_deblurring_comparison.png
: Side-by-side resultsimage_deblurring_metrics.png
: PSNR/SSIM comparisonimage_deblurring_timing.png
: Performance analysis
Reading the Results
Comparison Grid Layout:
Metrics Table: - PSNR: Image quality (higher = better) - SSIM: Structural similarity (closer to 1 = better) - Time: Processing time (lower = faster)
🔧 Advanced Usage
Custom Blur Kernels
Modify the blur kernel in the script:
# Gaussian blur (default)
psf = build_psf_gaussian(size, sigma=1.5)
# Motion blur
def build_psf_motion(size, length, angle):
# Implementation for motion blur
pass
# Custom kernel
psf = your_custom_kernel(size)
Batch Processing
# Process multiple images
for size in 32 64 128; do
python applications/image_deblurring/script_image_deblurring.py \
--size $size --lam 1e-3 --snr 40
done
Integration with Other Tools
# Use QuatIca deblurring in your pipeline
import sys, os
sys.path.append('path/to/QuatIca/core')
from qslst import qslst_restore_fft
from utils import rgb_to_quat, quat_to_rgb
# Your image processing pipeline
def deblur_image(rgb_image, blur_kernel, lambda_reg=1e-3):
quat_image = rgb_to_quat(rgb_image)
restored_quat = qslst_restore_fft(quat_image, blur_kernel, lambda_reg)
return quat_to_rgb(restored_quat)
📈 Benchmark Results
Accuracy Comparison (PSNR in dB)
Image Size | QSLST-FFT | QSLST-Matrix | NS (fftT) | HON (fftT) |
---|---|---|---|---|
32×32 | 35.2 | 35.3 | 35.1 | 35.4 |
64×64 | 33.8 | 33.9 | 33.7 | 34.0 |
128×128 | 32.1 | 32.2 | 32.0 | 32.3 |
Speed Comparison (seconds)
Image Size | QSLST-FFT | QSLST-Matrix | NS (fftT) | HON (fftT) |
---|---|---|---|---|
32×32 | 0.05 | 0.8 | 0.15 | 0.25 |
64×64 | 0.12 | 4.2 | 0.35 | 0.55 |
128×128 | 0.28 | 18.5 | 0.85 | 1.35 |
🎯 Recommendations
For Production Use
# Recommended settings for production
python run_analysis.py image_deblurring \
--size 64 \
--lam 1e-3 \
--snr 40 \
--ns_mode fftT \
--fftT_order 3 \
--ns_iters 12
For Research/Validation
# Maximum accuracy settings
python run_analysis.py image_deblurring \
--size 128 \
--lam 1e-3 \
--snr 50 \
--ns_mode fftT \
--fftT_order 3 \
--ns_iters 20
For Fast Prototyping
# Quick testing settings
python run_analysis.py image_deblurring \
--size 32 \
--lam 1e-3 \
--ns_mode fftT \
--fftT_order 2 \
--ns_iters 10
🔍 Further Reading
- QSLST Paper: Fei, W., Tang, J., & Shan, M. (2025). Quaternion special least squares with Tikhonov regularization method in image restoration.
- Newton-Schulz Methods: Classical iterative methods for matrix inversion
- FFT Deconvolution: Fast frequency-domain approaches to image restoration
🎓 Next Steps
- Try different parameters: Experiment with λ, image sizes, noise levels
- Test on your images: Replace the default image with your own
- Explore other applications: Check out Image Completion
- Understand the theory: Dive into the API documentation