The Color Transformation camera feature allows you to correct the color information delivered by the sensor.
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.
Make sure the white balance is configured appropriately.
Set the ProcessedRawEnable parameter to true (if available and if you're using a Bayer pixel format).
Set the LightSourceSelector parameter to Custom (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).
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.
// Select position Gain00 in the matrixcamera.ColorTransformationValueSelector.SetValue(ColorTransformationValueSelector_Gain00);// Enter a floating point value for the selected positioncamera.ColorTransformationValue.SetValue(1.5625);// Select position Gain01 in the matrixcamera.ColorTransformationValueSelector.SetValue(ColorTransformationValueSelector_Gain01);// Enter a floating point value for the selected positioncamera.ColorTransformationValue.SetValue(-0.4375);
INodeMap&nodemap=camera.GetNodeMap();// Select position Gain00 in the matrixCEnumParameter(nodemap,"ColorTransformationValueSelector").SetValue("Gain00");// Enter a floating point value for the selected positionCFloatParameter(nodemap,"ColorTransformationValue").SetValue(1.5625);// Select position Gain01 in the matrixCEnumParameter(nodemap,"ColorTransformationValueSelector").SetValue("Gain01");// Enter a floating point value for the selected positionCFloatParameter(nodemap,"ColorTransformationValue").SetValue(-0.4375);
// Select position Gain00 in the matrixcamera.Parameters[PLCamera.ColorTransformationValueSelector].SetValue(PLCamera.ColorTransformationValueSelector.Gain00);// Enter a floating point value for the selected positioncamera.Parameters[PLCamera.ColorTransformationValue].SetValue(1.5625);// Select position Gain01 in the matrixcamera.Parameters[PLCamera.ColorTransformationValueSelector].SetValue(PLCamera.ColorTransformationValueSelector.Gain01);// Enter a floating point value for the selected positioncamera.Parameters[PLCamera.ColorTransformationValue].SetValue(-0.4375);
/* Macro to check for errors */#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)GENAPIC_RESULTerrRes=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 matrixcamera.ColorTransformationValueSelector.Value="Gain00"# Enter a floating point value for the selected positioncamera.ColorTransformationValue.Value=1.5625# Select position Gain01 in the matrixcamera.ColorTransformationValueSelector.Value="Gain01"# Enter a floating point value for the selected positioncamera.ColorTransformationValue.Value=-0.4375