4

I'm writing a script to detect blur images using OpenCV by applying Laplacian filter and calculate the std but there is a problem the std for images that contain motion blur is very close to those images which contain any other type of blur. (my propose is to find detect unsuitable images that can't detect the object on it like a dog image that contain motion blur for example)

blurry image

I used this piece of code cv2.Laplacian(image, cv2.CV_64F, ksize=3 ).std() to find the blur ratio and make a threshold for std < 40 is considered a blurry image so I want a method to can differentiate between images that contain motion blur images and other kinds of blur

Marcus Müller
  • 24,744
  • 4
  • 29
  • 50
noura_7ussein
  • 43
  • 1
  • 5

2 Answers2

2

You can use the following variance of Laplacian responses:

cv2.Laplacian(gray_image, cv2.CV_64F).var()

More details at https://www.pyimagesearch.com/2015/09/07/blur-detection-with-opencv/

beahacker
  • 121
  • 3
1

Instead of filtering with a symmetric gaussian, which is a blurry kernel in every direction, just filter with two 1D-kernels:

One in x direction (a row vector kernel, if you will), and one in y direction (column vector).

If the "blurriness" in both directions is the same, generally blurry. If it's much higher in one direction than in the other: motion blur.

You'll have to adjust your thresholds for "blurriness" to also accomodate diagonal motion blur.

Marcus Müller
  • 24,744
  • 4
  • 29
  • 50