跳转到内容

Gamma#

相机的 Gamma 功能使您可以优化所采集图像的亮度,以便在显示器上显示。

该功能的使用#

运作原理#

相机根据以下公式(以彩色相机和红色像素值 (R) 为例)将 Gamma 校正值 (γ) 应用于每个像素的亮度值:

Gamma 校正公式(红色像素)

具体的最大像素值 (Rmax) 视情况而有所不同,例如在 8 位像素格式下为 255,在 10 位像素格式下为 1023。

启用 Gamma 校正#

要启用 Gamma 校正:

  1. GammaEnable 参数设置为 true如果可用)。
  2. 为了获得最佳效果,请将 BlackLevel 参数设置为 0。
  3. 设置 Gamma 将参数设置为所需值。该参数值的范围是 0 至 ≈4。
    • Gamma = 1:整体亮度保持不变
    • Gamma <1:整体亮度增加
    • Gamma > 1:整体亮度降低

在所有情况下,黑色像素(亮度 = 0)和白色像素(亮度 = 最大值)都不会被调整。

信息

如果启用 Gamma 校正,并且像素格式设置为 12 位像素格式,则会丢失一些图像信息。像素数据输出仍将是 12 位,但是像素值将在 Gamma 校正过程中插入。

附加参数#

根据您的相机型号,可以使用以下附加参数:

  • GammaEnable:启用或禁用 Gamma 校正。
  • GammaSelector:允许您选择以下 Gamma 校正模式:
    • User:可以根据需要设置 Gamma 校正值(默认)。
    • sRGB:相机自动将 Gamma 校正值设定为约 0.4。该值针对 sRGB 显示器上的图像显示进行了优化。
  • BslColorSpaceModeBslColorSpace:允许您选择以下 Gamma 校正模式:
    • RGB:不应用其他 Gamma 校正值。
    • sRGB: The image brightness is optimized for display on an sRGB monitor. A gamma correction value of approximately 0.4 is applied. For more information, see the footnotes in the Specifics section.

详情#

显示所有相机型号

相机型号 附加参数
a2A1920-51gcBAS BslColorSpacec
a2A1920-51gcPRO BslColorSpacec
a2A1920-51gmBAS BslColorSpacec
a2A1920-51gmPRO BslColorSpacec
a2A1920-160ucBAS BslColorSpacec
a2A1920-160ucPRO BslColorSpacec
a2A1920-160umBAS BslColorSpacec
a2A1920-160umPRO BslColorSpacec
a2A2590-22gcBAS BslColorSpacec
a2A2590-22gcPRO BslColorSpacec
a2A2590-22gmBAS BslColorSpacec
a2A2590-22gmPRO BslColorSpacec
a2A2590-60ucBAS BslColorSpacec
a2A2590-60ucPRO BslColorSpacec
a2A2590-60umBAS BslColorSpacec
a2A2590-60umPRO BslColorSpacec
a2A3840-13gcBAS BslColorSpacec
a2A3840-13gcPRO BslColorSpacec
a2A3840-13gmBAS BslColorSpacec
a2A3840-13gmPRO BslColorSpacec
a2A3840-45ucBAS BslColorSpacec
a2A3840-45ucPRO BslColorSpacec
a2A3840-45umBAS BslColorSpacec
a2A3840-45umPRO BslColorSpacec
acA640-90gc GammaEnable
GammaSelector
acA640-90gm GammaEnable
GammaSelector
acA640-90uc Nonea
acA640-90um Nonea
acA640-120gc GammaEnable
GammaSelector
acA640-120gm GammaEnable
GammaSelector
acA640-120uc Nonea
acA640-120um Nonea
acA640-121gm GammaEnable
GammaSelector
acA640-300gc GammaEnable
GammaSelector
acA640-300gm GammaEnable
GammaSelector
acA640-750uc Nonea
acA640-750um Nonea
acA720-290gc GammaEnable
GammaSelector
acA720-290gm GammaEnable
GammaSelector
acA720-520uc Nonea
acA720-520um Nonea
acA780-75gc GammaEnable
GammaSelector
acA780-75gm GammaEnable
GammaSelector
acA800-200gc GammaEnable
GammaSelector
acA800-200gm GammaEnable
GammaSelector
acA800-510uc Nonea
acA800-510um Nonea
acA1280-60gc GammaEnable
GammaSelector
acA1280-60gm GammaEnable
GammaSelector
acA1300-22gc GammaEnable
GammaSelector
acA1300-22gm GammaEnable
GammaSelector
acA1300-30gc GammaEnable
GammaSelector
acA1300-30gm GammaEnable
GammaSelector
acA1300-30uc Nonea
acA1300-30um Nonea
acA1300-60gc GammaEnable
GammaSelector
acA1300-60gm GammaEnable
GammaSelector
acA1300-60gmNIR GammaEnable
GammaSelector
acA1300-75gc GammaEnable
GammaSelector
acA1300-75gm GammaEnable
GammaSelector
acA1300-200uc Nonea
acA1300-200um Nonea
acA1440-73gc GammaEnable
GammaSelector
acA1440-73gm GammaEnable
GammaSelector
acA1440-220uc Nonea
acA1440-220um Nonea
acA1600-20gc GammaEnable
GammaSelector
acA1600-20gm GammaEnable
GammaSelector
acA1600-20uc Nonea
acA1600-20um Nonea
acA1600-60gc GammaEnable
GammaSelector
acA1600-60gm GammaEnable
GammaSelector
acA1920-25gc GammaEnable
GammaSelector
acA1920-25gm GammaEnable
GammaSelector
acA1920-25uc Nonea
acA1920-25um Nonea
acA1920-40gc GammaEnable
GammaSelector
acA1920-40gm GammaEnable
GammaSelector
acA1920-40uc Nonea
acA1920-40ucMED Nonea
acA1920-40um Nonea
acA1920-40umMED Nonea
acA1920-48gc GammaEnable
GammaSelector
acA1920-48gm GammaEnable
GammaSelector
acA1920-50gc GammaEnable
GammaSelector
acA1920-50gm GammaEnable
GammaSelector
acA1920-150uc Nonea
acA1920-150um Nonea
acA1920-155uc Nonea
acA1920-155ucMED Nonea
acA1920-155um Nonea
acA1920-155umMED Nonea
acA2000-50gc GammaEnable
GammaSelector
acA2000-50gm GammaEnable
GammaSelector
acA2000-50gmNIR GammaEnable
GammaSelector
acA2000-165uc Nonea
acA2000-165um Nonea
acA2000-165umNIR Nonea
acA2040-25gc GammaEnable
GammaSelector
acA2040-25gm GammaEnable
GammaSelector
acA2040-25gmNIR GammaEnable
GammaSelector
acA2040-35gc GammaEnable
GammaSelector
acA2040-35gm GammaEnable
GammaSelector
acA2040-55uc Nonea
acA2040-55um Nonea
acA2040-90uc Nonea
acA2040-90um Nonea
acA2040-90umNIR Nonea
acA2040-120uc Nonea
acA2040-120um Nonea
acA2440-20gc GammaEnable
GammaSelector
acA2440-20gm GammaEnable
GammaSelector
acA2440-35uc Nonea
acA2440-35ucMED Nonea
acA2440-35um Nonea
acA2440-35umMED Nonea
acA2440-75uc Nonea
acA2440-75ucMED Nonea
acA2440-75um Nonea
acA2440-75umMED Nonea
acA2500-14gc GammaEnable
GammaSelector
acA2500-14gm GammaEnable
GammaSelector
acA2500-14uc Nonea
acA2500-14um Nonea
acA2500-20gc GammaEnable
GammaSelector
acA2500-20gcMED GammaEnable
GammaSelector
acA2500-20gm GammaEnable
GammaSelector
acA2500-20gmMED GammaEnable
GammaSelector
acA2500-60uc Nonea
acA2500-60um Nonea
acA3088-16gc GammaEnable
GammaSelector
acA3088-16gm GammaEnable
GammaSelector
acA3088-57uc Nonea
acA3088-57um Nonea
acA3800-10gc GammaEnable
GammaSelector
acA3800-10gm GammaEnable
GammaSelector
acA3800-14uc Nonea
acA3800-14um Nonea
acA4024-8gc GammaEnable
GammaSelector
acA4024-8gm GammaEnable
GammaSelector
acA4024-29uc Nonea
acA4024-29um Nonea
acA4096-11gc GammaEnable
GammaSelector
acA4096-11gm GammaEnable
GammaSelector
acA4096-30uc Nonea
acA4096-30ucMED Nonea
acA4096-30um Nonea
acA4096-30umMED Nonea
acA4096-40uc Nonea
acA4096-40ucMED Nonea
acA4096-40um Nonea
acA4096-40umMED Nonea
acA4112-8gc GammaEnable
GammaSelector
acA4112-8gm GammaEnable
GammaSelector
acA4112-20uc Nonea
acA4112-20ucMED Nonea
acA4112-20um Nonea
acA4112-20umMED Nonea
acA4112-30uc Nonea
acA4112-30ucMED Nonea
acA4112-30um Nonea
acA4112-30umMED Nonea
acA4600-7gc GammaEnable
GammaSelector
acA4600-10uc Nonea
acA5472-5gc GammaEnable
GammaSelector
acA5472-5gm GammaEnable
GammaSelector
acA5472-17uc Nonea
acA5472-17ucMED Nonea
acA5472-17um Nonea
boA4096-93cc BslColorSpacec
boA4096-93cm BslColorSpacec
boA4112-68cc BslColorSpacec
boA4112-68cm BslColorSpacec
daA1280-54lc BslColorSpaceMode b
daA1280-54lm BslColorSpaceMode b
daA1280-54uc BslColorSpaceMode b
daA1280-54um BslColorSpaceMode b
daA1600-60lc BslColorSpaceMode b
daA1600-60lm BslColorSpaceMode b
daA1600-60uc BslColorSpaceMode b
daA1600-60um BslColorSpaceMode b
daA1920-15um BslColorSpaceMode b
daA1920-30uc BslColorSpaceMode b
daA1920-30um BslColorSpaceMode b
daA2500-14lc BslColorSpaceMode b
daA2500-14lm BslColorSpaceMode b
daA2500-14uc BslColorSpaceMode b
daA2500-14um BslColorSpaceMode b
daA2500-60mc 不支持 Gamma 功能
daA2500-60mci BslColorSpaced
daA4200-30mci BslColorSpaced
puA1280-54uc BslColorSpaceMode b
puA1280-54um BslColorSpaceMode b
puA1600-60uc BslColorSpaceMode b
puA1600-60um BslColorSpaceMode b
puA1920-30uc BslColorSpaceMode b
puA1920-30um BslColorSpaceMode b
puA2500-14uc BslColorSpaceMode b
puA2500-14um BslColorSpaceMode b

  1. If you select a light source preset, an additional gamma correction value of approximately 0.4 is applied (sRGB gamma correction). This value is applied separately and not included in the Gamma parameter value. Example: You have set the light source preset to Tungsten and the Gamma parameter value to 1.2. First, an automatic correction value of approximately 0.4 is applied to the pixel values. After that, a gamma correction value of 1.2 is applied to the resulting pixel values.

  2. 仅在像素格式设置为 YCbCr422 或 RGB8 时可用。

  3. If the color space is set to sRGB, a gamma correction value of approximately 0.4 is applied. This value is applied separately and not included in the Gamma parameter value. Example: You set the color space to sRGB and the Gamma parameter to 1.2. First, an automatic correction value of approximately 0.4 is applied to the pixel values. After that, a gamma correction value of 1.2 is applied to the resulting pixel values.
    If you have selected a Light Source Preset, setting the color space to sRGB will also affect the Balance White, Color Adjustment, and Color Transformation features.

  4. If the color space is set to sRGB, a gamma correction value of approximately 0.4 is applied, the Gamma parameter becomes read-only, and the Gamma parameter value is ignored.

示例代码#

ace 2, boost, and dart IMX Cameras#

// Set the Gamma value to 1.2
camera.Gamma.SetValue(1.2);
// Set the color space to sRGB
camera.BslColorSpace.SetValue(BslColorSpace_sRGB);
INodeMap& nodemap = camera.GetNodeMap();
// Set the Gamma value to 1.2
CFloatPtr(nodemap.GetNode("Gamma"))->SetValue(1.2);
// Set the color space to sRGB
CEnumerationPtr(nodemap.GetNode("BslColorSpace"))->FromString("sRGB");
INodeMap& nodemap = camera.GetNodeMap();
// Set the Gamma value to 1.2
CFloatParameter(nodemap, "Gamma").SetValue(1.2);
// Set the color space to sRGB
CEnumParameter(nodemap, "BslColorSpace").SetValue("sRGB");
// Set the Gamma value to 1.2
camera.Parameters[PLCamera.Gamma].SetValue(1.2);
// Set the color space to sRGB
camera.Parameters[PLCamera.BslColorSpace].SetValue(PLCamera.BslColorSpace.sRGB);
// Set the Gamma value to 1.2
Pylon.DeviceSetFloatFeature(hdev, "Gamma", 1.2);
// Set the color space to sRGB
Pylon.DeviceFeatureFromString(hdev, "BslColorSpace", "sRGB");
/* 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 Gamma value to 1.2 */
errRes = PylonDeviceSetFloatFeature(hdev, "Gamma", 1.2);
CHECK(errRes);
/* Set the color space to sRGB */
errRes = PylonDeviceFeatureFromString(hdev, "BslColorSpace", "sRGB");
CHECK(errRes);

ace classic/U/L GigE 相机#

// Enable the Gamma feature
camera.GammaEnable.SetValue(true);
// Set the gamma type to User
camera.GammaSelector.SetValue(GammaSelector_User);
// Set the Gamma value to 1.2
camera.Gamma.SetValue(1.2);
INodeMap& nodemap = camera.GetNodeMap();
// Enable the Gamma feature
CBooleanPtr(nodemap.GetNode("GammaEnable"))->SetValue(true);
// Set the gamma type to User
CEnumerationPtr(nodemap.GetNode("GammaSelector"))->FromString("User");
// Set the Gamma value to 1.2
CFloatPtr(nodemap.GetNode("Gamma"))->SetValue(1.2);
INodeMap& nodemap = camera.GetNodeMap();
// Enable the Gamma feature
CBooleanParameter(nodemap, "GammaEnable").SetValue(true);
// Set the gamma type to User
CEnumParameter(nodemap, "GammaSelector").SetValue("User");
// Set the Gamma value to 1.2
CFloatParameter(nodemap, "Gamma").SetValue(1.2);
// Enable the Gamma feature
camera.Parameters[PLCamera.GammaEnable].SetValue(true);
// Set the gamma type to User
camera.Parameters[PLCamera.GammaSelector].SetValue(PLCamera.GammaSelector.User);
// Set the Gamma value to 1.2
camera.Parameters[PLCamera.Gamma].SetValue(1.2);
// Enable the Gamma feature
Pylon.DeviceSetBooleanFeature(hdev, "GammaEnable", true);
// Set the gamma type to User
Pylon.DeviceFeatureFromString(hdev, "GammaSelector", "User");
// Set the Gamma value to 1.2
Pylon.DeviceSetFloatFeature(hdev, "Gamma", 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 */
/* Enable the Gamma feature */
errRes = PylonDeviceSetBooleanFeature(hdev, "GammaEnable", 1);
CHECK(errRes);
/* Set the gamma type to User */
errRes = PylonDeviceFeatureFromString(hdev, "GammaSelector", "User");
CHECK(errRes);
/* Set the Gamma value to 1.2 */
errRes = PylonDeviceSetFloatFeature(hdev, "Gamma", 1.2);
CHECK(errRes);

其他相机#

// Set the Gamma value to 1.2
camera.Gamma.SetValue(1.2);
INodeMap& nodemap = camera.GetNodeMap();
// Set the Gamma value to 1.2
CFloatPtr(nodemap.GetNode("Gamma"))->SetValue(1.2);
INodeMap& nodemap = camera.GetNodeMap();
// Set the Gamma value to 1.2
CFloatParameter(nodemap, "Gamma").SetValue(1.2);
// Set the Gamma value to 1.2
camera.Parameters[PLCamera.Gamma].SetValue(1.2);
// Set the Gamma value to 1.2
Pylon.DeviceSetFloatFeature(hdev, "Gamma", 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 Gamma value to 1.2 */
errRes = PylonDeviceSetFloatFeature(hdev, "Gamma", 1.2);
CHECK(errRes);

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