跳转到内容

Brightness and Contrast#

相机的 Brightness and Contrast 功能可让您调整图像的色调值。

亮度和对比度始终作为通用亮度/对比度数学函数的一部分一起处理。

该功能的使用#

调整对比度和对比模式#

调整对比度:

  1. 设置 BslContrastMode 参数为以下值(如果可用):
  2. 输入 BslContrast 参数的值。该参数值的范围是 -1 至 1。默认情况下,参数设置为 0,这意味着对比度保持不变。

调整亮度#

要调整亮度,请输入 BslBrightness 参数的值。该参数值的范围是 -1 至 1。默认情况下,该参数设置为 0,表示亮度保持不变。

运作原理#

对比度和对比模式#

调整对比度会更改图像中明暗区域之间的差异程度。应用的对比度越高,差异就越明显。

如何应用对比度取决于您选择的对比模式。

线性对比模式

If this contrast mode is selected, the camera uses a linear function to adjust the contrast. Increasing or decreasing the contrast, increases or decreases the gradient of the linear function.

对比度 = 0,亮度 = 0,线性对比模式

对比度 = 0.3,亮度 = 0,线性对比模式

如果对比度设置大于 0,则更多的输出像素值将被设置为全黑 (0) 或全白(最大像素值)。

如果将对比度设置为 0.3(请参见第二张图),则将 0 到大约 50 的输入值设置为全黑,而将大约 205 到 255 的输入值设置为全白。这意味着色调值的总范围(即图像的动态范围)缩小了。图像的最暗和最亮区域将显示为全黑色或全白色,而其他区域则显示得更加清晰。

降低对比度会产生相反的效果。

S 曲线对比模式

如果选择此对比模式,相机将使用 S 曲线函数来调整对比度。

这使您可以改进感知对比度,同时保留图像的动态范围。

对比度增加得越多,该函数的图形将越趋向于 S 形:

对比度 = 0.3,亮度 = 0,S 曲线对比模式

对比度 = 0.5,亮度 = 0,S 曲线对比模式

上图显示,在 S 曲线模式下提高对比度具有以下效果:

  • S 曲线的起点和终点变平、中心变陡。结果,图像明暗区域的对比度降低,并且中间色调的对比度提高。
  • 低输入像素值降低,高输入像素值提高。这压缩了图像的极暗和极亮区域,从而进一步提高了可感知的对比度。
  • 由于曲线始终从 (0,0) 开始,到 (Xmax,Ymax) 结束,因此图像的动态范围得以保留。

在 S 曲线模式下,低于 0 的对比度设置将导致 S 曲线反转,产生相反的效果。

亮度#

调节亮度可以通过增加或减小图像的色调值来使图像变亮或变暗。

调整亮度时会移动亮度/对比度函数的轴心点:

  • 增加亮度会使轴心点向左上方移动。这意味着图像将显得更亮。
  • 降低亮度会将轴心点移到右下角。这意味着图像将显得更暗。

下图显示了选择 S 曲线对比模式时的示例。

对比度 = 0.3,亮度 = 0,S 曲线对比模式

对比度 = 0.3,亮度 = 0.3,S 曲线对比模式

附加参数#

如果可用,则 BslBrightnessRawBslContrastRaw 参数允许您为亮度和对比度参数输入整数值,而不是浮点值。通常您不需要设置这些参数。

详情#

显示所有相机型号

相机型号 Available Contrast Modes
a2A1920-51gcBAS Brightness and Contrast feature not supported
a2A1920-51gcPRO Brightness and Contrast feature not supported
a2A1920-51gmBAS Brightness and Contrast feature not supported
a2A1920-51gmPRO Brightness and Contrast feature not supported
a2A1920-160ucBAS Brightness and Contrast feature not supported
a2A1920-160ucPRO Brightness and Contrast feature not supported
a2A1920-160umBAS Brightness and Contrast feature not supported
a2A1920-160umPRO Brightness and Contrast feature not supported
a2A2590-22gcBAS Brightness and Contrast feature not supported
a2A2590-22gcPRO Brightness and Contrast feature not supported
a2A2590-22gmBAS Brightness and Contrast feature not supported
a2A2590-22gmPRO Brightness and Contrast feature not supported
a2A2590-60ucBAS Brightness and Contrast feature not supported
a2A2590-60ucPRO Brightness and Contrast feature not supported
a2A2590-60umBAS Brightness and Contrast feature not supported
a2A2590-60umPRO Brightness and Contrast feature not supported
a2A3840-13gcBAS Brightness and Contrast feature not supported
a2A3840-13gcPRO Brightness and Contrast feature not supported
a2A3840-13gmBAS Brightness and Contrast feature not supported
a2A3840-13gmPRO Brightness and Contrast feature not supported
a2A3840-45ucBAS Brightness and Contrast feature not supported
a2A3840-45ucPRO Brightness and Contrast feature not supported
a2A3840-45umBAS Brightness and Contrast feature not supported
a2A3840-45umPRO Brightness and Contrast feature not supported
acA640-90gc Brightness and Contrast feature not supported
acA640-90gm Brightness and Contrast feature not supported
acA640-90uc Brightness and Contrast feature not supported
acA640-90um Brightness and Contrast feature not supported
acA640-120gc Brightness and Contrast feature not supported
acA640-120gm Brightness and Contrast feature not supported
acA640-120uc Brightness and Contrast feature not supported
acA640-120um Brightness and Contrast feature not supported
acA640-121gm Brightness and Contrast feature not supported
acA640-300gc Brightness and Contrast feature not supported
acA640-300gm Brightness and Contrast feature not supported
acA640-750uc Brightness and Contrast feature not supported
acA640-750um Brightness and Contrast feature not supported
acA720-290gc Brightness and Contrast feature not supported
acA720-290gm Brightness and Contrast feature not supported
acA720-520uc Brightness and Contrast feature not supported
acA720-520um Brightness and Contrast feature not supported
acA780-75gc Brightness and Contrast feature not supported
acA780-75gm Brightness and Contrast feature not supported
acA800-200gc Brightness and Contrast feature not supported
acA800-200gm Brightness and Contrast feature not supported
acA800-510uc Brightness and Contrast feature not supported
acA800-510um Brightness and Contrast feature not supported
acA1280-60gc Brightness and Contrast feature not supported
acA1280-60gm Brightness and Contrast feature not supported
acA1300-22gc Brightness and Contrast feature not supported
acA1300-22gm Brightness and Contrast feature not supported
acA1300-30gc Brightness and Contrast feature not supported
acA1300-30gm Brightness and Contrast feature not supported
acA1300-30uc Brightness and Contrast feature not supported
acA1300-30um Brightness and Contrast feature not supported
acA1300-60gc Brightness and Contrast feature not supported
acA1300-60gm Brightness and Contrast feature not supported
acA1300-60gmNIR Brightness and Contrast feature not supported
acA1300-75gc Brightness and Contrast feature not supported
acA1300-75gm Brightness and Contrast feature not supported
acA1300-200uc Brightness and Contrast feature not supported
acA1300-200um Brightness and Contrast feature not supported
acA1440-73gc Brightness and Contrast feature not supported
acA1440-73gm Brightness and Contrast feature not supported
acA1440-220uc Brightness and Contrast feature not supported
acA1440-220um Brightness and Contrast feature not supported
acA1600-20gc Brightness and Contrast feature not supported
acA1600-20gm Brightness and Contrast feature not supported
acA1600-20uc Brightness and Contrast feature not supported
acA1600-20um Brightness and Contrast feature not supported
acA1600-60gc Brightness and Contrast feature not supported
acA1600-60gm Brightness and Contrast feature not supported
acA1920-25gc Brightness and Contrast feature not supported
acA1920-25gm Brightness and Contrast feature not supported
acA1920-25uc Brightness and Contrast feature not supported
acA1920-25um Brightness and Contrast feature not supported
acA1920-40gc Brightness and Contrast feature not supported
acA1920-40gm Brightness and Contrast feature not supported
acA1920-40uc Brightness and Contrast feature not supported
acA1920-40ucMED Linear
S-Curve
acA1920-40um Brightness and Contrast feature not supported
acA1920-40umMED Linear
S-Curve
acA1920-48gc Brightness and Contrast feature not supported
acA1920-48gm Brightness and Contrast feature not supported
acA1920-50gc Brightness and Contrast feature not supported
acA1920-50gm Brightness and Contrast feature not supported
acA1920-150uc Brightness and Contrast feature not supported
acA1920-150um Brightness and Contrast feature not supported
acA1920-155uc Brightness and Contrast feature not supported
acA1920-155ucMED Linear
S-Curve
acA1920-155um Brightness and Contrast feature not supported
acA1920-155umMED Linear
S-Curve
acA2000-50gc Brightness and Contrast feature not supported
acA2000-50gm Brightness and Contrast feature not supported
acA2000-50gmNIR Brightness and Contrast feature not supported
acA2000-165uc Brightness and Contrast feature not supported
acA2000-165um Brightness and Contrast feature not supported
acA2000-165umNIR Brightness and Contrast feature not supported
acA2040-25gc Brightness and Contrast feature not supported
acA2040-25gm Brightness and Contrast feature not supported
acA2040-25gmNIR Brightness and Contrast feature not supported
acA2040-35gc Brightness and Contrast feature not supported
acA2040-35gm Brightness and Contrast feature not supported
acA2040-55uc Brightness and Contrast feature not supported
acA2040-55um Brightness and Contrast feature not supported
acA2040-90uc Brightness and Contrast feature not supported
acA2040-90um Brightness and Contrast feature not supported
acA2040-90umNIR Brightness and Contrast feature not supported
acA2040-120uc Brightness and Contrast feature not supported
acA2040-120um Brightness and Contrast feature not supported
acA2440-20gc Brightness and Contrast feature not supported
acA2440-20gm Brightness and Contrast feature not supported
acA2440-35uc Brightness and Contrast feature not supported
acA2440-35ucMED Linear
S-Curve
acA2440-35um Brightness and Contrast feature not supported
acA2440-35umMED Linear
S-Curve
acA2440-75uc Brightness and Contrast feature not supported
acA2440-75ucMED Linear
S-Curve
acA2440-75um Brightness and Contrast feature not supported
acA2440-75umMED Linear
S-Curve
acA2500-14gc Brightness and Contrast feature not supported
acA2500-14gm Brightness and Contrast feature not supported
acA2500-14uc Brightness and Contrast feature not supported
acA2500-14um Brightness and Contrast feature not supported
acA2500-20gc Brightness and Contrast feature not supported
acA2500-20gcMED Linear
S-Curve
acA2500-20gm Brightness and Contrast feature not supported
acA2500-20gmMED Linear
S-Curve
acA2500-60uc Brightness and Contrast feature not supported
acA2500-60um Brightness and Contrast feature not supported
acA3088-16gc Brightness and Contrast feature not supported
acA3088-16gm Brightness and Contrast feature not supported
acA3088-57uc Brightness and Contrast feature not supported
acA3088-57um Brightness and Contrast feature not supported
acA3800-10gc Brightness and Contrast feature not supported
acA3800-10gm Brightness and Contrast feature not supported
acA3800-14uc Brightness and Contrast feature not supported
acA3800-14um Brightness and Contrast feature not supported
acA4024-8gc Brightness and Contrast feature not supported
acA4024-8gm Brightness and Contrast feature not supported
acA4024-29uc Brightness and Contrast feature not supported
acA4024-29um Brightness and Contrast feature not supported
acA4096-11gc Brightness and Contrast feature not supported
acA4096-11gm Brightness and Contrast feature not supported
acA4096-30uc Brightness and Contrast feature not supported
acA4096-30ucMED Linear
S-Curve
acA4096-30um Brightness and Contrast feature not supported
acA4096-30umMED Linear
S-Curve
acA4096-40uc Brightness and Contrast feature not supported
acA4096-40ucMED Linear
S-Curve
acA4096-40um Brightness and Contrast feature not supported
acA4096-40umMED Linear
S-Curve
acA4112-8gc Brightness and Contrast feature not supported
acA4112-8gm Brightness and Contrast feature not supported
acA4112-20uc Brightness and Contrast feature not supported
acA4112-20ucMED Linear
S-Curve
acA4112-20um Brightness and Contrast feature not supported
acA4112-20umMED Linear
S-Curve
acA4112-30uc Brightness and Contrast feature not supported
acA4112-30ucMED Linear
S-Curve
acA4112-30um Brightness and Contrast feature not supported
acA4112-30umMED Linear
S-Curve
acA4600-7gc Brightness and Contrast feature not supported
acA4600-10uc Brightness and Contrast feature not supported
acA5472-5gc Brightness and Contrast feature not supported
acA5472-5gm Brightness and Contrast feature not supported
acA5472-17uc Brightness and Contrast feature not supported
acA5472-17ucMED Linear
S-Curve
acA5472-17um Brightness and Contrast feature not supported
boA4096-93cc Brightness and Contrast feature not supported
boA4096-93cm Brightness and Contrast feature not supported
boA4112-68cc Brightness and Contrast feature not supported
boA4112-68cm Brightness and Contrast feature not supported
daA1280-54lc Linear
S-Curve
daA1280-54lm Linear
S-Curve
daA1280-54uc Linear
S-Curve
daA1280-54um Linear
S-Curve
daA1600-60lc Linear
S-Curve
daA1600-60lm Linear
S-Curve
daA1600-60uc Linear
S-Curve
daA1600-60um Linear
S-Curve
daA1920-15um Linear
S-Curve
daA1920-30uc Linear
S-Curve
daA1920-30um Linear
S-Curve
daA2500-14lc Linear
S-Curve
daA2500-14lm Linear
S-Curve
daA2500-14uc Linear
S-Curve
daA2500-14um Linear
S-Curve
daA2500-60mc Brightness and Contrast feature not supported
daA2500-60mci S-Curve
daA4200-30mci S-Curve
puA1280-54uc Linear
S-Curve
puA1280-54um Linear
S-Curve
puA1600-60uc Linear
S-Curve
puA1600-60um Linear
S-Curve
puA1920-30uc Linear
S-Curve
puA1920-30um Linear
S-Curve
puA2500-14uc Linear
S-Curve
puA2500-14um Linear
S-Curve

示例代码#

// Set the Brightness parameter to 0.5
camera.BslBrightness.SetValue(0.5);
// Set the contrast mode to Linear
camera.BslContrastMode.SetValue(BslContrastMode_Linear);
// Set the Contrast parameter to 1.2
camera.BslContrast.SetValue(1.2);
INodeMap& nodemap = camera.GetNodeMap();
// Set the Brightness parameter to 0.5
CFloatPtr(nodemap.GetNode("BslBrightness"))->SetValue(0.5);
// Set the contrast mode to Linear
CEnumerationPtr(nodemap.GetNode("BslContrastMode"))->FromString("Linear");
// Set the Contrast parameter to 1.2
CFloatPtr(nodemap.GetNode("BslContrast"))->SetValue(1.2);
INodeMap& nodemap = camera.GetNodeMap();
// Set the Brightness parameter to 0.5
CFloatParameter(nodemap, "BslBrightness").SetValue(0.5);
// Set the contrast mode to Linear
CEnumParameter(nodemap, "BslContrastMode").SetValue("Linear");
// Set the Contrast parameter to 1.2
CFloatParameter(nodemap, "BslContrast").SetValue(1.2);
// Set the Brightness parameter to 0.5
camera.Parameters[PLCamera.BslBrightness].SetValue(0.5);
// Set the contrast mode to Linear
camera.Parameters[PLCamera.BslContrastMode].SetValue(PLCamera.BslContrastMode.Linear);
// Set the Contrast parameter to 1.2
camera.Parameters[PLCamera.BslContrast].SetValue(1.2);
// Set the Brightness parameter to 0.5
Pylon.DeviceSetFloatFeature(hdev, "BslBrightness", 0.5);
// Set the contrast mode to Linear
Pylon.DeviceFeatureFromString(hdev, "BslContrastMode", "Linear");
// Set the Contrast parameter to 1.2
Pylon.DeviceSetFloatFeature(hdev, "BslContrast", 1.2);
/* 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 Brightness parameter to 0.5 */
errRes = PylonDeviceSetFloatFeature(hdev, "BslBrightness", 0.5);
CHECK(errRes);
/* Set the contrast mode to Linear */
errRes = PylonDeviceFeatureFromString(hdev, "BslContrastMode", "Linear");
CHECK(errRes);
/* Set the Contrast parameter to 1.2 */
errRes = PylonDeviceSetFloatFeature(hdev, "BslContrast", 1.2);
CHECK(errRes);

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