Skip to content
Projects

Blind blur estimation

Telling from a blurred image alone whether it was blurred by motion, defocus or a Gaussian kernel, and estimating how much, as the first step to restoring it.

Blind blur estimation, screenshot 1
Blind blur estimation, screenshot 2

Details

Period
2025
Status
Completed
Code
Private repository
Stack
PyTorch, OpenCV, NumPy, Matplotlib

Case study

Problem

A blurred photo can be restored if you know how it was blurred, but usually you don’t: the blur has to be worked out from the image itself. Following Yan and Shao (IEEE Transactions on Image Processing, 2016), this project splits the work into two stages: first recognise the type of blur, then estimate its parameters.

Approach

  • Data. Patches of 64 × 64 pixels taken from sharp images and blurred synthetically: motion blur (angles 0–165°, lengths 5–25 px), defocus (radii 3–15 px) and Gaussian blur (σ 0.5–3.75). Each patch is described by the log-magnitude of its Fourier spectrum, where each kind of blur leaves its own pattern, together with edge maps from Canny edge detection and the Hough transform.
  • Classification. Two approaches compared. The paper’s deep network (4096 → 512 → 256 → 128 → 3), pre-trained layer by layer as restricted Boltzmann machines, and lightweight transformers: a TinyViT-style encoder with one layer and two attention heads, and a simplified MobileViT. They were trained on a laptop, with memory-saving measures such as gradient accumulation.
  • Parameters. For each blur type, a General Regression Neural Network estimates the parameters: angle and length for motion, radius for defocus, σ for Gaussian blur. It is memory-based and needs no iterative training.

Results

On the synthetic test patches, the TinyViT classifier reached 99.96% accuracy, with about 10,000 parameters (0.04 MB) and 0.13 ms per patch, over 7,400 patches a second. The deep network was almost as accurate, with a much larger model (about 2.3 million parameters) and slower inference.

Estimating the parameters was harder. The mean absolute error was 47° on the motion angle, 5.7 px on its length and 3.9 px on the defocus radius, while Gaussian σ was estimated exactly on the test set. In the paper’s accuracy measure, that is 73% for motion, 73.9% for defocus and 100% for Gaussian blur.