[Image-SIG] Filtering out all but black pixels for OCR
douglas at paradise.net.nz
Fri Jul 4 08:22:15 CEST 2008
Karsten Hiddemann schrieb:
> Fredrik has written something about the performance on pixel access with
> some timings here: http://effbot.org/zone/pil-pixel-access.htm
As that page also mentions, PIL images have the point method for doing
this kind of thing.
It is much faster and simpler than doing it in python, and slightly
more idiomatic than Image.eval (which runs the same code internally).
img = Image.open("onechannel.png")
better = img.point( +  * 255)
You could also use point to perform apply the kind of sigmoid function
that Scott suggested as part of a more OCR solution.
More information about the Image-SIG