Enhance images for OCR

I use this code to enhance photographs or other image files taken from black and white text. Does great job for optical character recognition, printing and other purposes. This script is using ImageMagick to do the actual job.

#!/bin/bash
 
mkdir "bw"
 
for x in *.jpg ; do 
	b=`basename $x .jpg`
	echo $x
	convert -noise 1 -unsharp 10x5+10 -threshold 20% "$x" "bw/$b.pbm";
	unpaper "bw/$b.pbm" "bw/unpaper_$b.pbm"
	convert "bw/unpaper_$b.pbm" "bw/$b.png";
	rm -f "bw/$b.pbm" "bw/unpaper_$b.pbm"
done

Linkbacks

Use the following URL for manually sending trackbacks: http://rigo.info/lib/plugins/linkback/exe/trackback.php/en:blog:enhance_images_for_ocr
en/blog/enhance_images_for_ocr.txt · Utolsó módosítás: 2009-04-14 00:00 (külső szerkesztés)
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0