2

How would one go about creating an algorithm that detects the unblurred parts of a picture? For example, it would look at this picture:

enter image description here

and realize the non blurred portion is:

enter image description here

I saw over here how to measure the blur of the whole picture. For this problem, should I just create a threshold for the maximal absolute second derivative for the pixels? And then whichever one exceeds, is considered a non blurred region?

agiro
  • 2,018
  • 2
  • 30
  • 62
  • 2
    Sounds like a good start. You probably need to do some postprocessing, though. Why don't you just try? Another approach would be taking a small window around each pixel and analyzing the frequencies. If there are no high frequencies, it is likely in a blurred region. – Nico Schertler Jul 16 '17 at 16:30
  • @NicoSchertler Thanks! Will do. If it doesn't work out though, what should I do? I'm guessing reposting a question is not allowed. – Clangorous Chimera Jul 17 '17 at 13:51
  • You can edit your question to reflect your new findings. The question will then re-appear on SO's start page as far as I know. – Nico Schertler Jul 17 '17 at 18:19

1 Answers1

3

A simple solution is to detect high frequency content.

If there's no high frequency content in an area, it may be because it is blurred.

How to detect areas with no high frequency content? You can do it in the frequency domain (for example, with DCT), or you can do it in the spatial domain.

First, I recommend the spatial domain method.

You'll need some kind of high-pass filter. The easiest method is to blur the image (for example, with a gauss filter), then subtract it from the original, then convert to grayscale:

Blurred:

enter image description here

Subtracted:

enter image description here

As you see, all the blurred pixels become dark, and high frequency content is bright. Now, you may want to blur this image, and apply a threshold, to get this:

enter image description here

Note: this process was done by hand, with gimp. Your algorithm can easily follow this, but need some parameters specified (like the blur radius, threshold value).

geza
  • 28,403
  • 6
  • 61
  • 135