The idea is from "The Blur Effect: Perception and Estimation with a New No-Reference Perceptual Blur Metric"
Crété-Roffet F., Dolmiere T., Ladret P., Nicolas M. - GRENOBLE - 2007
In SPIE proceedings - SPIE Electronic Imaging Symposium Conf Human Vision and Electronic Imaging, États-Unis d'Amérique (2007)
Written by DO Quoc Bao, PhD Student in L2TI Laboratory, Paris 13 University, France
There are a few things that should be changed in this file.
1) The im filter functions on lines 24 and 25 should have the option 'replicate' to avoid boundary errors in the smoothing which biases the deltas calculated in lines 30-31.
2) The vertical and horizontal smoothing filters are swapped. You can tell this by looking at the intermediate images. B_Ver for example is blurred in the horizontal direction.
3) And lastly a note: lines 39-43 do not sum over the whole array like the paper does.
4) The input expects a luminance image. It would be nice to check if image is a luminance image and if not, convert it automatically.