See figure 2.8.
VIPS uses matricies for morphological operations, for convolutions, and
for some colour-space conversions. There are two types of matrix: integer
(INTMASK
) and double precision floating point (DOUBLEMASK
).
For convenience, both types are stored in files as ASCII. The first line of the file should start with the matrix dimensions, width first, then on the same line an optional scale and offset. The two size fields should be integers; the scale and offset may be floats. Subsequent lines should contain the matrix elements, one row per line. The scale and offset are the conventional ones used to represent non-integer values in convolution masks -- in other words:
If the scale and offset are missing, they default to 1.0 and 0.0. See the sections on convolution for more on the use of these fields. So as an example, a 4 by 4 identity matrix would be stored as:
4 4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
And a 3 by 3 mask for block averaging with convolution might be stored as:
3 3 9 0 1 1 1 1 1 1 1 1 1
(in other words, sum all the pels in every 3 by 3 area, and divide by 9).
This matrix contains only integer elements and so could be used as an
argument to functions expecting both INTMASK
and DOUBLEMASK
matricies. However, masks containing floating-point values (such as the
output of im_matinv()
) can only be used as arguments to functions
expecting DOUBLEMASK
s.
A set of functions for mask input and output are also available for
C-programmers -- see the manual pages for im_read_dmask()
. For
other matrix functions, see also the convolution sections and the arithmetic
sections.