photographic deconvolution tool
Characterize the point spread function (PSF) of your lens and deconvolve images for aberration-aware sharpening. Photograph the test target on your monitor in pairs. Take one photo stopped down to reduce lens aberrations (typically f/8) and one at the desired aperture (e.g. wide open). Use the spatially varying PSFs to deconvolve images following Heide et al., High-Quality Computational Imaging Through Simple Lenses.
Everything runs client-side and nothing leaves your machine because I don't want to pay for your compute. Save your calibration for later reuse.
- Fullscreen the calibration pattern.
- Back off far enough to avoid moire. Use a tripod and a self-timer or shutter release cable to keep the images aligned. Prefer low ISO and good exposure. Use a focus distance similar to the one you want to calibrate.
- Stop down, focus on the calibration patter, and take a photo.
- Open to the desired aperture, refocus on the target, and take a photo without moving the tripod.
- Reframe and repeat the previous two steps until you have pairs of images of the test pattern covering the entire frame.
Keep the image size, orientation, format, and focal length consistent. The tool identifies the stopped-down and wider-aperture photos in either order.
Add another pair or merge saved profiles from the same lens setup to keep the best measurement at each position. Save the profile to restore other photos without recalibrating.
Calibration sources
PSF map
Low confidence (/100)
Boxes mark measured patches. Shading interpolates their scores across the frame. Select a position to inspect its PSF.
RMS blur radius (calibration px)
- Red
- Green
- Blue
Use a photo taken at the calibrated aperture, with the same camera, lens, focal length and focus distance. Keep the same image dimensions and orientation.
Compiled to WASM from heide-simple.
LLM summary of how this tool differs from Heide et al.
Heide et al. paper and MATLAB code
Calibration
- Target and patch boundaries. Heide et al. use white-noise patches with white borders to give each patch a constant boundary. We mix 1-, 2-, 4-, and 8-pixel squares in 64×64-pixel patches. The larger squares also contain fine texture. We fit only pixels whose full convolution footprint lies inside the measured patch.
- Exposure and PSF weights. Heide et al. calculate exposure gain before fitting. Their fit penalizes any deviation from a PSF weight sum of one. We fit exposure gain and the PSF together for each patch and color channel. We require nonnegative PSF weights that sum to one at every iteration.
- Fit resolution. Heide et al. fit PSFs in an image pyramid, from coarse to fine. We start with a regularized frequency-domain estimate and refine it at the capture resolution.
- Combining measurements. Heide et al. average neighboring PSFs in a 3×3 grid. We combine measurements from multiple capture pairs at the same position. The score uses patch texture, the error in predicted contrast, and clipping. The weakest color channel sets the score. We keep all three PSFs from the highest-scoring pair at each position.
Restoration
- Color guidance. The MATLAB code uses the red channel as a guide and adds one to the image intensities. We use linear intensities directly. We use the width and shape of the measured PSFs to select a guide only when one channel is sufficiently sharper.
- Adjoints and step size. The MATLAB code uses reverse filters with replicated padding for the derivative adjoints. It estimates an operator norm to choose the step size. We use the exact transposes of the forward derivatives, including at the image boundaries. We choose the step size from a conservative norm bound based on the filters and the guide channel.
- Nonnegativity. The MATLAB code sets negative values to zero after each solve. We enforce nonnegativity during the solve.
- Saturation. Heide et al. exclude saturated samples from the data fit. We use the standard fit up to a limit on clipped samples per tile and color channel. The limit is 0.01% of the tile's pixels, rounded down, with a minimum of 4 and a maximum of 8. When the count exceeds this limit, a clipped sample incurs a penalty only if the predicted blurred intensity falls below the clipping level.
- Restoration passes. Heide et al. use a coarse-to-fine reconstruction with residual passes and describe a separate regularizer for dark regions. We use the basic cross-channel prior and solve each channel once per tile at the photo's resolution.
- Tile layout. Heide et al. assign a measured PSF to each tile. We measure PSFs on a separate grid and interpolate a PSF at the center of each restoration tile. Each solve uses surrounding pixels for context. We blend the overlapping tile interiors in linear light.