Most image processing operations in the VIPS library can operate on
images of any type (IM_BANDFMT_UCHAR
, as in our examples above,
also IM_BANDFMT_UINT
etc.). This is usually implemented with code
replication: the operation contains loops for processing every kind of image,
and when called, invokes the appropriate loop for the image it is given.
As an example, figure 2.3 calculates exp()
for every pel
in an image. If the input image is double
, we write double
output. If it is any other non-complex type, we write float
. If it
is complex, we flag an error (exp()
of a complex number is fiddly).
The example uses an image type predicate, im_iscomplex()
. There are
a number of these predicate functions, see the manual page.