From aeb663e7da50cdad5b60dcb5d7a1f78fc83f36b4 Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Mon, 1 Aug 2011 18:39:06 +0800 Subject: [PATCH] ocropus as soon as possible --- scan2pages.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scan2pages.sh b/scan2pages.sh index b2bad10..42b3bfb 100755 --- a/scan2pages.sh +++ b/scan2pages.sh @@ -125,7 +125,19 @@ for scanpgnum in `$my_seq 1 $pages`; do $scanpg || exit 1 fi; - # preprocess it! +done; + +# do ocr binarise +[ -e $outdir/scanpgs ] && rm -r $outdir/scanpgs +ocropus book2pages $outdir/scanpgs $outdir/scanpg-*.png || exit 1 + +for scanpgnum in `$my_seq 1 $pages`; do + + scanpgnum=$(printf '%03d' $scanpgnum) + scanpg=$outdir/scanpg-${scanpgnum}.png + binscanpg=$outdir/scanpgs/$(printf '%04d' $scanpgnum).bin.png + + # preprocess scanned page cleanscanpg=$outdir/scanpg-clean-${scanpgnum}.pnm if [ ! -e $cleanscanpg ]; then # create mask: @@ -137,9 +149,7 @@ for scanpgnum in `$my_seq 1 $pages`; do cropcords=$(convert -border 1x1 -bordercolor '#000' -resize 1000% -trim -fuzz 90% -format "%wx%h%O" $outdir/scanpg-mask-${scanpgnum}.png info: || exit 1) # ... crop and despeckle? the final pre-prepared image - convert $convertflags -crop $cropcords $scanpg $cleanscanpg || exit 1 - elif [[ $skipmask ]]; then - cp $origfile $preppnm + convert $convertflags -crop $cropcords $binscanpg $cleanscanpg || exit 1 fi; # check it hasn't mostly disappeared - e.g. if the scan was all black -- 2.20.1