Color Transformation#
Using a color transformation matrix, the feature can correct color shifts caused by the light source used during image acquisition as well as compensate for imperfections in the sensor's color generation process.
Info
You should only use this feature if you are thoroughly familiar with matrix color transformations. It is nearly impossible to enter correct values in the transformation matrix by trial and error.
Using the Feature#
Configuring Color Transformation#
- Make sure the white balance is configured appropriately.
- Set the
ProcessedRawEnable
parameter totrue
(if available and if you're using a Bayer pixel format). - Set the
LightSourcePreset
parameter toCustom
(if available). - Set the
ColorTransformationValueSelector
parameter to the desired position in the matrix, e.g.,Gain00
. - Enter the desired value for the
ColorTransformationValue
parameter to adjust the value at the selected position. The parameter's value range is -8.0 to +7.96875.
Info
The transformation matrix is already populated with color transformation values. They are related to previously selected light source presets, correspond to unit vectors, or result from a previous use of the color transformation feature.
ColorTransformationMatrixFactor Parameter
This parameter, which is only available on ace Classic/U/L cameras with GigE interface, determines the extent to which the color matrix influences the color values. If set to 0, the matrix is effectively disabled. Basler recommends leaving it at the default setting (1).
How It Works#
The color transformation feature uses a transformation matrix to deliver modified red, green, and blue pixel data for each pixel.
The transformation is performed by premultiplying a 3 x 1 matrix containing R, G, and B pixel values by a 3 x 3 matrix containing the color transformation values:
You can set each matrix value (Gain00, Gain01, etc.) according to your requirements.
External Links#
Sample Code#
// Select position Gain00 in the matrix
camera.ColorTransformationValueSelector.SetValue(ColorTransformationValueSelector_Gain00);
// Enter a floating point value for the selected position
camera.ColorTransformationValue.SetValue(1.5625);
// Select position Gain01 in the matrix
camera.ColorTransformationValueSelector.SetValue(ColorTransformationValueSelector_Gain01);
// Enter a floating point value for the selected position
camera.ColorTransformationValue.SetValue(-0.4375);
INodeMap& nodemap = camera.GetNodeMap();
// Select position Gain00 in the matrix
CEnumParameter(nodemap, "ColorTransformationValueSelector").SetValue("Gain00");
// Enter a floating point value for the selected position
CFloatParameter(nodemap, "ColorTransformationValue").SetValue(1.5625);
// Select position Gain01 in the matrix
CEnumParameter(nodemap, "ColorTransformationValueSelector").SetValue("Gain01");
// Enter a floating point value for the selected position
CFloatParameter(nodemap, "ColorTransformationValue").SetValue(-0.4375);
// Select position Gain00 in the matrix
camera.Parameters[PLCamera.ColorTransformationValueSelector].SetValue(PLCamera.ColorTransformationValueSelector.Gain00);
// Enter a floating point value for the selected position
camera.Parameters[PLCamera.ColorTransformationValue].SetValue(1.5625);
// Select position Gain01 in the matrix
camera.Parameters[PLCamera.ColorTransformationValueSelector].SetValue(PLCamera.ColorTransformationValueSelector.Gain01);
// Enter a floating point value for the selected position
camera.Parameters[PLCamera.ColorTransformationValue].SetValue(-0.4375);
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK; /* Return value of pylon methods */
/* Select position Gain00 in the matrix */
errRes = PylonDeviceFeatureFromString(hdev, "ColorTransformationValueSelector", "Gain00");
CHECK(errRes);
/* Enter a floating point value for the selected position */
errRes = PylonDeviceSetFloatFeature(hdev, "ColorTransformationValue", 1.5625);
CHECK(errRes);
/* Select position Gain01 in the matrix */
errRes = PylonDeviceFeatureFromString(hdev, "ColorTransformationValueSelector", "Gain01");
CHECK(errRes);
/* Enter a floating point value for the selected position */
errRes = PylonDeviceSetFloatFeature(hdev, "ColorTransformationValue", -0.4375);
CHECK(errRes);
# Select position Gain00 in the matrix
camera.ColorTransformationValueSelector.Value = "Gain00"
# Enter a floating point value for the selected position
camera.ColorTransformationValue.Value = 1.5625
# Select position Gain01 in the matrix
camera.ColorTransformationValueSelector.Value = "Gain01"
# Enter a floating point value for the selected position
camera.ColorTransformationValue.Value = -0.4375
You can also use the pylon Viewer to easily set the parameters.