Home Blur Detection
Post
Cancel

Blur Detection

How to do Blur Detection?

We can get the value of blur by using cv2.Laplacian(src, ddepth, ksize, scale, delta).var() where:

  • src : Grayscaled image.

  • ddepth : Desired depth of the destination image.

  • ksize : Aperture size used to compute the second-derivative filters.
    If ksize > 1, Laplacian is computed $\Delta src\ =\ \frac{\delta a^{2} src}{\delta x^{2}}\ +\ \frac{\delta^{2} src}{\delta y^{2}}$.
    If ksize = 1, Laplacian is computed by filtering the image with 3X3 matrix which is:
    \(\begin{bmatrix} 0 & 1 & 0\\ 1 & -4 & 1\\ 0 & 1 & 0 \end{bmatrix}\)

  • scale : Optional scale factor for the computed Laplacian values.

  • delta : Optional delta value that is added to the results prior to storing them in dst.

To detect blur, we take the variance of the response output. The Laplacian is the 2nd derivative of an image and thus it highlights the areas of an image containing rapid intensity changes. Hence it’s use in Edge Detection. A high variance should in theory, indicate the presence of both edge-like and non-edge like (hence the wide range of values resulting in a high variance), which is typical of a normal in-focus image. A low variance, thus might mean very little edges in the image meaning it might be blurred as the more blur present the less edges there are.





Implementation

This post is licensed under CC BY 4.0 by the author.