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

Gamma (dart E)#

透過 Gamma camera feature,您可以最佳化所擷取影像的亮度,以便在顯示器上檢視。

使用此功能#

運作原理#

相機會根據下列公式,將 Gamma 校正值 ($\gamma$) 套用到每個像素的亮度值(此處以彩色相機的紅色像素值 (R) 為例):

Gamma Correction Formula (Red Pixels)

最大像素值 ($R_{max}$)(例如 8 位元 Pixel Format 為 255,或 10 位元 pixel format 為 1 023)。

設定 Gamma 矯正#

若要設定 Gamma 矯正,請將 Gamma 參數設定為所需的值。該參數的值範圍為 0 到 ≈4。- Gamma = 1:整體亮度保持 不變。- Gamma < 1:整體亮度 增加。- Gamma > 1:整體亮度 減少.

在所有情況下,黑色像素(亮度 = 0)和白色像素(亮度 = 最大值)都不會進行調整。

資訊

如果您啟用 gamma correction 且 Pixel Format 設為 12 位元 pixel format,將會遺失部分影像資訊。像素資料輸出仍會是 12 位元,但在 gamma correction 處理過程中,會對像素值進行內插處理。

設定色彩空間#

在 daA…mci 相機模組上,提供 BslColorSpace 參數。它允許您選擇以下其中一種 Gamma 矯正模式:

  • RGB:不套用額外的 gamma correction 值。
  • sRGB:針對在 sRGB 顯示器上顯示最佳化影像亮度。套用大約 0.4 的 Gamma 矯正值, Gamma 參數將變為唯讀,且 Gamma 參數值將被忽略。

範例程式碼#

// Set the Gamma value to 1.2
camera.Gamma.SetValue(1.2);
INodeMap& nodemap = camera.GetNodeMap();
// Set the Gamma value to 1.2
CFloatParameter(nodemap, "Gamma").SetValue(1.2);
// Set the Gamma value to 1.2
camera.Parameters[PLCamera.Gamma].SetValue(1.2);
/* 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 Gamma value to 1.2 */
errRes = PylonDeviceSetFloatFeature(hdev, "Gamma", 1.2);
CHECK(errRes);
# Set the Gamma value to 1.2
camera.Gamma.Value = 1.2
/* 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 Gamma value to 1.2 */
errRes = PylonDeviceSetFloatFeature(hdev, "Gamma", 1.2);
CHECK(errRes);

您也可以使用 pylon Viewer 輕鬆設定參數。