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-first API: Top-level functions operate on
image::DynamicImageand return image buffers suitable for saving or further processing. - Known-PSF restoration: Includes inverse filters, Wiener-family methods, Richardson-Lucy variants, iterative least-squares methods, constrained solvers, sparse/proximal methods, Krylov methods, and MLE-style solvers.
- PSF and OTF tooling: Provides owned
Kernel2D/Kernel3DandTransfer2D/Transfer3Dtypes, plus PSF generators, support utilities, andpsf2otf/otf2psfconversions. - Blind deconvolution: Includes blind Richardson-Lucy, blind maximum likelihood, and parametric blind workflows with PSF constraints.
- Preprocessing and simulation: Edge tapering, apodization, NSR estimation, deterministic blur/noise helpers, and synthetic fixtures are available for testing and examples.
- ndarray API: Public
ndmodules expose 2D and 3D array workflows for users who want to bypassDynamicImageconversion.
Installation
[]
= "0.1.0"
The crate uses image as its image API. Applications that load or save image
files directly should also depend on image:
rayon is enabled by default and enables the rayon features on ndarray and image
rayon feature flags. Disable default features for a serial build:
[]
= { = "0.1.0", = false }
Quick Start
use gaussian2d;
use ;
Image API, Channels, and Policies
The primary API accepts image::DynamicImage values. Current image-facing
algorithms support these DynamicImage variants:
ImageLuma8ImageLumaA8ImageRgb8ImageRgba8
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 8-bit image ranges.
PSFs, OTFs, and Support Utilities
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 Deconvolution Method Families
Spectral and inverse filters
Frequency-domain methods for fast known-kernel restoration.
naive_inverse_filterinverse_filtertruncated_inverse_filterregularized_inverse_filtertikhonov_inverse_filterwienerunsupervised_wiener
Configuration types:
InverseFilterRegularizedInverseFilterTikhonovInverseFilterWienerUnsupervisedWiener
Each method also exposes a _with variant for explicit configuration.
Richardson-Lucy and regularized RL
Poisson-style multiplicative restoration with positivity-aware updates.
richardson_lucydamped_richardson_lucyrichardson_lucy_tv
Configuration types:
RichardsonLucyRichardsonLucyTv
Iterative least-squares methods
Residual-update solvers for deterministic restoration workflows.
landwebervan_citterttikhonov_millerictm
Configuration types:
LandweberVanCittertTikhonovMillerIctm
Constrained solvers
Bound-aware restoration methods.
nnlsbvls
Configuration types:
NnlsBvls
Sparse and proximal methods
Proximal-gradient solvers with sparse-basis control.
istafista
Configuration and model types:
IstaFistaSparseBasis
Krylov and advanced iterative methods
Scientific-imaging style iterative families.
mrnsdcglswplhybr
Configuration types:
MrnsdCglsWplHybr
Maximum-likelihood family
Microscopy-oriented MLE-style restoration methods.
cmlegmleqmle
Configuration types:
CmleGmleQmle
Blind Deconvolution
Blind workflows estimate both the restored image and the PSF.
blind::richardson_lucyblind::maximum_likelihoodblind::parametric
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.
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
Simulation utilities are deterministic and useful for tests, examples, and benchmark inputs.
Blur and degradation:
simulate::blur::blursimulate::blur::blur_otfsimulate::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 the only crate feature and is enabled by default.
[]
= ["rayon"]
= ["dep:rayon", "ndarray/rayon", "image/rayon"]
Disable default features for serial builds:
Example Programs
Image-facing workflows:
Volume workflow:
Benchmarks and Development
Bench families (criterion):
spectralrlblindvolume
Development checks:
Limitations and Scope
- The image-facing API currently supports 8-bit Gray, GrayAlpha, Rgb, and Rgba
DynamicImagevariants. - Deconvolution quality depends heavily on the PSF, boundary assumptions, and regularization strength.
- Aggressive inverse filtering can amplify noise and ringing; prefer Wiener, damping, TV regularization, edge tapering, or constrained solvers for noisy inputs.
- Blind deconvolution is sensitive to initialization and PSF constraints.
License
deconvolution is licensed under the MIT License, copyright (c) 2026 pbkx.