Pattern Removal Auto#
该功能的使用#
为什么使用 Pattern Removal Auto#
部分相机输出的图像可能会显示出类似叠加棋盘格图案的伪影。这种现象源自特定的传感器设计。仅当入射光垂直于传感器表面时,传感器阵列中的任何 2 x 2 像素才会对光线产生相同的响应。如果光线以倾斜角度射入,它们的响应会略有不同。这会导致图像中出现棋盘格图案。
您可以通过确保将适当的校正系数应用于原始像素值来抑制棋盘格图案的出现。校正系数会在每次图像采集时自动应用。
Pattern Removal Auto 使您可以确保校正系数的值适合于每次图像采集。该值仅在使用了 Pattern Removal Auto 时出现特定成像条件的情况下生效。
特征#
自动功能 Pattern Removal Auto 在某些方面与其他自动功能有所不同:
- 您不必指定自动功能 ROI。
- 您不必指定目标值。自动功能会生成校正系数值,该校正系数值将尽可能消除棋盘格图案。
- 仅可以使用
Once
工作模式。
启用和使用 Pattern Removal Auto#
使用自动功能 Pattern Removal Auto:
- 将图像 ROI 设置为其最大尺寸。
- 如果可能,营造出均匀照明。
- 禁用所有可能影响校正值生成的功能,例如 Gain Auto、Exposure Auto 或 Sequencer。
- Adjust the camera settings (e.g., Exposure Time, Black Level, and Digital Shift) as desired. For best results, the gray values should be homogeneous across the image.
- 将
PatternRemovalAuto
参数设置为Once
。 - 采集三个图像。确保目标场景在多次采集之间不会发生变化。
相机会根据当前成像条件生成并应用最佳校正值。这是瞬间发生的,不会影响相机的帧速率。第三次采集后,PatternRemovalAuto
参数自动设置为Off
。 - 如有必要,恢复图像 ROI 的原始大小。
生成的校正值将一直应用到发生以下任一事件为止:
重复执行 Pattern Removal Auto 流程#
当相关的成像条件发生变化时,应重复执行 Pattern Removal Auto 流程。这能确保在条件改变的情况下仍能可靠地去除棋盘格图案,并且确保了像素值不会发生不必要的更改。
相关的成像条件如下:
- 光学系统:更改镜头、光圈或焦点。
- 照明:更改照明类型、光源布置或亮度。
- 功能设置:棋盘格图案可能会受到几种相机功能设置的影响,特别是Exposure Time、Binning、图像 ROI、Black Level 和 Digital Shift。
保存校正值#
如果相机断开电源,则自动功能 Pattern Removal Auto 生成的校正值将会丢失。
但是,您可以将校正值保存在用户设置集中。每当您想再次使用校正值时,都可以加载此用户设置集。
加载校正值时,请确保成像条件与生成校正值时的条件相同。
示例代码#
// Set the operating mode of the Pattern Removal Auto auto function to Once
camera.PatternRemovalAuto.SetValue(PatternRemovalAuto_Once);
// Acquire three images
// ...
// (Implement your own image grabbing routine here.
// For example, the InstantCamera class provides the StartGrabbing() method.)
// ...
// Save the correction values in User Set 1
camera.UserSetSelector.SetValue(UserSetSelector_UserSet1);
camera.UserSetSave.Execute();
INodeMap& nodemap = camera.GetNodeMap();
// Set the operating mode of the Pattern Removal Auto auto function to Once
CEnumParameter(nodemap, "PatternRemovalAuto").SetValue("Once");
// Acquire three images
// ...
// (Implement your own image grabbing routine here.
// For example, the InstantCamera class provides the StartGrabbing() method.)
// ...
// Save the correction values in User Set 1
CEnumParameter(nodemap, "UserSetSelector").SetValue("UserSet1");
CCommandParameter(nodemap, "UserSetSave").Execute();
// Set the operating mode of the Pattern Removal Auto auto function to Once
camera.Parameters[PLCamera.PatternRemovalAuto].SetValue(PLCamera.PatternRemovalAuto.Once);
// Acquire three images
// ...
// (Implement your own image grabbing routine here.
// For example, the InstantCamera class provides the StartGrabbing() method.)
// ...
// Save the correction values in User Set 1
camera.Parameters[PLCamera.UserSetSelector].SetValue(PLCamera.UserSetSelector.UserSet1);
camera.Parameters[PLCamera.UserSetSave].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 */
/* Set the operating mode of the Pattern Removal Auto auto function to Once */
errRes = PylonDeviceFeatureFromString(hdev, "PatternRemovalAuto", "Once");
CHECK(errRes);
/* Acquire three images */
/* ... */
/* (Implement your own image grabbing routine here. */
/* For example, the InstantCamera class provides the StartGrabbing() method.) */
/* ... */
/* Save the correction values in User Set 1 */
errRes = PylonDeviceFeatureFromString(hdev, "UserSetSelector", "UserSet1");
CHECK(errRes);
errRes = PylonDeviceExecuteCommandFeature(hdev, "UserSetSave");
CHECK(errRes);
# Set the operating mode of the Pattern Removal Auto auto function to Once
camera.PatternRemovalAuto.Value = "Once"
# Acquire three images
# ...
# (Implement your own image grabbing routine here.
# For example, the InstantCamera class provides the StartGrabbing() method.)
# ...
# Save the correction values in User Set 1
camera.UserSetSelector.Value = "UserSet1"
camera.UserSetSave.Execute()
您也可以使用 pylon Viewer 轻松设置参数。