Skip to content

Flat-Field Correction#

The Flat-Field Correction (FFC) camera feature is a calibration method that allows you to correct differences of light sensitivity between the pixels of a sensor.

Flat-field correction is performed using images with a uniform background. Then, the pixels of the acquired (raw) images are corrected so that the resulting output image is uniform.

Using the Feature#

How It Works#

On each sensor, pixels show variations in their brightness output, which results in image artifacts. This is a common effect in digital imaging and is due to production tolerances. Flat-field correction minimizes these image artifacts, thus improving image quality and subsequent analysis.

To remove image artifacts, you must first create correction data. The following diagram illustrates this process:

Step 1 – Creating Correction Values (CV)#

Flat-Field Correction Step 1

Step 2 – Applying Flat-Field Correction#

Flat-Field Correction Step 1

Step 1 requires a sequence of dark field images to detect the Fixed Pattern Noise (FPN) (dark current noise), and a sequence of bright field (flat field) images to detect the Photo Response Non-Uniformity (PRNU).

The correction values (CV) must then be calculated by the user and saved to the camera's flash memory.

In step 2, the image artifacts are removed, provided that the flat-field correction feature is enabled. The original pixel values (OV) are corrected so that an improved image (Resulting Values, RV) is achieved.

Calculating the Correction Values#

The Flat-Field Correction feature is column-based, i.e., for each column of the sensor, a correction value for the Fixed Pattern Noise (FPN) and a correction value for the Photo Response Non-Uniformity (PRNU) must be calculated during calibration. The following mathematical parameters are involved:

  • DMean: mean gray value of all pixels in the dark field image
  • GMean: mean gray value of all pixels in the bright field image
  • FPN_Coeff(x): fixed pattern noise (FPN) coefficient
  • PRNU_Coeff(x): photo response non-uniformity (PRNU) coefficient
  • UserGD_Offset: user-defined global dark offset

where x is the column index.

Info

For best results, acquire the dark and bright field images in your real application environment. Be aware that only static effects can be corrected. If you change, e.g., the lens or lighting, you must repeat this procedure.

To calculate the correction values:

  1. Protect the sensor from light, e.g., by placing a plastic cap on the lens, and acquire a sequence of dark images.
  2. Sum up the gray values of all pixels in all acquired images and divide the sum by the total number of pixels. The result is the mean gray value of all pixels in the dark field image (DMean).
  3. Calculate the mean gray value for each column x (D(x)).
  4. Illuminate the sensor homogenously to 70 % saturation, e.g., by placing a white sheet in the camera's entire field of view, and acquire a sequence of bright images.
  5. Sum up the gray values of all pixels in all acquired images and divide the sum by the total number of pixels. The result is the mean gray value of all pixels in the bright field image (GMean).
  6. Calculate the mean gray value for each column x (G(x)).
  7. If necessary, determine a global dark offset value according to your needs (UserGD_Offset).
  8. For each column x, calculate the coefficients FPN_Coeff(x) and PRNU_Coeff(x) as follows:

    FPN And PRNU Correction Formula

  9. Use the calculated values for setting the corresponding camera parameters via the pylon API.

    • Column index (x): BslFlatFieldCorrectionCoeffX
    • DMean: BslFlatFieldCorrectionDMean
    • FPN_Coeff(x): BslFlatFieldCorrectionCoeffFPN
    • PRNU_Coeff(x): BslFlatFieldCorrectionCoeffPRNU
    • UserGD_Offset: BslFlatFieldCorrectionUserGD
  10. After having set all correction values for all columns, you can test flat-field correction by acquiring a series of images.

  11. If you're satisfied with the image quality, save the settings to the camera's flash memory.

Setting the Flat-Field Correction Mode#

To set the flat-field correction mode, set the BslFlatFieldCorrectionMode parameter to one of the following values:

  • On: The camera performs flat-field correction, i.e., FPN and PRNU corrections.
  • FPNOnly: The camera performs the FPN correction only.
  • Off (default): The camera does not perform flat-field correction.

Sample Code#

// Example: Set all correction values for all columns
// Fixed pattern noise (FPN) coefficient
// CalculatedFPN[0..width-1]
// Photo response non-uniformity (PRNU) coefficient
// CalculatedPRNU[0..width-1]
for (x=0; ++x; x<width)
{
    camera.BslFlatFieldCorrectionCoeffX.SetValue(x);
    camera.BslFlatFieldCorrectionCoeffFPN.SetValue(CalculatedFPN[x]);
    camera.BslFlatFieldCorrectionCoeffPRNU.SetValue(CalculatedPRNU[x]);
}

// Set the global dark offset value
camera.BslFlatFieldCorrectionUserGD.SetValue(40)

// Save the settings to the camera's flash memory
camera.BslFlatFieldCorrectionSaveToFlash.Execute();

// Set the flat-field correction mode
camera.BslFlatFieldCorrectionMode.SetValue(BslFlatFieldCorrectionMode_On);

This sample code is only available in C++ language.

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