跳转到内容
暂存服务器
开发服务器

Demosaicing Mode#

通过 Demosaicing Mode 相机功能,您可以更改用于 去马赛克 的方法。

这有助于优化图像质量。

信息

此功能适用于 Basler ace 2、boost R 和 dart R 相机。

Basler ace U/L 相机还提供一个 DemosaicingMode 参数,但该参数仅用于启用 PGI Feature Set.

该功能的使用#

为什么要使用 Demosaicing Mode#

去马赛克(也称为去拜耳)用于从图像传感器的彩色输出中生成 RGB 信息。

Basler 彩色相机始终执行去马赛克,即使像素格式设置为 Bayer 格式也是如此。这是由相机的内部图像处理决定的。

您的相机提供用于去马赛克的 不同方法。默认情况下,该方法根据设置的 Pixel Format 自动确定。

如果自动选择的方法产生的结果无法满足您的应用要求,手动调整 Demosaicing Mode 会有所帮助。

例如,相机针对 Bayer 像素格式自动选择 Nearest Neighbor 方法。这样做是为了确保与旧固件版本的兼容性。然而,Unilinear 方法通常能取得更好的结果。

Demosaicing 方法#

提供以下去马赛克方法:

去马赛克方法 描述 适用于非 Bayer 像素格式 适用于 Bayer 像素格式
Average Green 使用来自最近像素之一的信息或周围绿色像素的 Arithmetic 平均值。如果 Basler PGI 不可用,这是非 Bayer 像素格式的默认方法。
Basler PGI 如果可用,使用 Basler PGI 算法进行高级去马赛克。
Nearest Neighbor 使用来自最近像素之一的信息。这是 Bayer 像素格式的默认方法,并可确保与以前的固件版本具有最佳兼容性。
Unilinear 使用来自最近像素之一的信息或周围像素的 Arithmetic 平均值。与 Nearest Neighbor 去马赛克相比,边缘产生的色彩伪影更少。

Demosaicing Modes#

提供以下 Demosaicing Mode:

  • Auto: 根据设置的 Pixel Format 自动确定去马赛克方法。
  • Manual:可以手动设置去马赛克方法。

配置 Demosaicing#

要更改用于去马赛克的算法:

  1. 设置 BslDemosaicingMode 将参数设置为 Manual.
  2. 设置 BslDemosaicingMethod 将参数设置为所需的 去马赛克方法,例如 Unilinear.

示例代码#

// Enable manual adjustment of the demosaicing method
camera.BslDemosaicingMode.SetValue(BslDemosaicingMode_Manual);
// Set the demosaicing method to Unilinear
camera.BslDemosaicingMethod.SetValue(BslDemosaicingMethod_Unilinear);
INodeMap& nodemap = camera.GetNodeMap();
// Enable manual adjustment of the demosaicing method
CEnumParameter(nodemap, "BslDemosaicingMode").SetValue("Manual");
// Set the demosaicing method to Unilinear
CEnumParameter(nodemap, "BslDemosaicingMethod").SetValue("Unilinear");
// Enable manual adjustment of the demosaicing method
camera.Parameters[PLCamera.BslDemosaicingMode].SetValue(PLCamera.BslDemosaicingMode.Manual);
// Set the demosaicing method to Unilinear
camera.Parameters[PLCamera.BslDemosaicingMethod].SetValue(PLCamera.BslDemosaicingMethod.Unilinear);
/* 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 */
/* Enable manual adjustment of the demosaicing method */
errRes = PylonDeviceFeatureFromString(hdev, "BslDemosaicingMode", "Manual");
CHECK(errRes);
/* Set the demosaicing method to Unilinear */
errRes = PylonDeviceFeatureFromString(hdev, "BslDemosaicingMethod", "Unilinear");
CHECK(errRes);
# Enable manual adjustment of the demosaicing method
camera.BslDemosaicingMode.Value = "Manual"
# Set the demosaicing method to Unilinear
camera.BslDemosaicingMethod.Value = "Unilinear"

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