8
$\begingroup$

Is there any strategy to detect the region of an image that is sharp and in-focus, in order to separate the out-of-focus background? I've tried using edge detection methods but without any success.

In other words, is it possible to determine if an area of an image is blurred (out of focus) or not?

$\endgroup$
5
  • 1
    $\begingroup$ Do you mean that you want to detect areas of an image that are sharp and in-focus, versus blurred and out-of-focus? $\endgroup$ Oct 7, 2015 at 19:46
  • 1
    $\begingroup$ How did you used edge detection algorithms? Not sure it works and can't test now (so no answer for now :P), but just off the top of my head, you can divide your image in subregions and measure the value of gradients. Based on a threshold you can then decide whether that subregion is "in-focus" or not. Then you can re-use the edge info to refine your first approximation I described before. It makes sense to me know, but it may very well be a brain-fart being it late here :) I'll give it a try tomorrow if I have a minute to. $\endgroup$
    – cifz
    Oct 7, 2015 at 21:13
  • $\begingroup$ @cifz - Thanks! Great idea to measure the gradiants, sounds like a simple and fast approach. But this will only work for a rough detection, right? $\endgroup$
    – p2or
    Oct 8, 2015 at 10:24
  • $\begingroup$ @NathanReed Right. Sorry, not a native :) Do you think I should rephrase the question? $\endgroup$
    – p2or
    Oct 8, 2015 at 10:28
  • $\begingroup$ @poor Yes, I think it would be helpful to rephrase and edit the title to make it more clear. $\endgroup$ Oct 8, 2015 at 17:10

1 Answer 1

11
$\begingroup$

it is quite easy to measure the local max frequency in an image (at least as a low resolution mask, with some regularization). Several papers of the MIT graphics group have been around detecting and processing from this kind of clue, with regular or coded aperture cameras. e.g. Defocus Magnification and Image and Depth from a Conventional Camera with a Coded Aperture.

$\endgroup$
3
  • $\begingroup$ Many thanks Fabrice! If possible, can you elaborate local max frequency? $\endgroup$
    – p2or
    Oct 8, 2015 at 10:44
  • $\begingroup$ I don't remember how these papers were estimating the native focus before refocusing. But I could think of various solutions: poor-man wavelets by calculating the FFT in a grid of subimages (i.e. a grid of windowed FFT), estimating local autocorrelation, poor-man FFT by convolving with a set of Differential of Gaussians (to detect ranges of focus), etc. But this is kind-of instant-hacking, the best is to read what the experts did for real :-) $\endgroup$ Oct 8, 2015 at 12:58
  • $\begingroup$ Any work done on single image, not with Coded Aperture? Thank You. $\endgroup$
    – Royi
    Oct 19, 2015 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.