跳转到内容

Color Transformation#

相机的 Color Transformation 功能使您可以校正传感器提供的色彩信息。

使用色彩转换矩阵,该功能可以校正由图像采集期间使用的光源引起的色彩偏移,并补偿传感器呈色过程中产生的瑕疵。

信息

您仅应在完全熟悉矩阵色彩转换时才能使用此功能。要在转换矩阵中输入正确的值,通过试错法几乎是不可能实现的。

该功能的使用#

配置 Color Transformation#

  1. 确保正确配置白平衡
  2. 设置 ProcessedRawEnable parameter to true (如果可用 and if you're using a Bayer pixel format).
  3. 设置 LightSourcePreset parameter to Custom (如果可用).
  4. 设置 ColorTransformationValueSelector parameter to the desired position in the matrix, e.g., Gain00.
  5. 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.

信息

转换矩阵已经填充了色彩转换值。它们与先前选择的光源预设相关、与单位向量相对应或根据先前使用色彩转换功能的情况得出。

ColorTransformationMatrixFactor 参数

此参数仅在带有 GigE 接口的 ace Classic/U/L 相机上可用,确定颜色矩阵对颜色值的影响程度。如果设置为 0,矩阵实际上会被禁用。Basler 建议将其保留为默认设置 (1)。

运作原理#

色彩转换功能使用转换矩阵为每个像素传递修改后的红色、绿色和蓝色像素数据。

通过将包含 R、G 和 B 像素值的 3 x 1 矩阵与包含色彩转换值的 3 x 3 矩阵预先相乘,以执行转换:

Color Transformation 矩阵

您可以根据需要设置每个矩阵值(Gain00、Gain01 等)。

示例代码#

// 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

您也可以使用 pylon Viewer 轻松设置参数。