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

Pixel Beyond#

Pixel Beyond 相機功能允許您降低相機輸出的影像解析度。

此功能與 Binning 功能類似,但允許更為細緻的解析度調整。

如需詳細資訊,請參閱 Basler 網站上的功能說明。

使用功能#

為什麼要使用 Pixel Beyond#

Pixel Beyond 功能的運作方式與 Binning 功能類似。相機會結合相鄰像素的像素值。這能有效降低解析度,同時不改變視野。

根據您的應用程式與影像感光元件的特性,這可能會帶來以下好處:

  • 提高對光的反應
  • 減少資料量
  • 提高幀率
  • 改善訊號雜訊比 (SNR)
  • 能夠模擬不同感光元件的解析度。這可讓您例如在不重新設計視覺系統的情況下,替換停產的感光元件。

雖然 Binning 功能僅允許您以整數級距降低解析度(例如使用 2x2 或 3x3 Binning),但 Pixel Beyond 功能可讓您使用浮點數 Scaling 值來調整解析度。這提供了更大的靈活性。

此外,不同於其他 Scaling 演算法,所得影像的 EMVA data 不會受到插補的影響。

設定 Pixel Beyond#

若要設定 Pixel Beyond:

  1. 確保相機處於閒置狀態,即未擷取影像。
  2. 如果您的相機是彩色相機,請將 Pixel Format 設定為非 Bayer 彩色 Pixel Format,即可用 RGB、BGR 或 YUV Pixel Format 之一。
  3. 將相機中的 BslScalingFactor 將參數設為 1.0 到 2.8 之間的數值。

當係數為 1.0 時,影像解析度保持不變。大於 1.0 的係數會按比例縮小影像的寬度和高度:

  • Width * (1 / BslScalingFactor) = 縮放寬度
  • Height * (1 / BslScalingFactor) = 縮放高度

範例:假設影像 ROI的寬度設定為 1936,且您將縮放係數設定為 1.75。相機輸出的影像寬度將為 1936 * (1 / 1.75) = 1106。

資訊

根據相機型號的不同,數值的四捨五入方式亦有所不同。因此,實際影像尺寸可能與計算出的影像尺寸有所差異。

計算 Scaling 因素#

影像大小#

若您想將圖片縮放至特定尺寸,且需要知道縮放係數,請使用以下公式:

Width / 所需寬度 = BslScalingFactor

由於 Scaling 總是按比例執行,因此您只需指定寬度。

範例:假設 Image ROI 為 1936 x 1216,而您想將影像縮放到 800 x 600。適當的 Scaling 係數為 1936 / 800 = 2.42。

Pixel Size#

如果您想用具有特定 Pixel Size 的感光元件替換已停產的感光元件,並且需要知道 Scaling 係數,請使用以下公式:

Previous Sensor Pixel Size / Current Sensor Pixel Size = BslScalingFactor

範例:假設您想用 a2A1920-51gcPRO 的 IMX392 感光元件(Pixel Size 3.45 µm)替換 Pixel Size 為 7.4 µm 的 ICX424 感光元件。適當的 Scaling 係數為 7.4 / 3.45 = 2.14。

範例程式碼#

// Set scaling to 1.5, i.e., set the resolution
// to (1 / 1.5) = 66 % of the original resolution
camera.BslScalingFactor.SetValue(1.5);
// Disable scaling
camera.BslScalingFactor.SetValue(1.0);
INodeMap& nodemap = camera.GetNodeMap();
// Set scaling to 1.5, i.e., set the resolution
// to (1 / 1.5) = 66 % of the original resolution
CFloatParameter(nodemap, "BslScalingFactor").SetValue(1.5);
// Disable scaling
CFloatParameter(nodemap, "BslScalingFactor").SetValue(1.0);
// Set scaling to 1.5, i.e., set the resolution
// to (1 / 1.5) = 66 % of the original resolution
camera.Parameters[PLCamera.BslScalingFactor].SetValue(1.5);
// Disable scaling
camera.Parameters[PLCamera.BslScalingFactor].SetValue(1.0);
/* 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 scaling to 1.5, i.e., set the resolution */
/* to (1 / 1.5) = 66 % of the original resolution */
errRes = PylonDeviceSetFloatFeature(hdev, "BslScalingFactor", 1.5);
CHECK(errRes);
/* Disable scaling */
errRes = PylonDeviceSetFloatFeature(hdev, "BslScalingFactor", 1.0);
CHECK(errRes);
# Set scaling to 1.5, i.e., set the resolution
# to (1 / 1.5) = 66 % of the original resolution
camera.BslScalingFactor.Value = 1.5
# Disable scaling
camera.BslScalingFactor.Value = 1.0

您也可以 use the pylon Viewer 來輕鬆設定參數。