跳转到内容

Demosaicing Mode#

Demosaicing Mode 相机功能允许您更改用于去马赛克的方法。

这有助于优化图像质量。

信息

This feature is available for Basler ace 2, boost R, and dart R cameras.

Basler ace U/L cameras also provide a DemosaicingMode parameter but this only serves to enable the PGI Feature Set.

该功能的使用#

为什么使用 Demosaicing Mode#

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

Basler 彩色相机始终执行去马赛克,即使 Pixel Format 设置为拜耳格式也是如此。这是由于相机的内部图像处理造成的。

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

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

例如,相机会自动为拜耳 Pixel Format 选择最近邻方法。这样做是为了确保与较旧固件版本的兼容性。然而,Unilinear 方法通常可以获得更好的结果。

去马赛克方法#

可以使用以下去马赛克方法:

去马赛克方法 描述 适用于非拜耳 Pixel Format 适用于拜耳 Pixel Format
平均绿色值 使用来自最近像素之一的信息或周围绿色像素的算术平均值。如果 Basler PGI 不可用,这是非拜耳 Pixel Format 的默认方法。
Basler PGI 如果可用,则使用 Basler PGI 高级去马赛克算法。
最近邻 使用来自最近像素之一的信息。这是拜耳 Pixel Format 的默认方法,并提供与以前的固件版本的最佳兼容性。
Unilinear 使用来自最近像素之一的信息或周围像素的算术平均值。与最近邻去马赛克相比,边缘处出现的颜色伪影较少。

Demosaicing Mode#

可以使用以下 Demosaicing Mode:

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

配置去马赛克功能#

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

  1. Set the BslDemosaicingMode parameter to Manual.
  2. Set the BslDemosaicingMethod parameter to the desired demosaicing method, e.g., 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 轻松设置参数。