[PYTHON IMAGE-SIG] Image docs
Mon, 6 May 1996 14:28:09 +0200
> > # PIL 0.1 allows you to write:
> > # im = im.point(lambda a: 255 - (255 * a / 64))
> IMHO this kind of stuff would be nice to have as a PIL function,
> done in C for speed. For those not in hurry there could be a
> Python function for doing the same with floats ;-).
It is done in C; the wrapper just calculates the expression for each
possible pixel value (0..255) and uses a lookup table to process the
> Does PIL have some kind of 'combine' function? For doing something
> like this:
> result = (img_1 * 2 / 3) + (img_2 * 1 / 3)
Yep (it's already there in release 0.0, in fact).
result = Image.blend(img_1, img_2, 1.0/3)
An important detail is that the alpha may extend outside the range 0.0
to 1.0, allowing you to for example implement unsharp masking using
this mechanism (as done by the ImageEnhance module).
> /.../ might have some use in combining completely different images
> too, if PIL would have some functions for doing different color
> (intensity) 'slide' images that can be used in combining to control
> how the two images are combined.
If you browsed the sample code, you have already seen the
(undocumented) _wedge operation. You can implement any linear variant
by combining that with point and rotate methods. Radial fills are a
different thing, but is sure useful. I'll put in on my list (but not
for release 0.1 :-)
BTW, PIL 0.1 adds a composite convenience function, which is
implemented as a copy/paste(mask) operation:
result = Image.composite(img_1, img_2, mask)
> For combining some defined image parts one needs to do masks by hand. :-(
> (on some rare cases threshold might suffice though)
There's a rudimentary file interface to Boutell's GD library in PIL
0.1, allowing you to for example draw a mask using that library, save
it as a GD file, and load it into PIL. (Future versions of PIL will
include same basic 2D drawing support as well).
IMAGE-SIG - SIG on Image Processing with Python
send messages to: email@example.com
administrivia to: firstname.lastname@example.org