跳转到内容

Gamma (dart E)#

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

该功能的使用#

运作原理#

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

Gamma 校正公式(红色像素)

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

配置 Gamma 校正#

To configure gamma correction, set the Gamma parameter to the desired value. The parameter's value range is 0 to ≈4. - Gamma = 1: The overall brightness remains unchanged. - Gamma < 1: The overall brightness increases. - Gamma > 1: The overall brightness decreases.

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

信息

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

设置色彩空间#

On daA…mci camera modules, the BslColorSpace parameter is available. It allows you to select one of the following gamma correction modes:

  • RGB: No additional gamma correction value is applied.
  • sRGB: The image brightness is optimized for display on an sRGB monitor. A gamma correction value of approximately 0.4 is applied, the Gamma parameter becomes read-only, and the Gamma parameter value is ignored.

示例代码#

// 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);
# Set the Gamma value to 1.2
camera.Gamma.Value = 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);

You can also use the pylon Viewer to easily set the parameters.