Brightness and contrast are always processed together as parts of a common mathematical Brightness/Contrast function.
In this topic Hide
To adjust the contrast:
To adjust the brightness, enter a value for the BslBrightness parameter. The parameter's value range is from -1 to 1. By default, the parameter is set to 0 which means that the brightness remains unchanged.
Adjusting the contrast changes the degree of difference between light and dark areas in the image. The more contrast you apply, the more pronounced the difference will be.
How the contrast is applied depends on the contrast mode that you select.
This is the default contrast mode. If this contrast mode is selected,
the camera uses a linear function to adjust the contrast.
Increasing or decreasing the contrast, increases or decreases the gradient
of the linear function.
With a contrast setting greater than 0, more output pixel values will be
set to completely black (0) or completely white (maximum pixel value).
If the contrast is set to 0.3 (see second figure), input values from 0 to approximately 50 are set to completely black, and input values from approximately 205 to 255 are set to completely white. This means that the overall range of tonal values, i.e, the dynamic range of the image, is reduced. The darkest and lightest regions of the image will appear completely black or completely white, but the other areas will appear more defined.
Decreasing the contrast has the opposite effect.
If this contrast mode is selected, the camera uses an S-curve function to adjust the contrast.
This allows you to improve the perceived contrast while preserving the dynamic range of the image.
The more you increase the contrast, the more S-shaped the graph of the function will be:
The figures above show that increasing the contrast in S-Curve mode has
the following effects:
Contrast settings below 0 in S-Curve mode will result in an inverted S-curve with opposite effects.
Adjusting the brightness allows you to lighten or darken the image by increasing or decreasing its tonal values.
Adjusting the brightness moves the pivot point of the Brightness/Contrast function:
The figures below show examples with the S-Curve contrast mode selected.
If available, the BslBrightnessRaw and BslContrastRaw parameters allow you to enter integer values instead of float values for the brightness and contrast parameters. Normally, you don't need to set these parameters.
// Set the Brightness parameter to 0.5
camera.BslBrightness.SetValue(0.5);
// Set the contrast mode to Linear
camera.BslContrastMode.SetValue(BslContrastMode_Linear);
// Set the Contrast parameter to 1.2
camera.BslContrast.SetValue(1.2);
INodeMap& nodemap = camera.GetNodeMap();
// Set the Brightness parameter to 0.5
CFloatPtr(nodemap.GetNode("BslBrightness"))->SetValue(0.5);
// Set the contrast mode to Linear
CEnumerationPtr(nodemap.GetNode("BslContrastMode"))->FromString("Linear");
// Set the Contrast parameter to 1.2
CFloatPtr(nodemap.GetNode("BslContrast"))->SetValue(1.2);
// Set the Brightness parameter to 0.5
camera.Parameters[PLCamera.BslBrightness].SetValue(0.5);
// Set the contrast mode to Linear
camera.Parameters[PLCamera.BslContrastMode].SetValue(PLCamera.BslContrastMode.Linear);
// Set the Contrast parameter to 1.2
camera.Parameters[PLCamera.BslContrast].SetValue(1.2);
// Set the Brightness parameter to 0.5
Pylon.DeviceSetFloatFeature(hdev, "BslBrightness", 0.5);
// Set the contrast mode to Linear
Pylon.DeviceFeatureFromString(hdev, "BslContrastMode", "Linear");
// Set the Contrast parameter to 1.2
Pylon.DeviceSetFloatFeature(hdev, "BslContrast", 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 Brightness parameter to 0.5 */
errRes = PylonDeviceSetFloatFeature(hdev, "BslBrightness", 0.5);
CHECK(errRes);
/* Set the contrast mode to Linear */
errRes = PylonDeviceFeatureFromString(hdev, "BslContrastMode", "Linear");
CHECK(errRes);
/* Set the Contrast parameter to 1.2 */
errRes = PylonDeviceSetFloatFeature(hdev, "BslContrast", 1.2);
CHECK(errRes);
You can also use the pylon Viewer to easily set the parameters.