I am using scanimage with a document scanner (Canon DR-2510C) that supports duplex scanning. Unfortunately, its SANE driver does not support blank page detection, so that with mixed pages (single/double-sided), blank pages make it into the scan result.

I would like to automatically get rid of those blank pages when post-processing the scan output, so I am looking for a command-line tool that is able to detect whether a TIFF or PNM file consists of mostly white pixels).

Any ideas?


This is the solution I came up with based on the answer by lesmana:

for i in "${DEST_DIR}/out"*.pnm; do
  histogram=`convert "${i}" -threshold 50% -format %c histogram:info:-`
  white=`echo "${histogram}" | grep "white" | sed -n 's/^ *\(.*\):.*$/\1/p'`
  black=`echo "${histogram}" | grep "black" | sed -n 's/^ *\(.*\):.*$/\1/p'`
  blank=`echo "scale=4; ${black}/${white} < 0.005" | bc`
  if [ ${blank} -eq "1" ]; then
    echo "${i} seems to be blank - removing it..."
    rm "${i}"
  fi
done
link|improve this question
feedback

1 Answer

up vote 0 down vote accepted

You can use ImageMagick compare tool to compare the scanned images against a "master" blank page. Since my ImageMagick-fu is quite limited I cannot give you any example command. You will have to RTFM:

The second link even has a section titled "Blank Fax" which explains how to detect blank fax pages. Sadly that section seems unfinished. Hopefully the available information is enough for you to get started.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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