跳转到内容

Flat-Field Correction#

Flat-Field Correction (FFC) 相机功能可以消除因传感器像素的感光度差异而引起的图像非均匀性。

在应用平场校正之前,需要对相机进行校准。这涉及计算适当的校正数据并将其上传到相机中。借助这些校正数据,就可以在图像采集过程中对原始像素进行校正,从而获得经改进的图像。

Flat-Field Correction ( pylon Viewer) 功能对该功能进行了补充。

该功能的使用#

运作原理#

每个传感器的像素在亮度输出上都有轻微差异,因此会导致图像出现伪影。这是数字成像中的常见现象。平场校正可最大限度地减少这些图像伪影,从而提高图像质量和后续分析。

要消除图像伪影,您必须首先创建校正数据。下图展示了此校正过程:

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

平场校正步骤 1

步骤 2 - 应用平场校正#

平场校正步骤 1

步骤 1 需要一系列暗场图像来检测暗信号非均匀性 (DSNU)(暗电流噪声),以及一系列明场(平场)图像来检测光响应非均匀性 (PRNU)

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

在步骤 2 中,如果启用了平场校正功能,则会消除图像伪影。原始像素值 (OV) 得到了校正,从而得到经改进的图像(结果值,RV)。

使用 pylon Viewer 计算校正值#

→ 请参见 Flat-Field Correction (pylon Viewer)

使用 pylon API 计算校正值#

Flat-Field Correction 功能以列为基础,即在校准期间必须针对传感器的每一列计算暗信号非均匀性 (DSNU) 的校正值和光响应非均匀性 (PRNU) 的校正值,其中涉及以下数学参数:

  • DMean:暗场图像中所有像素的平均灰度值
  • GMean:明场图像中所有像素的平均灰度值
  • DSNU_Coeff(x):暗信号非均匀性 (DSNU) 系数
  • PRNU_Coeff(x):光响应非均匀性 (PRNU) 系数
  • UserGD_Offset:用户定义的全局暗偏移

其中 x 是列索引。

信息

为了获得最佳结果,请在实际应用环境中获取暗场和明场图像。请注意,只能校正静态效果。如果更改镜头或光源等,则必须重复此过程。

要计算校正值:

  1. 保护传感器免受光线照射,例如,给镜头装上塑料盖,并拍摄一系列暗图像。
  2. 对所有拍摄的图像中所有像素的灰度值求和,并将总和除以像素总数。结果是暗场图像中所有像素的平均灰度值 (DMean)。
  3. 计算每列 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. 对所有拍摄的图像中所有像素的灰度值求和,并将总和除以像素总数。结果是明场图像中所有像素的平均灰度值 (GMean)。
  6. 计算每列 x 的平均灰度值 (G(x))。
  7. 如有必要,根据您的需要确定全局暗偏移值 (UserGD_Offset)。
  8. 对于每一列 x,计算 DSNU_Coeff(x) 系数和 PRNU_Coeff(x) 系数,如下所示:

    DSNU 和 PRNU 校正公式

  9. 使用计算值通过 pylon API 设置相应的相机参数。

    • Column index (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.

设置平场校正模式#

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.

示例代码#

// 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 轻松设置参数。