simply-blur-detector

CNN vs. Laplacian · nothing leaves your browser

Is it blurry?

Start with one of the pictures below, or drop your own. A small convolutional network, trained on images blurred with blur-generator, and the classic Laplacian variance both take a look, window by window.

no picture
loading the model…

Stress test

Blur the current picture a little more at every step and watch both detectors change their minds. The blurs are simulated in your browser on a copy at most 512 px wide.

Pick a kind of blur and press Run.

Both lines are blur scores from 0 (sharp) to 1 (blurry). The Laplacian score is threshold ÷ (threshold + variance), so it crosses 0.5 exactly at the threshold.
Show as a table

How it works

Same model, same maths, from the training script to this page.

  1. Sharp picturesdrawn by code into data/train and data/test, folder nonblur (or your own)
  2. blur-generatora lens, Gaussian or motion blur for every one, into blur
  3. Keras CNN3 conv blocks → 2 dense layers, 100k weights, trained on whole pictures and crops
  4. ONNXexported and checked against Keras by GitHub Actions
  5. Your browserONNX Runtime Web; the pixels stay on your machine

The CNN

Every picture is prepared exactly like the training data: each colour channel's histogram is equalized, the picture is squeezed to 256 × 256 and scaled to 0–1. The network answers with two probabilities, sharp and blurry. For the heat map it looks at square windows, half as wide as the picture's shorter side, which is the smallest crop it saw in training.

The Laplacian variance

The Laplacian filter lights up wherever brightness changes abruptly, so a sharp picture has a wildly varying Laplacian and a blurry one a flat, quiet one. Its variance is a one-line blur score with no training at all. Its weak spot: flat areas such as sky look "blurry" even when they are in focus.

Model card

status
loading…

The model learned from a hundred illustrations of this project and their copies blurred with blur-generator, so it is most at home with drawings and less sure about photos.

The sample pictures are part of this project, under its MIT licence. Your own pictures never leave your browser.