As part of a duplex scanning pipeline I need to detect empty pages such that they can be excluded from the OCR and the resulting PDF document.
Currently, I'm using a 'blurry' trim which works pretty well. Example with ImageMagick:
convert image-0001.png -shave 300x0 -virtual-pixel White -blur 0x15 -fuzz \ 15% -trim info:
(if the resulting dimensions are below a threshold then the page is considered empty)
But this is slow.
What are faster alternative approaches for accurately detecting empty pages in scanned images?
Things that complicate the empty page detection:
- the noise - i.e. scanned dust etc.
- margins/punch-holes that may show up as black lines
- almost empty pages (e.g. just 2 words in 12 pt on an otherwise blank pages) must not be detected as empty
- pages without any text but with images must not be detected as empty