跳至內容
測試伺服器
開發伺服器

Demosaicing Mode#

透過 Demosaicing Mode camera feature,您可以變更用於 demosaicing 的方法。

這有助於最佳化影像 Quality。

資訊

此功能適用於 Basler ace 2、boost R 和 dart R 相機。

Basler ace U/L 相機也提供 DemosaicingMode 參數,但這僅用於啟用 PGI 集.

使用此功能#

為什麼要使用 Demosaicing Mode#

Demosaicing(也稱為 debayering)是為了從影像感光元件的色彩輸出產生 RGB 資訊而執行的。

Basler 彩色相機一律會執行 demosaicing,即使 Pixel Format 設定為 Bayer 格式也是如此。這是由於相機內部的影像處理所致。

您的相機提供不同的方法來進行 demosaicing。預設情況下,該方法會根據所設定的 Pixel Format 自動決定。

如果您對自動選擇的方法所產生的結果不滿意,手動調整 demosaicing mode 將會有所幫助。

例如,相機針對 Bayer Pixel Format 會自動選擇 Nearest Neighbor 方法。這樣做是為了確保與舊版韌體相容。然而,Unilinear 方法通常能達到更好的結果。

去馬賽克方法#

提供以下 demosaicing 方法:

Demosaicing Method 描述 適用於非 Bayer Pixel Format 適用於 Bayer Pixel Format
Average Green 使用來自其中一個最接近像素或周圍綠色像素的 Arithmetic 平均值之資訊。如果無法使用 Basler PGI,這是非 Bayer Pixel Format 的預設方法。
Basler PGI 如果可用,則使用 Basler PGI 演算法進行進階 demosaicing。
Nearest Neighbor 使用來自其中一個最接近像素的資訊。這是 Bayer Pixel Format 的預設方法,並提供與先前韌體版本最佳的相容性。
Unilinear 使用來自其中一個最接近像素或周圍像素的 Arithmetic 平均值之資訊。相較於 Nearest Neighbor demosaicing,邊緣產生的色彩偽影較少。

Demosaicing Modes#

提供以下 demosaicing mode:

  • Auto:Demosaicing 方法會根據所設定的 Pixel Format 自動決定。
  • Manual:Demosaicing 方法可以手動設定。

設定 Demosaicing#

若要變更用於 demosaicing 的方法:

  1. 將 BslDemosaicingMode 參數設為 Manual.
  2. 將 BslDemosaicingMethod 參數設為所需的 demosaicing method,例如 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 來輕鬆設定參數。