I'm look for a way to programatically check whether images are blurry or not and am interested in hearing any options I have to do so. I could use any programming language, though I'm most familiar with PHP and Python.
Thanks in advance for any ideas you have.
There's a lot of advice on here about computing Laplacian of Gaussians and theoretical stuff, but I sense you want something practical and easy, so I would suggest you use ImageMagick like this to compute the Laplacian at the command line. It is installed on most Linux distros and available for Windows and OS X.
Here is a sharp image:
and I compute its Lapalacian like this at the command line
convert face1.jpg colorspace gray -define convolve:scale='!' -bias 50% \
-morphology Convolve Laplacian:0 laplacian.png
and get the statistics like this, looking at the min/max and the standard deviation:
identify -verbose laplacian.png | grep -E "min|max|deviation"
min: 44 (0.172549)
max: 200 (0.784314)
standard deviation: 4.52133 (0.0177307)
Now I do the same for a blurry version
and I get this:
identify -verbose laplacian.png | grep -E "min|max|deviation"
min: 118 (0.462745)
max: 135 (0.529412)
standard deviation: 0.835725 (0.00327735)
You can either shell out from PHP and use the commands I am giving, or use the PHP bindings for ImageMagick.
If you don't want the image output and are just interested in the statistics, you can avoid creating an intermediate file like this:
convert blur.jpg -colorspace gray \
-define convolve:scale='!' -bias 50% \
-morphology Convolve Laplacian:0 -verbose info: | grep -Ei "min|max|deviation"