This module implements a simple rational function ('ratfunc') transform for 3-channel data.

The transform is explained in the document 'rational_function_color_transform.txt'.

The primary application is converting RGB camera/scanner data to XYZ.

We often use a 3x4 matrix to do this,

| a11, a12, a13, a14 |
| a21, a22, a23, a24 |
| a31, a32, a33, a34 |

To use this matrix, we add a column containing '1' to the input data,

[R, G, B] => [R, G, B, 1]

Then we use matrix multiplication to compute the XYZ values from these augmented RGB values.

[X, Y, Z] = [3x4 matrix] x [R, G, B, 1]

If the camera or scanner has RGB spectral sensitivities derived from color matching functions (Luther-Ives condition), the accuracy of this simple transform will be excellent. However, the spectral sensitivity curves are not always optimal.

We may be able to achieve slightly better results using rational functions. A rational function is the ratio of two polynomial functions. We use extremely simple, linear functions of RGB. We extend the 3x4 matrix by adding three rows to get a 6x4 matrix,

| a11, a12, a13, a14 |
| a21, a22, a23, a24 |
| a31, a32, a33, a34 |
| a41, a42, a43,  1  |
| a51, a52, a53,  1  |
| a61, a62, a63,  1  |

Now, when we multiply by the augmented RGB matrix, we get,

[Xn, Yn, Zn, Xd, Yd, Zd] = [6x4 matrix] x [R, G, B, 1]

Then we reduce these values to ratios,

[X, Y, Z] = [Xn/Xd, Yn/Yd, Zn/Zd]

If the added coefficients, a41, a42, ... a63, are all zero, the denominators will all be 1, and the transform is the same as the 3x3 matrix with offsets. If these coefficients are non-zero, the X, Y, Z functions will be non-linear, which may improve the accuracy of the transform.

The advantage of this transform is that it provides some additional degrees of freedom compared to the 3x3 matrix. This allows us to 'fix' some points to improve the reproduction of a particular original. The transform may have some curvature, but it is smooth and gradual, so congruence is maintained. This transform cannot improve the color quality of the sensor, but it can be used to fine tune images.

The object's matrix is compatible with the XS function 'ICC::Support::Image::ratfunc_transform_float'. The intention is to optimize the matrix using the 'ratfunc.pm' object, then transform images using the XS function.

The size of the object's matrix is always 6x4. If we attempt to make a larger matrix, an error occurs. If we supply a smaller matrix, the missing coefficients are those of the identity matrix. The identity matrix looks like this,

| 1, 0, 0, 0 |
| 0, 1, 0, 0 |
| 0, 0, 1, 0 |
| 0, 0, 0, 1 |
| 0, 0, 0, 1 |
| 0, 0, 0, 1 |

For example, a 3x3 matrix will be copied to the first three rows and columns of the above identity matrix. In that case, the 'ratfunc' transform will be the same as the 'matf' transform (straight matrix multiplication).

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 368:

=cut found outside a pod block. Skipping to next block.

Around line 505:

=cut found outside a pod block. Skipping to next block.