跳转到内容

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.

该功能的使用#

运作原理#

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:

步骤 1 - 创建校正值 (CV)#

平场校正步骤 1

步骤 2 - 应用平场校正#

平场校正步骤 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).

然后用户必须计算校正值 (CV) 并将其保存到相机的闪存中。

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:暗场图像中所有像素的平均灰度值
  • GMean:明场图像中所有像素的平均灰度值
  • DSNU_Coeff(x): dark signal non-uniformity (DSNU) coefficient
  • PRNU_Coeff(x):光响应非均匀性 (PRNU) 系数
  • UserGD_Offset:用户定义的全局暗偏移

其中 x 是列索引。

信息

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.

要计算校正值:

  1. 保护传感器免受光线照射,例如,给镜头装上塑料盖,并拍摄一系列暗图像。
  2. 对所有拍摄的图像中所有像素的灰度值求和,并将总和除以像素总数。结果是暗场图像中所有像素的平均灰度值 (DMean)。
  3. 计算每列 x 的平均灰度值 (D(x))。
  4. Illuminate the sensor homogenously 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. 对所有拍摄的图像中所有像素的灰度值求和,并将总和除以像素总数。结果是明场图像中所有像素的平均灰度值 (GMean)。
  6. 计算每列 x 的平均灰度值 (G(x))。
  7. 如有必要,根据您的需要确定全局暗偏移值 (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. 使用计算值通过 pylon API 设置相应的相机参数。

    • 列索引 (x):BslFlatFieldCorrectionCoeffX
    • DMean:BslFlatFieldCorrectionDMean
    • DSNU_Coeff(x): BslFlatFieldCorrectionCoeffDSNU
    • PRNU_Coeff(x):BslFlatFieldCorrectionCoeffPRNU
    • UserGD_Offset:BslFlatFieldCorrectionUserGD
  10. 为所有列设置所有校正值后,您可以通过拍摄一组图像来测试平场校正。

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

设置平场校正模式#

要设置平场校正模式,请将 BslFlatFieldCorrectionMode 参数设置为以下值之一:

  • On: The camera performs flat-field correction, i.e., DSNU and PRNU corrections.
  • DSNUOnly: The camera performs DSNU correction only.
  • Off(默认值):相机执行平场校正。

示例代码#

// 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);

此示例代码仅适用于 C++ 语言。

您也可以使用 pylon Viewer 轻松设置参数。