Brightness and Contrast (dart E)#
Brightness 和 contrast 始終作為共同數學 Brightness/Contrast 函數的一部分進行處理。
使用此功能#
調整對比度#
若要調整對比度,請輸入下列項目的值: BslContrast Property 輸入一個值。該 Property 的值範圍為 -1 到 1。依預設,該 Property 設定為 0,表示 contrast 保持不變。
調整 Brightness#
若要調整 brightness,請為 BslBrightness Property 輸入一個值。該 Property 的值範圍為 -1 到 1。依預設,該 Property 設定為 0,表示 brightness 保持不變。
運作原理#
Contrast#
調整 contrast 會改變影像中明亮區域與黑暗區域之間的差異程度。套用的 contrast 越多,差異就會越明顯。
相機會使用 S 曲線函數來調整對比度。
這可讓您在保持影像 dynamic range 的同時,改善所感受到的 contrast。
您增加越多 contrast,該函數的圖表就會越呈 S 形:
上圖顯示在 S-Curve 模式下增加 contrast 會產生以下效果:
- S 形曲線在其起點和終點附近變得更平緩,而在中心附近變得更陡峭。因此,影像明亮和黑暗區域的 contrast 會降低,而中間色調的 contrast 會增加。
- 低的輸入像素值會降低,高的輸入像素值會升高。因此,影像中極端黑暗和明亮的區域會被壓縮,這進一步改善了所感受到的 contrast。
- 由於曲線始終從 (0,0) 開始並在 (Xmax,Ymax) 結束,因此圖像的動態範圍得以保留。
在 S-Curve 模式下,低於 0 的 Contrast 設定將導致相反效果的反向 S 曲線。
Brightness#
透過增加或減少色調值,調整 Brightness 可讓您使圖像變亮或變暗。
調整 Brightness 會移動 Brightness/Contrast 功能的樞紐點:
- 增加 Brightness 會將樞紐點向左上方移動。這意味著圖像會顯得更亮。
- 減少 Brightness 會將樞紐點向右下方移動。這意味著圖像會顯得更暗。
範例程式碼#
/* 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 Brightness parameter to 0.5 */
errRes = PylonDeviceSetFloatFeature(hdev, "BslBrightness", 0.5);
CHECK(errRes);
/* Set the Contrast parameter to 1.2 */
errRes = PylonDeviceSetFloatFeature(hdev, "BslContrast", 1.2);
CHECK(errRes);
/* 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 Brightness parameter to 0.5 */
errRes = PylonDeviceSetFloatFeature(hdev, "BslBrightness", 0.5);
CHECK(errRes);
/* Set the Contrast parameter to 1.2 */
errRes = PylonDeviceSetFloatFeature(hdev, "BslContrast", 1.2);
CHECK(errRes);
您也可以使用 pylon Viewer 輕鬆設定參數。