跳转到内容

Color Transformation#

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

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

信息

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

该功能的使用#

配置 Color Transformation#

  1. 确保正确配置白平衡
  2. ProcessedRawEnable 参数设置为 true如果可用且如果您采用的是 Bayer 像素格式)。
  3. LightSourcePreset 参数设置为 true如果可用)。
  4. ColorTransformationValueSelector 参数设置为矩阵中所需的位置,例如 Gain00
  5. ColorTransformationValue 参数输入所需值,以在选定位置调整该值。该参数的值范围是 -8.0 到 +7.96875。

信息

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

运作原理#

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

通过将包含 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
CEnumerationPtr(nodemap.GetNode("ColorTransformationValueSelector"))->FromString("Gain00");
// Enter a floating point value for the selected position
CFloatPtr(nodemap.GetNode("ColorTransformationValue"))->SetValue(1.5625);
// Select position Gain01 in the matrix
CEnumerationPtr(nodemap.GetNode("ColorTransformationValueSelector"))->FromString("Gain01");
// Enter a floating point value for the selected position
CFloatPtr(nodemap.GetNode("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);
// Select position Gain00 in the matrix
Pylon.DeviceFeatureFromString(hdev, "ColorTransformationValueSelector", "Gain00");
// Enter a floating point value for the selected position
Pylon.DeviceSetFloatFeature(hdev, "ColorTransformationValue", 1.5625);
// Select position Gain01 in the matrix
Pylon.DeviceFeatureFromString(hdev, "ColorTransformationValueSelector", "Gain01");
// Enter a floating point value for the selected position
Pylon.DeviceSetFloatFeature(hdev, "ColorTransformationValue", -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);

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