Skip to content

Flat-Field Correction#

The Flat-Field Correction (FFC) camera feature allows you to remove non-uniformities in the image caused by differing light sensitivities of the sensor pixels.

Before flat-field correction can be applied, the camera needs to be calibrated. This involves calculating appropriate correction data and uploading these to the camera. With this, the original pixels can be corrected during image acquisition resulting in an improved image.

This feature is complemented by the Flat-Field Correction (pylon Viewer) feature.

Using the Feature#

How It Works#

Every sensor's pixels vary slightly in their brightness output resulting in image artifacts. This is a common effect in digital imaging. 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 dark signal non-uniformities (DSNU) (dark current noise) and a sequence of bright field (flat field) images to detect photo response non-uniformities (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 resulting in an improved image (Resulting Values, RV).

Calculating the Correction Values Using the pylon Viewer#

→ See Flat-Field Correction (pylon Viewer).

Calculating the Correction Values Using the pylon API#

The Flat-Field Correction feature is column-based, i.e., for each column of the sensor, a correction value for Dark Signal Non-Uniformity (DSNU) and a correction value for 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
  • DSNU_Coeff(x): dark signal non-uniformity (DSNU) 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 actual 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 homogeneously to 70 % saturation, e.g., by placing a white sheet of paper 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 DSNU_Coeff(x) and PRNU_Coeff(x) as follows:

    DSNU 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
    • DSNU_Coeff(x): BslFlatFieldCorrectionCoeffDSNU
    • 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 by executing the BslFlatFieldCorrectionSaveToFlash command.

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., DSNU and PRNU corrections.
  • DSNUOnly: The camera performs DSNU correction only.
  • Off (default): The camera does not perform flat-field correction.

Sample Code#

// Example: Set all correction values for all columns
// Dark signal non-uniformity (DSNU) coefficient
// CalculatedDSNU[0..width-1]
// Photo response non-uniformity (PRNU) coefficient
// CalculatedPRNU[0..width-1]
for (x=0; ++x; x<width)
{
    camera.BslFlatFieldCorrectionCoeffX.SetValue(x);
    camera.BslFlatFieldCorrectionCoeffDSNU.SetValue(CalculatedDSNU[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.