How can I quickly and reliably assess the degree of blur in a photograph of a document?

Let's say I have a 20 megapixel photograph of a document containing printed or handwritten text. The text, of course, and the background, may be slightly distorted by shadows, flash or lamp halos, etc.

I want to appreciate the blur in the top half and the bottom half of the image. Since I know that typed (and hopefully handwritten) text is too sharp to detect in the camera's general-purpose resolutions / settings, I assume that the borders of the text in the background are infinitely sharp. I am thinking of detecting the minimum number (or 1st percentile) of pixels that form a border between minBrightness + 5% (text color) and maxBrightness-5% inside the local brightness box - since the dynamic range and lighting conditions change at different places in the photo. So, if I need at best 3 pixels to go from BlackPoint

to WhitePoint

, I would infer that the size of my blur is roughly 2 pixels.

There are several problems with my idea. The algorithm I'm thinking about looks slower than the filter. This can lead to misleading results if I run it in an area that has no text at all (for example, a document whose bottom half is completely blank) and therefore relies on a hard minimum dynamic range (for example, if maxBrightness-minBrightness < 100, no text, don't try to judge the blur). Thirdly, the algorithm I have does not seem to be very robust about noise, shadows, etc., and it can fail if the actual font is not black and white, but grayscale for aesthetic purposes.

Given my concerns, is there a fast, reliable, moderately accurate algorithm that performs better than the one I have in mind?

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

+3


source to share


1 answer


Since your text needs to be sharp, it seems like a generic "in focus" or blur detector might work. Something like: Is there a way to detect if the image is blurry? and Blur detection in images / video sequences is applied to sections of your image.



+1


source







All Articles