The Python Imaging Library | ![]() |
|
Copyright © 1997 by Fredrik Lundh <fredrik@pythonware.com> | ||
Updated 17 Aug 1997 |
< The Image Class | The ImageChops Module | The ImageDraw Class >
This module contains a number of arithmetical image operations, called channel operations (chops). These can be used for various purposes, including special effects, image compositions, algorithmic painting, and more.
All functions take one or two image arguments and returns a new image. Unless otherwise noted, the result of a channel operation is always clipped to the range 0 to MAX (which is 255 for all modes supported by the current version of the Python Imaging Library).
invert( image ) inverts an image.
out = MAX - image
lighter( image1, image2 ) compares the two images, pixels by pixel, and returns a new image containing the lighter value for each pixel.
out = max( image1, image2 )
darker( image1, image2 ) compares the two images, pixels by pixel, and returns a new image containing the darker value for each pixel.
out = min( image1, image2 )
difference( image1, image2 ) returns the absolute value of the difference between the two images.
out = abs( image1 - image2 )
multiply( image1, image2 ) superimposes two images on top of each other. If you multiply an image with a solid black image, the result is black. If you multiply with a solid white image, the image is unaffected.
out = image1 * image2 / MAX
screen( image1, image2 ) superimposes two inverted images on top of each other.
out = MAX - ((MAX - image1) * (MAX - image2) / MAX)
add( image1, image2, scale, offset ) adds two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0.
out = ( image1 + image2 ) / scale + offset
subtract( image1, image2, scale, offset ) subtracts two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0.
out = ( image1 - image2 ) / scale + offset
< The Image Class | The ImageChops Module | The ImageDraw Class >