Next: 2.2 Relational Up: 2. VIPS packages Previous: 2. VIPS packages Contents

# 2.1 Arithmetic

See figure 2.1.

Arithmetic functions work on images as if each band element were a separate number. All operations are point-to-point -- each output element depends exactly upon the corresponding input element. All (except in a few cases noted in the manual pages) will work with images of any type (or any mixture of types), of any size and of any number of bands.

Arithmetic operations try to preserve precision by increasing the number of bits in the output image when necessary. Generally, this follows the ANSI C conventions for type promotion -- so multiplying two `IM_BANDFMT_UCHAR` images together, for example, produces a `IM_BANDFMT_USHORT` image, and taking the `im_costra()` of a `IM_BANDFMT_USHORT` image produces a `IM_BANDFMT_FLOAT` image. The details of the type conversions are in the manual pages.

Figure 2.1: Arithmetic functions