[Image-SIG] Filtering out all but black pixels for OCR
Douglas Bagnall
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.
see http://effbot.org/imagingbook/image.htm#tag-Image.Image.point
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([0] + [255] * 255)
better.save("bilevel.png")
You could also use point to perform apply the kind of sigmoid function
that Scott suggested as part of a more OCR solution.
Douglas
More information about the Image-SIG
mailing list