$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:
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