10

I am working on images that are partially blur on some sections. These are noises that should be taken care of, but here is the problem:

Are there methods to detect whether an image is blur or partially blur at some sections of an image? For instance, take a look at sample image below:

blur test

You can see in the image that there are 3 sections that are visually blur: bottom-left, near center region and top-right. Now, is it possible to detect that any portion of an image is blur programming-wise or mathematically?

Karl
  • 5,613
  • 13
  • 73
  • 107
  • I'm not sure about existing methods, but (if all your images will be similar to the above) you could run an edge detection method and look for regions with an absence of edges. – Iain_b Aug 20 '12 at 14:32
  • 2
    [Downvoted] Hum, you've got to define "blurry" first, and its kissing cousin "scale" - as in "blurry at which scale"? And "blurry because of what"? Motion? Defocusing? Bird poop on the lens? – Francesco Callari Aug 21 '12 at 12:42
  • @FrancoCallari: yes, I understand that having the respective parameters will help greatly. If you know what type of blur you are facing, you can perform a respective anti-blur technique. But I want to know whether there are techniques out there that can detect any kind of blur (it could be motion blur, radial blur, etc.) without given these parameters (such as "blurry at which scale")? In other words, the software will be given only an image without any other parameters you have mentioned. Can we detect whether an image is blur without those parameters? Or is this not possible? – Karl Aug 21 '12 at 13:01
  • 1
    Only thing I can think of is FFT over portions of the image (and again, the size of the "portion" would define the "scale" of the blur), then look at the distribution of statistics from those spectra over the image. But again, you are talking of stuff that's rather in the eye of the beholder here: take a a perfectly focused photo of a tree in a misty morning: is it blurry or sharp? – Francesco Callari Aug 22 '12 at 14:12
  • Did a little bit of digging. http://photo.stackexchange.com/questions/32388/how-can-i-focus-peak-a-photograph and http://dsp.stackexchange.com/questions/2304/auto-focus-estimation – Justin Apr 12 '13 at 18:00

2 Answers2

15

As lain_b pointed out, with an image like this you can use an edge detector and look for an absence of edges. I tried it on your image and it seems to work pretty well. First I used the kernel

[0,1,0,
 1,-4,1,
 0,1,0]

Which is a simple edge detector. Its result was

enter image description here

Then I used a threshold to get

enter image description here

Then I closed the image and opened it to get

enter image description here

This is obviously not a finished version, the top right portion did not recognize well at all. Perhaps you could improve it by blurring before performing thresholding, or by choosing better values for the threshold and the radii of the opening and closing operations. A lot of the decisions you will need to make depend on the constraints you can put on your problem. I think this technique will work for you though.

Edit If you are looking for blur detection of arbitrary images you are going to have to investigate a wide variety of techniques. Things are much easier if you can make assumptions about your set of input images. Without any assumptions I don't know what will work best for you. Here is some reading on the topic

Image Blur Metrics

Reserach paper on using the Harr wavelet transform

Similar SO Question and look at the question that question links to

Blur detection is a very active research field, there is no one answer. You will just need to try all the methods you can find (these were found by googling detect blur in image).

Community
  • 1
  • 1
Hammer
  • 10,109
  • 1
  • 36
  • 52
  • This image is just an example image to show you what we might encounter. Yes, your method may work for the given image, but other images such as real world images, it does not work. We don't know the parameters to apply into the kernels and such respectively. My question is "given any image, is it possible to detect that an image is blurry at all?" Or must we always require some other pretext to do this job? – Karl Aug 21 '12 at 08:43
  • 3
    @Karl that is an active research question. There are a variety of papers to read on the topic. Nobody is going to be able to give you a single "best" way (if they can they should publish a paper on it). If you are talking about arbitrary images in the future be sure to **say** so, posting an example image implies that it is representative of your problem. – Hammer Aug 21 '12 at 15:14
  • @Hammer You provided an example matrix [0,1,0, 1,-4,1, 0,1,0]. What does this matrix represent and how did you apply it to Karl's example image to produce the first edge detection image? – Justin Apr 12 '13 at 17:22
  • @Justin it is a lot like this http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/sobel_derivatives/sobel_derivatives.html – Hammer Apr 12 '13 at 18:15
2

This paper may be of some help. It does blur estimation (mostly for out of focus, but I think it also does blur) to recreate a similarly blurred object in the image.

I think you should be able to use it to detect the blurred areas, and how blurred they are. It should be especially relevent to your problem as it is designed to work with real-world images.

Bill
  • 698
  • 1
  • 5
  • 22