跳转到内容

Balance White (dart E)#

相机的 Balance White 功能可让您手动校正色彩偏移,以使白色物体在采集到的图像中显示为白色。

为此,可以对每个色彩通道(红、绿、蓝色)应用数字增益校正。

该功能的使用#

为什么要执行白平衡校正#

相机采集到的图像可能出现偏色,即特定颜色的色调。其原因是不同的光源具有不同的色温。荧光灯会给图像增加偏蓝的色调,而钨丝白炽灯则会增加偏黄的色调。

白平衡功能使您可以通过调整红、绿、蓝色的强度来校正这些色彩偏移。使得白色物体在采集到的图像中呈现白色。

执行白平衡校正#

执行白平衡校正:

  1. Set the BalanceRatioSelector parameter to one of the available color channels (Red, Green, or Blue).
  2. Adjust the BalanceRatio parameter value for the selected color channel:

    • 平衡率 = 1:颜色强度保持不变
    • 平衡率 > 1:相对于其他两种颜色,颜色强度增大
    • Balance ratio < 1: The intensity of the color is decreased relative to the other two colors. (This is only possible if your camera model supports balance ratio values lower than 1.)
    • 对所有可用的颜色通道重复步骤 3 和 4。

强度成比例增大或降低。例如,如果将一种颜色的平衡率设置为 1.2,则该颜色的强度将增加 20%。

信息

  • 如果指定的平衡率小于 1,也会降低色彩可以达到的最大强度。除非要校正一种明显占优势的颜色,否则建议不要将平衡率指定为小于 1 的值。

示例代码#

// Set the red intensity to 108.789%
camera.BalanceRatioSelector.SetValue(BalanceRatioSelector_Red);
camera.BalanceRatio.SetValue(1.08789);
// Set the green intensity to 100%
camera.BalanceRatioSelector.SetValue(BalanceRatioSelector_Green);
camera.BalanceRatio.SetValue(1);
// Set the blue intensity to 219.678%
camera.BalanceRatioSelector.SetValue(BalanceRatioSelector_Blue);
camera.BalanceRatio.SetValue(2.19678);
INodeMap& nodemap = camera.GetNodeMap();
// Set the red intensity to 108.789%
CEnumParameter(nodemap, "BalanceRatioSelector").SetValue("Red");
CFloatParameter(nodemap, "BalanceRatio").SetValue(1.08789);
// Set the green intensity to 100%
CEnumParameter(nodemap, "BalanceRatioSelector").SetValue("Green");
CIntegerParameter(nodemap, "BalanceRatio").SetValue(1);
// Set the blue intensity to 219.678%
CEnumParameter(nodemap, "BalanceRatioSelector").SetValue("Blue");
CFloatParameter(nodemap, "BalanceRatio").SetValue(2.19678);
// Set the red intensity to 108.789%
camera.Parameters[PLCamera.BalanceRatioSelector].SetValue(PLCamera.BalanceRatioSelector.Red);
camera.Parameters[PLCamera.BalanceRatio].SetValue(1.08789);
// Set the green intensity to 100%
camera.Parameters[PLCamera.BalanceRatioSelector].SetValue(PLCamera.BalanceRatioSelector.Green);
camera.Parameters[PLCamera.BalanceRatio].SetValue(1);
// Set the blue intensity to 219.678%
camera.Parameters[PLCamera.BalanceRatioSelector].SetValue(PLCamera.BalanceRatioSelector.Blue);
camera.Parameters[PLCamera.BalanceRatio].SetValue(2.19678);
/* 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 */
/* Set the red intensity to 108.789% */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceRatioSelector", "Red");
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "BalanceRatio", 1.08789);
CHECK(errRes);
/* Set the green intensity to 100% */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceRatioSelector", "Green");
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "BalanceRatio", 1);
CHECK(errRes);
/* Set the blue intensity to 219.678% */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceRatioSelector", "Blue");
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "BalanceRatio", 2.19678);
CHECK(errRes);
# Set the red intensity to 108.789%
camera.BalanceRatioSelector.Value = "Red"
camera.BalanceRatio.Value = 1.08789
# Set the green intensity to 100%
camera.BalanceRatioSelector.Value = "Green"
camera.BalanceRatio.Value = 1
# Set the blue intensity to 219.678%
camera.BalanceRatioSelector.Value = "Blue"
camera.BalanceRatio.Value = 2.19678
/* 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 */
/* Set the red intensity to 108.789% */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceRatioSelector", "Red");
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "BalanceRatio", 1.08789);
CHECK(errRes);
/* Set the green intensity to 100% */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceRatioSelector", "Green");
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "BalanceRatio", 1);
CHECK(errRes);
/* Set the blue intensity to 219.678% */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceRatioSelector", "Blue");
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "BalanceRatio", 2.19678);
CHECK(errRes);

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