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
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to