Gamma

The Gamma camera feature allows you to optimize the brightness of acquired images for display on a monitor.

In this topic Hide

Using the Feature

Prerequisites

How It Works

The camera applies a gamma correction value (γ) to the brightness value of each pixel according to the following formula (red pixel value (R) of a color camera shown as an example):

Gamma Correction Formula (Red Pixels)

The maximum pixel value (Rmax) equals, e.g., 255 for 8-bit pixel formats or 1 023 for 10-bit pixel formats.

Enabling Gamma Correction

To enable gamma correction, use the Gamma parameter. The parameter's value range is 0 to ≈4.

In all cases, black pixels (brightness = 0) and white pixels (brightness = maximum) will not be adjusted.

If you enable gamma correction and the pixel format is set to a 12-bit pixel format, some image information will be lost. Pixel data output will still be 12-bit, but the pixel values will be interpolated during the gamma correction process.

Disabling Gamma Correction

To disable gamma correction:

Additional Parameters

Depending on your camera model, the following additional parameters are available:

External Links

Specifics

Camera Model

Additional Parameters

All ace 2 GigE camera models BslColorSpacea
All ace 2 USB 3.0 camera models BslColorSpacea
All ace GigE camera models
  • GammaEnable
  • GammaSelector
All ace USB 3.0 camera models Nonea
All boost CXP-12 camera models tbd
All dart BCON for LVDS camera models BslColorSpaceModeb
All dart BCON for MIPI camera models Gamma feature not supported
All dart USB 3.0 camera models BslColorSpaceModeb
All pulse USB 3.0 camera models BslColorSpaceModeb

aIf 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 will not be 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.

bOnly available if the pixel format is set to YCbCr422 or RGB8.

Sample Code

// 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);
// 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);
// Set the Gamma value to 1.2
CFloatPtr(nodemap.GetNode("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);
// 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);
// 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 */
errRes = PylonDeviceSetFloatFeature(hdev, "Gamma", 1.2);
CHECK(errRes);

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