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

Pattern Removal Auto#

Pattern Removal Auto camera feature 可抑制單色影像上棋盤格圖案的產生。

使用此功能#

為什麼要使用 Pattern Removal Auto#

某些相機輸出的影像可能會顯示類似疊加棋盤格圖案的偽影。這是由特定的感光元件設計所引起的。只有在光線垂直於感光元件表面入射時,感光元件陣列中的任何 2 x 2 像素對光的反應才會完全相同。如果光線以斜角到達,它們的反應將會略有不同。這會在影像中造成棋盤格圖案。

您可以透過確保將適當的校正係數套用到原始像素值來抑制棋盤格圖案。校正係數會在每次影像擷取時自動套用。

Pattern Removal Auto 允許您確保校正係數的值適用於每次影像擷取。這些值僅在使用 Pattern Removal Auto 時存在的特定成像條件下有效。

Characteristics#

Pattern Removal Auto 自動功能在某些方面與其他自動功能不同:

  • 您不必指定 Auto Function ROI。
  • 您不必指定目標值。相反地,自動功能會產生校正係數值,以盡可能消除棋盤格圖案。
  • 僅提供 Once Operating Mode。

啟用並使用 Pattern Removal Auto#

若要使用 Pattern Removal Auto 自動功能:

  1. 將 Image ROI 設定為最大尺寸。
  2. 如果可能,請建立均勻的照明。
  3. 停用所有可能干擾校正值產生的相機功能,例如 Gain Auto、Exposure Auto 或 Sequencer。
  4. 根據需要調整相機設定(例如 Exposure Time、Black Level 和 Digital Shift)。為了獲得最佳效果,灰階值應在整個影像中保持均勻。
  5. 將 PatternRemovalAuto 參數設為 Once.
  6. 擷取 三張影像。確保目標場景在擷取之間沒有改變。
    相機會針對目前的成像條件產生並套用最佳校正值。此過程會立即發生,且不會影響相機的幀率。在第三次擷取後, PatternRemovalAuto 參數會自動設定為 Off.
  7. 如有必要,請恢復 Image ROI 的原始尺寸。

產生的校正值將一直適用,直到發生以下事件之一:

  • PatternRemovalAuto 且 Once.
  • 相機斷電。(為避免遺失校正值,請儲存校正值。)
  • 載入具有不同校正值的 user set。

重複 Pattern Removal Auto 流程#

當相關成像條件之一發生變更時,您應該重複 Pattern Removal Auto 流程。這可確保在變更的條件下仍能可靠地去除棋盤格圖案,且不會不必要地更改像素值。

相關的成像條件包括以下各項:

  • 光學系統:更換鏡頭、光圈或對焦。
  • 照明:更換照明類型、光源配置或亮度。
  • 功能設定:棋盤格圖案可能會受到多個相機功能設定的影響,特別是 Exposure Time、Binning、Image ROI、Black Level 和 Digital Shift。

儲存校正值#

如果相機斷電,由 Pattern Removal Auto 自動功能產生的校正值將會遺失。

不過,您可以將校正值儲存在 user set 中。每當您想要再次使用這些校正值時,都可以載入此 user set。

載入校正值時,請確保成像條件與產生校正值時完全相同。

範例程式碼#

// 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 來輕鬆設定參數。