Detecting blank scans

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
RobLewis

Detecting blank scans

Post by RobLewis »

I have a bunch of scans of the back sides of old photos. Some of them have handwritten notes; many are blank.

Is there a way to run them through IM and get some kind of report back to distinguish the blank ones from the nonblank ones?

Complication #1: many of the photos have a line or 2 of data printed by the photofinisher on the back, typically in a rather crude dot matrix font.

Complication #2: some of them have discolored patches or stains.

Complication #3: often the notes are written very lightly in pencil; readable to the eye but pretty low in contrast.

Enhancement: could IM generate a compressed, contrast-enhanced JPEG of nonblank images it finds? Readability and small file size are more important than image fidelity.

My idea was to assume that blank images would compress better than nonblank ones, and use the file size of the compressed image to tell whether it was blank or not.

Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Detecting blank scans

Post by fmw42 »

Do you consider complication 1 and 2 as blank or not blank?
RobLewis

Re: Detecting blank scans

Post by RobLewis »

fmw42 wrote:Do you consider complication 1 and 2 as blank or not blank?
Complication 2 is definitely a blank.

Complication 1 (photofinisher imprint) should probably be treated as blank, at least as the default option, if possible.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Detecting blank scans

Post by fmw42 »

Not an easy problem unless it is absolutely blank.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Detecting blank scans

Post by anthony »

I would threshold the image first or other types of convertsion to pure black and white. Fred Weinhaus has a lot of scripts and alturnative to simple threshold too.

Once in black and white output a histogram report to get a count of the number of 'valid' pixels. That will give you a good measure of the amount of information on the page. If you have a speicific line or area that appears offten and you don't want included in the count, overlay a mask or draw white to blank that area before getting the pixel count.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply