====== Tools: unpaper ====== Recently I wanted to print a few scanned pages. However, due to the low quality of the source material (see below) reducing the pages to black&white didn't exactly improve them. Enter [[http://unpaper.berlios.de/|unpaper]]. While unpaper is a rather unknown tool it's also extremely useful because it allows diverse image modifications to improve scanned pages, e.g.: * black-/gray-/noise-/blurfiltering * deskewing * border-aligning * mask-centering * etc. If you aren't sold yet the [[http://unpaper.berlios.de/unpaper.html|documentation]] offers other great examples of applied image processing techniques. {{ :blog:2008:06:unprint.png |}} Below I've included the minimal((''meaning: quick&dirty'')) script I used to process the scanned pages. While the settings produced sufficient results for my needs they are probably still far from perfect -- so don't forget to toy with your settings to get optimal results ,) #!/bin/bash # Usage: autounpaper *.jpg inputfiles=$* tmpin=`mktemp -t autounpaper-in-XXXXXXXXXX`.pgm tmpout=`mktemp -t autounpaper-out-XXXXXXXXXX`.pgm opts="-q --overwrite" opts+=" --no-deskew --no-mask-scan" opts+=" --grayfilter-size 1,1 --grayfilter-step 1,1 --grayfilter-threshold 0.4" echo -n "Processing:" for input in $inputfiles; do echo -n " $input" ending=${input#*.} output=${input%.*}-unpaper.$ending convert $input $tmpin && echo -n . && \ unpaper $opts $tmpin $tmpout && echo -n . && \ convert $tmpout $output done rm $tmpin $tmpout echo {{tag>sh quick_and_dirty tools}} ~~DISCUSSION~~