Show HN: Deconvolution – a Rust image deconvolution and restoration crate
Summary
Deconvolution is a Rust crate for image deconvolution and restoration, providing known-PSF and blind restoration methods, PSF/OTF conversion, preprocessing, and simulation utilities.
View Cached Full Text
Cached at: 06/17/26, 05:42 PM
pbkx/deconvolution
Source: https://github.com/pbkx/deconvolution
deconvolution
| Original | Deconvolved |
|---|---|
![]() | ![]() |
Before (left) is the motion-blurred sample; after (right) is restored using wiener_with.
Rust image deconvolution and restoration library.
Recovering images from blur depends on a point-spread function, stable
frequency-domain utilities, and careful regularization. deconvolution
provides known-PSF restoration, blind workflows, PSF/OTF conversion,
preprocessing helpers, simulation fixtures, and ndarray APIs.
Overview
- Image API: Top-level functions use
image::DynamicImageand return images ready to save. - Known PSF methods: Inverse filters, Wiener, Richardson-Lucy, constrained, proximal, Krylov, and MLE-style restoration.
- Blind methods: Blind Richardson-Lucy, blind maximum likelihood, and parametric PSF estimation.
- PSF and OTF types:
Kernel2D,Kernel3D,Transfer2D,Transfer3D, andBlur2D/Blur3D. - PSF tools: Gaussian, motion, defocus, microscopy models, support utilities, and PSF/OTF conversion.
- Preprocessing: Edge tapering, apodization, range normalization, and NSR estimation.
- Simulation: Deterministic blur, noise, and synthetic fixture generation.
- ndarray support: 2D image arrays and 3D volume workflows.
- Feature flags:
rayonby default; optionalf16support.
Installation
cargo add deconvolution
[dependencies]
deconvolution = "0.2.0"
Image loading: Add image when your application opens or saves image files.
cargo add image
Serial build: Disable default features to turn off rayon.
[dependencies]
deconvolution = { version = "0.2.0", default-features = false }
Quick Start
use deconvolution::psf::basic::gaussian2d;
use deconvolution::spectral::{wiener_with, Wiener};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let input = image::open("before_deconvolution.png")?;
let psf = gaussian2d((15, 15), 2.15)?;
let restored = wiener_with(&input, &psf, &Wiener::new().nsr(2.5e-4))?;
restored.save("after_deconvolution.png")?;
Ok(())
}
Image API
Supported DynamicImage variants:
ImageLuma8ImageLumaA8ImageRgb8ImageRgba8ImageLuma16ImageLumaA16ImageRgb16ImageRgba16ImageRgb32FImageRgba32F
Configuration enums are shared across algorithm families:
Boundary:Zero,Replicate,Reflect,Symmetric,PeriodicPadding:None,Same,Minimal,NextFastLen,Explicit2,Explicit3ChannelMode:Independent,LumaOnly,IgnoreAlpha,PremultipliedAlphaRangePolicy:PreserveInput,Clamp01,ClampNegPos1,Unbounded
Use ChannelMode::Independent for per-channel color restoration,
ChannelMode::LumaOnly when the blur should primarily affect luminance, and
RangePolicy::PreserveInput when working in normal image sample ranges.
PSF and OTF API
Basic PSF generators:
delta2d,delta3dgaussian2d,gaussian3dmotion_lineardisk,pillbox,defocusbox2d,box3doriented_gaussian
Blind initialization helpers:
psf::init::uniformpsf::init::gaussian_guesspsf::init::motion_guesspsf::init::from_support
Support utilities:
normalize,normalize_3dcenter,center_3dpad_to,pad_to_3dcrop_to,crop_to_3dflip,flip_3dvalidate,validate_3dsupport_mask,support_mask_3d
Transfer conversion utilities:
otf::convert::psf2otfotf::convert::psf2otf_3dotf::convert::otf2psfotf::convert::otf2psf_3d
Optical and microscopy models:
BornWolfParams/born_wolfGibsonLanniParams/gibson_lanniVariableRiGibsonLanniParams/variable_ri_gibson_lanniRichardsWolfParams/richards_wolflorentz2dastigmaticdouble_helixotf::spectra::koehler_otfotf::spectra::defocus_otf
Known PSF Methods
Spectral and inverse filters
Frequency-domain restoration.
naive_inverse_filterinverse_filtertruncated_inverse_filterregularized_inverse_filtertikhonov_inverse_filterwienerunsupervised_wiener
Configuration types:
InverseFilterRegularizedInverseFilterTikhonovInverseFilterWienerUnsupervisedWiener
Custom configs: Use _with variants.
Richardson-Lucy and regularized RL
Poisson-style multiplicative restoration.
richardson_lucydamped_richardson_lucyrichardson_lucy_tv
Configuration types:
RichardsonLucyRichardsonLucyTv
Iterative least-squares methods
Residual-update restoration.
landwebervan_citterttikhonov_millerictm
Configuration types:
LandweberVanCittertTikhonovMillerIctm
Constrained solvers
Bound-aware restoration.
nnlsbvls
Configuration types:
NnlsBvls
Sparse and proximal methods
Proximal-gradient restoration.
istafista
Configuration and model types:
IstaFistaSparseBasis
Krylov and advanced iterative methods
Scientific imaging solvers.
mrnsdcglswplhybr
Configuration types:
MrnsdCglsWplHybr
Maximum-likelihood family
Microscopy-oriented MLE-style restoration.
cmlegmleqmle
Configuration types:
CmleGmleQmle
Blind Deconvolution
Blind workflows estimate both the restored image and the PSF.
Image-facing blind workflows support Gray and GrayAlpha DynamicImage variants
for u8 and u16 samples.
blind::richardson_lucyblind::maximum_likelihoodblind::parametric
blind::maximum_likelihood shares the same Poisson EM restoration core as blind Richardson-Lucy.
Configuration and output types:
BlindRichardsonLucyBlindMaximumLikelihoodBlindParametricBlindOutput<I>BlindReportParametricPsfPsfConstraint
PSF constraints:
NonnegativeNormalizeSumSupportMask(...)
Parametric PSF families:
Gaussian { sigma }MotionLinear { length, angle_deg }Defocus { radius }OrientedGaussian { sigma_major, sigma_minor, angle_deg }
ndarray Workflows
The public nd module exposes array-first workflows for users who already work
in ndarray or need 3D volumes.
Enable the optional f16 feature to pass half::f16 arrays into the 2D
ndarray API while keeping computation in f32.
2D known-PSF methods in nd::known_psf:
wiener,unsupervised_wienerrichardson_lucy,richardson_lucy_tvlandweber,van_cittert,tikhonov_miller,ictmnnls,bvlsista,fistamrnsd,cgls,wpl,hybr
Blind methods in nd::blind:
richardson_lucymaximum_likelihood
3D and microscopy methods in nd::microscopy:
wienerrichardson_lucyrichardson_lucy_tvcmlegmleqmle
Preprocessing
Preprocessing utilities help reduce ringing and prepare numerical inputs.
preprocess::apodizepreprocess::apodize::window_edgespreprocess::edgetaperpreprocess::estimate_nsrpreprocess::normalize_range
Use edgetaper or apodization before frequency-domain deconvolution when
strong edge discontinuities create ringing artifacts.
Simulation and Fixtures
Deterministic: Same input and seed produce the same simulated output.
Fixtures: Synthetic images and volumes for tests, examples, and benchmarks.
Blur and degradation:
simulate::blur::blursimulate::blur::blur_otfsimulate::blur::blur_3dsimulate::blur::blur_otf_3dsimulate::blur::degrade
Noise models:
simulate::noise::add_gaussian_noisesimulate::noise::add_poisson_noisesimulate::noise::add_readout_noise
Synthetic fixtures:
simulate::phantom::checkerboard_2dsimulate::phantom::gaussian_blob_2dsimulate::phantom::rgb_edges_2dsimulate::phantom::phantom_3d
Optional rayon Integration
rayon is enabled by default. The optional f16 feature adds half::f16
input/output support for the 2D ndarray API; computation remains in f32.
[features]
default = ["rayon"]
rayon = ["dep:rayon", "ndarray/rayon", "image/rayon"]
f16 = ["dep:half"]
Disable default features for serial builds:
cargo test --no-default-features
Example Programs
Image-facing workflows:
cargo run --example wiener -- input.png output.png
cargo run --example richardson_lucy
cargo run --example blind_motion
cargo run --example edgetaper
cargo run --example custom_regularizer
Volume workflow:
cargo run --example microscopy_volume
Benchmarks and Development
Benchmarks: Criterion benchmark families.
spectralrlblindvolume
cargo bench --no-run
cargo bench --bench spectral
cargo bench --bench rl
cargo bench --bench blind
cargo bench --bench volume
Checks:
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo check --all-features
cargo test --workspace --all-targets --all-features
cargo doc --workspace --no-deps --all-features
Limitations and Scope
- Known-PSF image-facing algorithms support u8/u16 Gray, GrayAlpha, Rgb, and Rgba
DynamicImagevariants, plus 32-bit float Rgb and Rgba images. - Blind image-facing algorithms support u8/u16 Gray and GrayAlpha
DynamicImagevariants.
License
deconvolution is licensed under the MIT License, copyright (c) 2026 pbkx.
Similar Articles
CogSENet: Blind Image Deblurring with Blur-Conditioned Semantic Routing and Explicit Frequency Fusion
CogSENet introduces a blind image deblurring framework inspired by eagle vision, using semantic-aware modules and frequency decomposition to improve restoration quality and structural fidelity, outperforming state-of-the-art methods.
Show HN: Photoc – Command-line tools for photographers
Photoc is a new open-source command-line toolkit for photographers to review, organize, and prepare photos from the terminal — including metadata inspection, finding blurry shots and duplicates, renaming, contact sheets, and GPS scrubbing, with JPEG support and Sony ARW RAW metadata reading.
When Fast Fourier Transform Meets Transformer for Image Restoration (2024)
SFHformer introduces Fast Fourier Transform into Transformer architecture for efficient image restoration, achieving state-of-the-art on ten tasks including deraining, dehazing, and super-resolution. The paper was accepted at ECCV 2024 with an extension SWFormer released in 2025.
Rust implementations of vision transformer models
A Rust crate for building and experimenting with Vision Transformer (ViT) models, providing typed configs, reusable structs, and runnable examples for research and production.
PixRestore: Unified Image Restoration via Pixel Diffusion Transformer
PixRestore is a VAE-free pixel-space diffusion transformer for unified image restoration, achieving high fidelity and efficiency via flow matching and adversarial fine-tuning to a one-step generator.

