Skip to content

Vignetting Correction#

The Vignetting Correction camera feature allows you to remove vignetting artifacts from your images.

This feature works in conjunction with the Vignetting Correction feature in the pylon Viewer.

Using the Feature#

Vignetting means a darkening of the corners of an image compared to its center. It is a common effect in digital imaging and occurs when the pixels at the edges of the sensor don't receive sufficient light.

This can happen, e.g., because the image circle is too small in relation to the size of the sensor or because the light rays don't hit the sensor at right angles like they do at the center of the sensor. This means that the pixels at the edges have lower gray values.

To remove these artifacts, you have to create a set of correction data using the pylon Viewer. The following diagram illustrates this process:

Vignetting Correction Process Diagram

In step 1, correction values (CV) for all pixels are calculated and saved in the camera's memory. In step 2, the vignetting artifacts are removed immediately if the VignettingCorrectionMode parameter is enabled. To remove the artifacts, the correction values are multiplied with the original pixel values (OV) to achieve an improved image (Resulting Values, RV).

Using the VignettingCorrectionMode parameter, you can turn the correction on and off. This parameter will only be available after you have created vignetting correction data using the pylon Viewer.

You can also use vignetting correction data from a different camera if your camera has similar specifications as the one on which you created the vignetting correction data. To do so, follow these steps. Afterwards, execute the VignettingCorrectionLoad command.

Info

  • For best results, disable all non-linear features, e.g., light source presets or gamma, before creating the correction data. Afterwards, you can enable them again.
  • On color cameras, select a Bayer pixel format before creating the correction data. Once you have created the correction data, you can select any pixel format.
  • When performing vignetting correction, it is important that the generated reference image shows only a moderate darkening of the corners compared to its center.
  • Vignetting is influenced by the lens used, the aperture, and the focal length. If you change the lens, the aperture, or the focal length, you must create a new set of vignetting correction data.
  • Changing the binning factor while the BinningSelector parameter is set to Sensor will disable vignetting correction. The VignettingCorrectionMode parameter will be set to Off, and you won't be able to turn it on again until one of the following happens:

    • You reset the binning factor to the factor that you performed vignetting correction with.
    • You perform vignetting correction again with the new factor.

Sample Code#

ace 2 and boost R Cameras#
// Turn vignetting correction on
camera.BslVignettingCorrectionMode.SetValue(BslVignettingCorrectionMode_On);
// Load vignetting correction data
camera.BslVignettingCorrectionLoad.Execute();
INodeMap& nodemap = camera.GetNodeMap();
// Turn vignetting correction on
CEnumParameter(nodemap, "BslVignettingCorrectionMode").SetValue("On");
// Load vignetting correction data
CCommandParameter(nodemap, "BslVignettingCorrectionLoad").Execute();
// Turn vignetting correction on
camera.Parameters[PLCamera.BslVignettingCorrectionMode].SetValue(PLCamera.BslVignettingCorrectionMode.On);
// Load vignetting correction data
camera.Parameters[PLCamera.BslVignettingCorrectionLoad].Execute();
/* 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 */
/* Turn vignetting correction on */
errRes = PylonDeviceFeatureFromString(hdev, "BslVignettingCorrectionMode", "On");
CHECK(errRes);
/* Load vignetting correction data */
errRes = PylonDeviceExecuteCommandFeature(hdev, "BslVignettingCorrectionLoad");
CHECK(errRes);
# Turn vignetting correction on
camera.BslVignettingCorrectionMode.Value = "On"
# Load vignetting correction data
camera.BslVignettingCorrectionLoad.Execute()
Other Cameras#
// Turn vignetting correction on
camera.VignettingCorrectionMode.SetValue(VignettingCorrectionMode_On);
// Load vignetting correction data
camera.VignettingCorrectionLoad.Execute();
INodeMap& nodemap = camera.GetNodeMap();
// Turn vignetting correction on
CEnumParameter(nodemap, "VignettingCorrectionMode").SetValue("On");
// Load vignetting correction data
CCommandParameter(nodemap, "VignettingCorrectionLoad").Execute();
// Turn vignetting correction on
camera.Parameters[PLCamera.VignettingCorrectionMode].SetValue(PLCamera.VignettingCorrectionMode.On);
// Load vignetting correction data
camera.Parameters[PLCamera.VignettingCorrectionLoad].Execute();
/* 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 */
/* Turn vignetting correction on */
errRes = PylonDeviceFeatureFromString(hdev, "VignettingCorrectionMode", "On");
CHECK(errRes);
/* Load vignetting correction data */
errRes = PylonDeviceExecuteCommandFeature(hdev, "VignettingCorrectionLoad");
CHECK(errRes);
# Turn vignetting correction on
camera.VignettingCorrectionMode.Value = "On"
# Load vignetting correction data
camera.VignettingCorrectionLoad.Execute()

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