跳转到内容

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:图像亮度已优化,可在 sRGB 监视器上显示。应用约 0.4 的 Gamma 校正值。有关更多信息,请参见详情部分中的脚注。

详情#

显示所有相机型号

相机型号 附加参数
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
a2A4504-5gcBAS BslColorSpacec
a2A4504-5gcPRO BslColorSpacec
a2A4504-5gmBAS BslColorSpacec
a2A4504-5gmPRO BslColorSpacec
a2A4504-18ucBAS BslColorSpacec
a2A4504-18ucPRO BslColorSpacec
a2A4504-18umBAS BslColorSpacec
a2A4504-18umPRO BslColorSpacec
a2A5320-7gcBAS BslColorSpacec
a2A5320-7gcPRO BslColorSpacec
a2A5320-7gmBAS BslColorSpacec
a2A5320-7gmPRO BslColorSpacec
a2A5320-23ucBAS BslColorSpacec
a2A5320-23ucPRO BslColorSpacec
a2A5320-23umBAS BslColorSpacec
a2A5320-23umPRO BslColorSpacec
a2A5328-4gcBAS BslColorSpacec
a2A5328-4gcPRO BslColorSpacec
a2A5328-4gmBAS BslColorSpacec
a2A5328-4gmPRO BslColorSpacec
a2A5328-15ucBAS BslColorSpacec
a2A5328-15ucPRO BslColorSpacec
a2A5328-15umBAS BslColorSpacec
a2A5328-15umPRO 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-57ucMED Nonea
acA3088-57um Nonea
acA3088-57umMED 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
acA5472-17umMED Nonea
boA4096-93cc BslColorSpacec
boA4096-93cm BslColorSpacec
boA4112-68cc BslColorSpacec
boA4112-68cm BslColorSpacec
boA4500-45cc BslColorSpacec
boA4500-45cm BslColorSpacec
boA6500-36cc BslColorSpacec
boA6500-36cm BslColorSpacec
boA8100-16cc BslColorSpacec
boA8100-16cm 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
daA1920-160uc BslColorSpacea
daA1920-160um BslColorSpacea
daA2500-14lc BslColorSpaceMode b
daA2500-14lm BslColorSpaceMode b
daA2500-14uc BslColorSpaceMode b
daA2500-14um BslColorSpaceMode b
daA3840-45uc BslColorSpacea
daA3840-45um BslColorSpacea
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. 如果选择 Light Source Preset,则将应用大约 0.4 的附加 Gamma 校正值(sRGB Gamma 校正)。此值是单独应用的,不会包含在 Gamma 参数值中。示例:您已将光源预设设置为“钨丝”,然后将 Gamma 参数值为 1.2。首先,将大约 0.4 的自动校正值应用于像素值。之后,将 1.2 的 Gamma 校正值应用于所得的像素值。

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

  3. 如果将色彩空间设置为 sRGB,则将应用大约 0.4 的 Gamma 校正值。此值是单独应用的,不会包含在 Gamma 参数值中。示例:您已将色彩空间设置为 sRGB,然后将 Gamma 参数设置为 1.2。首先,将大约 0.4 的自动校正值应用于像素值。之后,将 1.2 的 Gamma 校正值应用于所得的像素值。
    如果您选择了 Light Source Preset,将色彩空间设置为 sRGB 还会影响 Balance WhiteColor AdjustmentColor Transformation 功能。

  4. 如果将色彩空间设置为 sRGB,则将应用大约 0.4 的 Gamma 校正值,Gamma 参数变为只读,并且 Gamma 参数值将被忽略。

示例代码#

ace 2、boost 和 dart IMX 相机#

// 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
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);
/* 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
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);
/* 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
CFloatParameter(nodemap, "Gamma").SetValue(1.2);
// Set the Gamma value to 1.2
camera.Parameters[PLCamera.Gamma].SetValue(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 轻松设置参数。