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):
The maximum pixel value (Rmax) equals, e.g., 255 for 8-bit pixel formats or 1 023 for 10-bit pixel formats.
Set the GammaEnable parameter to true (if available).
For best results, set the BlackLevel parameter to 0.
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.
In all cases, black pixels (brightness = 0) and white pixels (brightness = maximum) will not be adjusted.
Info
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.
On boA13440-17cm cameras, gamma correction can only be enabled, if the pixel format is set to an 8-bit pixel format.
Depending on your camera model, the following additional parameters are available:
GammaEnable: Enables or disables gamma correction.
GammaSelector: Allows you to select one of the following gamma correction modes:
User: The gamma correction value can be set as desired. (Default.)
sRGB: The camera automatically sets a gamma correction value of approximately 0.4. This value is optimized for image display on sRGB monitors.
BslColorSpaceMode or BslColorSpace: 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. For more information, see the footnotes in the Specifics section.
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.
Only available if the pixel format is set to YCbCr422 or RGB8.
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.
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.
// Set the Gamma value to 1.2camera.Gamma.SetValue(1.2);// Set the color space to sRGBcamera.BslColorSpace.SetValue(BslColorSpace_sRGB);
INodeMap&nodemap=camera.GetNodeMap();// Set the Gamma value to 1.2CFloatParameter(nodemap,"Gamma").SetValue(1.2);// Set the color space to sRGBCEnumParameter(nodemap,"BslColorSpace").SetValue("sRGB");
// Set the Gamma value to 1.2camera.Parameters[PLCamera.Gamma].SetValue(1.2);// Set the color space to sRGBcamera.Parameters[PLCamera.BslColorSpace].SetValue(PLCamera.BslColorSpace.sRGB);
/* Macro to check for errors */#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)GENAPIC_RESULTerrRes=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);
# Set the Gamma value to 1.2camera.Gamma.Value=1.2# Set the color space to sRGBcamera.BslColorSpace.Value="sRGB"
// Enable the Gamma featurecamera.GammaEnable.SetValue(true);// Set the gamma type to Usercamera.GammaSelector.SetValue(GammaSelector_User);// Set the Gamma value to 1.2camera.Gamma.SetValue(1.2);
INodeMap&nodemap=camera.GetNodeMap();// Enable the Gamma featureCBooleanParameter(nodemap,"GammaEnable").SetValue(true);// Set the gamma type to UserCEnumParameter(nodemap,"GammaSelector").SetValue("User");// Set the Gamma value to 1.2CFloatParameter(nodemap,"Gamma").SetValue(1.2);
// Enable the Gamma featurecamera.Parameters[PLCamera.GammaEnable].SetValue(true);// Set the gamma type to Usercamera.Parameters[PLCamera.GammaSelector].SetValue(PLCamera.GammaSelector.User);// Set the Gamma value to 1.2camera.Parameters[PLCamera.Gamma].SetValue(1.2);
/* Macro to check for errors */#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)GENAPIC_RESULTerrRes=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);
# Enable the Gamma featurecamera.GammaEnable.Value=True# Set the gamma type to Usercamera.GammaSelector.Value="User"# Set the Gamma value to 1.2camera.Gamma.Value=1.2
// Set the Gamma value to 1.2camera.Gamma.SetValue(1.2);
INodeMap&nodemap=camera.GetNodeMap();// Set the Gamma value to 1.2CFloatParameter(nodemap,"Gamma").SetValue(1.2);
// Set the Gamma value to 1.2camera.Parameters[PLCamera.Gamma].SetValue(1.2);
/* Macro to check for errors */#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)GENAPIC_RESULTerrRes=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.2camera.Gamma.Value=1.2