linear_trans_color — Compute an affine transformation of the color values of a
linear_trans_color performs an affine transformation of the
color values of the multichannel image
Image and returns
the result in
ImageTrans. The affine transformation of the
color values is described by the transformation matrix
TransMat. If n is the number of channels in
Image and m is the number of channels in
TransMat is a homogeneous m × (n+1) matrix that is stored row by row. Homogeneous
means that the left m × n submatrix of
TransMat describes a linear transformation of the color
values, while the last column of
TransMat describes a
constant offset of the color values. The transformation matrix is
typically computed with
particular, it is possible to project an image onto the first m
principal components by selecting the first m ×
(n+1) values of the transformation returned by
gen_principal_comp_trans. The transformation can, however,
also be specified directly. For example, a transformation from RGB
to YIQ, which is described by the following transformation
can be achieved by setting
Here, it should be noted that the above transformation is
unnormalized, i.e., the resulting color values can lie outside the
range [0,255]. The transformation 'yiq' in
trans_from_rgb additionally scales the rows of the matrix
(except for the constant offset) appropriately.
To avoid a loss of information,
an image of type real. If a different image type is desired, the
image can be transformed with
linear_trans_color can be executed on OpenCL devices if the image
Image consists of nine channels or less and is transformed to
an image of three channels or less. Since the calculations are done in
single precision floating point, the results may differ from those
calculated by the CPU.
→object (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real)
Multichannel input image.
Multichannel output image.
Transformation matrix for the color values.
linear_trans_color returns the value 2 (H_MSG_TRUE) if
the parameters are correct. Otherwise an exception is raised.