Balance White#
為此,可針對每個色彩通道(紅、綠、藍)分別進行數位增益校正。
若要自動校正色彩偏移,請使用「Balance White 」的「自動」功能。
使用功能#
為何要進行白平衡校正#
相機拍攝的影像可能會出現色偏,也就是帶有某種特定顏色的色調。這是因為不同的光源具有不同的色溫。螢光燈會使影像帶有藍色色偏,而鎢絲白熾燈則會使影像帶有黃色色偏。
白平衡功能可讓您透過調整紅色、綠色和藍色的飽和度,來校正這些色偏。因此,在拍攝的影像中,白色物體會呈現白色。
執行白平衡校正#
要執行白平衡校正:
- 將相機中的 Balance White auto function 設為
Off. - 為獲得最佳效果,請將黑電平設定為 0(零)。
- 將相機中的
BalanceRatioSelector將參數設定為其中一個可用的色彩通道(Red,Green,或Blue)。 -
調整
BalanceRatio所選色彩通道的參數值:- 平衡比 = 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。
- 某些色彩增強功能,例如: Light Source Preset 或 Color Transformation,也會影響白平衡設定。如有需要,您可以在使用這些功能後手動重新調整白平衡。
外部連結#
範例程式碼#
ace Classic/U/L GigE 相機#
// Set the red intensity to 108.789%
camera.BalanceRatioSelector.SetValue(BalanceRatioSelector_Red);
camera.BalanceRatioAbs.SetValue(1.08789);
// Set the green intensity to 100%
camera.BalanceRatioSelector.SetValue(BalanceRatioSelector_Green);
camera.BalanceRatioAbs.SetValue(1.0);
// Set the blue intensity to 219.678%
camera.BalanceRatioSelector.SetValue(BalanceRatioSelector_Blue);
camera.BalanceRatioAbs.SetValue(2.19678);
INodeMap& nodemap = camera.GetNodeMap();
// Set the red intensity to 108.789%
CEnumParameter(nodemap, "BalanceRatioSelector").SetValue("Red");
CFloatParameter(nodemap, "BalanceRatioAbs").SetValue(1.08789);
// Set the green intensity to 100%
CEnumParameter(nodemap, "BalanceRatioSelector").SetValue("Green");
CFloatParameter(nodemap, "BalanceRatioAbs").SetValue(1.0);
// Set the blue intensity to 219.678%
CEnumParameter(nodemap, "BalanceRatioSelector").SetValue("Blue");
CFloatParameter(nodemap, "BalanceRatioAbs").SetValue(2.19678);
// Set the red intensity to 108.789%
camera.Parameters[PLCamera.BalanceRatioSelector].SetValue(PLCamera.BalanceRatioSelector.Red);
camera.Parameters[PLCamera.BalanceRatioAbs].SetValue(1.08789);
// Set the green intensity to 100%
camera.Parameters[PLCamera.BalanceRatioSelector].SetValue(PLCamera.BalanceRatioSelector.Green);
camera.Parameters[PLCamera.BalanceRatioAbs].SetValue(1.0);
// Set the blue intensity to 219.678%
camera.Parameters[PLCamera.BalanceRatioSelector].SetValue(PLCamera.BalanceRatioSelector.Blue);
camera.Parameters[PLCamera.BalanceRatioAbs].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, "BalanceRatioAbs", 1.08789);
CHECK(errRes);
/* Set the green intensity to 100% */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceRatioSelector", "Green");
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "BalanceRatioAbs", 1.0);
CHECK(errRes);
/* Set the blue intensity to 219.678% */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceRatioSelector", "Blue");
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "BalanceRatioAbs", 2.19678);
CHECK(errRes);
# Set the red intensity to 108.789%
camera.BalanceRatioSelector.Value = "Red"
camera.BalanceRatioAbs.Value = 1.08789
# Set the green intensity to 100%
camera.BalanceRatioSelector.Value = "Green"
camera.BalanceRatioAbs.Value = 1.0
# Set the blue intensity to 219.678%
camera.BalanceRatioSelector.Value = "Blue"
camera.BalanceRatioAbs.Value = 2.19678
其他相機#
// 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.0);
// 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");
CFloatParameter(nodemap, "BalanceRatio").SetValue(1.0);
// 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.0);
// 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 = PylonDeviceSetFloatFeature(hdev, "BalanceRatio", 1.0);
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.0
# Set the blue intensity to 219.678%
camera.BalanceRatioSelector.Value = "Blue"
camera.BalanceRatio.Value = 2.19678
您也可以 use the pylon Viewer 來輕鬆設定參數。