跳转到内容

Vignetting Correction#

相机的 Vignetting Correction 功能可让您从图像中消除暗角伪影。

此功能与 pylon Viewer 中的 Vignetting Correction 功能共同发挥作用。

该功能的使用#

渐晕是指图像的边角与中心相比变暗。这是数字成像中的常见效果,而当传感器边缘的像素没有接收到足够的光线时就会发生这种情况。

出现这种情况的原因可能是相对于传感器大小来说,像圈太小了,或者因为光线不会像在传感器中心那样以直角射入传感器。这意味着边缘像素的灰度值较低。

要消除这些伪影,您必须使用 pylon Viewer 创建一组校正数据。下图展示了此过程:

Vignetting Correction 流程图

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.

信息

  • 为了获得最佳结果,请在创建校正数据之前禁用所有非线性功能,例如光源预设或 Gamma 校正。之后,您可以再次启用这些功能。
  • 在彩色相机上,在创建校正数据之前选择 Bayer 像素格式。创建校正数据后,您可以选择任何像素格式。
  • 执行 vignetting correction 时,重要的是,生成的参考图像仅显示相对于中心中等程度的拐角变暗效果。
  • 渐晕受所用镜头、光圈和焦距的影响。如果更换镜头、光圈或焦距,则必须创建一组新的 vignetting correction 数据。
  • Changing the binning factor while the BinningSelector parameter is set to 传感器 will disable vignetting correction. The VignettingCorrectionMode parameter will be set to 熄灭, and you won't be able to turn it on again until one of the following happens:

    • 您可以将 Binning 系数重置为执行 Vignetting Correction 的系数。
    • 您使用新系数再次执行 Vignetting Correction。

示例代码#

ace 2 和 boost R 相机#
// 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()
其他相机#
// 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()

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