3

Suppose I have a 20 MP photo of some document, containing printed or handwritten text. The text, of course, and background, can be mildly distorted by shadows, halo from flash lightning or a lamp, etc.

I want to estimate the blur in the top half and in the bottom half of the image. Since I know that printed (and hopefully, handwritten) text is much too sharp to detect in general-purpose camera resolutions/settings, I assume text-to-background boundaries are infinitely sharp. I am thinking of detecting the minimum number (or 1st percentile) of pixels that form the boundary between minBrightness+5% (text color) and maxBrightness-5% inside a local brightness window - because the dynamic range and lightning conditions change in different localities of the photo. So, if I need at best 3 pixels to cross from BlackPoint to WhitePoint, I would infer that my blur size is roughly 2 pixels.

There are a few problems with my idea. The algorithm I am thinking of seems way slower than a filter. It could give misleading results if I run it on a region that has no text at all (e.g. a document, whose lower half is entirely blank), and so it relies on hardcoded minimum dynamic range (e.g. if maxBrightness-minBrightness < 100, there is no text; do not try to estimate blur). Thirdly, the algorithm I have does not seem very robust in regards to noise, shadows, etc, and it could fail if the actual text font is not black-white, but is grayscale for aesthetic purposes.

Given my concerns, is there a fast and robust, moderately accurate algorithm that will do the task better than the algorithm I have in mind?

PS for now I am assuming uniform blur as opposed to directional blur because the direction of the blur is not central to my task.

Boyko Perfanov
  • 3,007
  • 18
  • 34

1 Answers1

1

Since your text should be sharp, it seems like a general "in focus" or blur detector might work. Something like: Is there a way to detect if an image is blurry? and Detection of Blur in Images/Video sequences applied to sections of your image.

Community
  • 1
  • 1
abarry
  • 425
  • 3
  • 16
  • I've already implemented the Laplacian-based method family heavily referenced in the 1st answer but even though it is fast, it only correlates with blur. The approach to directly operate on DCT coefficients in jpeg files (provided your input is in jpeg form) can be fast and useful. – Boyko Perfanov Jul 31 '15 at 08:35