In the current version, ImageMath only supports
single-layer images. To process multi-band images, use the
split() method or merge()
function.

Parameters:

expression – A string which uses the standard Python expression
syntax. In addition to the standard operators, you can
also use the functions described below.

environment – A dictionary that maps image names to Image instances.
You can use one or more keyword arguments instead of a
dictionary, as shown in the above example. Note that
the names must be valid Python identifiers.

Returns:

An image, an integer value, a floating point value,
or a pixel tuple, depending on the expression.

You can use standard arithmetical operators for addition (+), subtraction (-),
multiplication (*), and division (/).

The module also supports unary minus (-), modulo (%), and power (**) operators.

Note that all operations are done with 32-bit integers or 32-bit floating
point values, as necessary. For example, if you add two 8-bit images, the
result will be a 32-bit integer image. If you add a floating point constant to
an 8-bit image, the result will be a 32-bit floating point image.

You can force conversion using the convert(),
float(), and int() functions
described below.

The module also provides operations that operate on individual bits. This
includes and (&), or (|), and exclusive or (^). You can also invert (~) all
pixel bits.

Note that the operands are converted to 32-bit signed integers before the
bitwise operation is applied. This means that you’ll get negative values if
you invert an ordinary greyscale image. You can use the and (&) operator to
mask off unwanted bits.