コンテンツにスキップ

Tonal Range#

Tonal Rangeカメラ機能を使用すると、コントラストを手動で調整したり、カラーシフトを修正したりできます。

この機能を使用するには、色調範囲画像ヒストグラムの概念を理解している必要があります。

色調範囲を自動的に調整する場合は、Tonal Range Auto機能を使用します。

リニアまたはSカーブ関数を使用してコントラストを調整する場合は、Brightness and Contrast機能を使用します(使用可能な場合)。

機能を使用する#

Adjusting the Contrast#

情報

Baslerは、Tonal Range Auto機能を最初に使用することをお勧めします。その後、以下の手順に従ってコントラストを微調整できます。

コントラストを手動で調整するには、次の手順に従います。

  1. カメラがすでに良好な画像を生成しており、低コントラストシフトカラーの問題だけが残っていることを確認します。色調範囲の操作は、既に良好な画質を持つ画像に対してのみ実行してください。
    画質を最適化する場合は、以下の手順に従います。
  2. Set the TonalRangeEnable parameter to On.
  3. Set the TonalRangeSelector parameter to Sum.
  4. Set the TonalRangeSourceDark and TonalRangeTargetDark parameters to the dark source and target values.
    If the dark target value is lower than the dark source value, contrast is increased.
  5. Set the TonalRangeSourceBright and TonalRangeTargetBright parameters to the bright source and target values.
    If the bright target value is greater than the bright source value, contrast is increased.

Correcting Color Shifts#

情報

Baslerは、Tonal Range Auto機能を最初に使用することをお勧めします。その後、以下の手順に従ってカラー補正を微調整できます。

カラーシフトを手動で修正するには:

  1. カメラがすでに良好な画像を生成しており、低コントラストシフトカラーの問題だけが残っていることを確認します。色調範囲の操作は、既に良好な画質を持つ画像に対してのみ実行してください。
    画質を最適化する場合は、以下の手順に従います。
  2. Set the TonalRangeEnable parameter to On.
  3. Set the TonalRangeSelector parameter to Red, Green, or Blue, depending on the color shift you want to correct.
    Example: If your images have a green cast, set the parameter to Green.
  4. Set the TonalRangeSourceDark, TonalRangeTargetDark, TonalRangeSourceBright, and TonalRangeTargetBright parameters to source and target values that align the current histogram with the other histograms.

Image Optimization Sequence#

画質を最適化する場合は、次の手順に従って副作用を回避します。

  1. 基本的な画像最適化には、Exposure TimeBlack LevelおよびGainの機能を使用します。画像が色飽和しないようにしてください。
  2. カラーカメラを使用している場合は、Light Source PresetBalance White Auto、またはBalance White機能を使用してホワイトバランスを調整します。
  3. Tonal Range AutoおよびTonal Range機能を使用して、コントラスト、カラー、またはその両方を最適化します。

仕組み#

色調範囲の操作は、画像内の色調分布のグラフィック表現(画像ヒストグラム)を見ることで最もよく理解できます。

Basler pylon ViewerにはHistogramペインがあり、色調範囲の操作を実行するときに非常に便利です。

情報

カメラで有効になっている他の機能によっては、pylon ViewerのHistogramペインでは、Tonal Range機能が実際に使用するデータが表示されない場合があります
例えば、Gamma機能は、色調範囲の操作後に処理されます。その結果、ガンマ補正は、pylon Viewerに表示されるヒストグラムに含まれますが、Tonal Range機能で使用するデータには含まれません。

Source and Target Values#

コントラストとカラーの調整は、ソース値をターゲット値にマッピングするのと同じ概念に基づいて行われます。

これを説明するには、ヒストグラムでソース値を「アンカー」と考え、ターゲット値をアンカーの移動先のポイントと考えます。

Source and Target Values Illustration

ソース値がターゲット値にマッピングされると、ヒストグラム全体がそれに応じてスプレッドまたはストレッチされます。

Histogram Stretching Animation

Dark/Bright Source and Target Values#

上図に示すように、色調範囲操作を実行するには、ソース値とターゲット値の2つのセットを定義する必要があります。

  • Dark source and target values, located at the lower end of the histogram.
    You specify these values using the TonalRangeSourceDark and TonalRangeTargetDark parameters.
  • Bright source and target values, located at the upper end of the histogram.
    You specify these values using the TonalRangeSourceBright and TonalRangeTargetBright parameters.

すべてのソース値とターゲット値の範囲は、0~最大ピクセル値です(例えば、12ビットピクセルフォーマットが設定されている場合は4095)。ヒストグラムのストレッチとスプレッドの程度が制限されているために、パラメーター範囲も制限される場合があります。

Contrast Adjustment (Mono and Color Cameras)#

Tonal Range機能をサポートするすべてのカメラで、この機能を使用してコントラストを調整できます。

低コントラスト画像の色調範囲は狭いです。

Narrow Tonal Range Example

Tonal Range機能を使用すると、色調範囲を手動で広げてコントラストを上げることができます。

Wide Tonal Range Example

色調範囲を広げるには、暗さのソース値を低いターゲット値に、明るさのソース値を高いターゲット値にマッピングします。

両ソース値の間の領域は、中間調(画像に不可欠と考えられるピクセル値)を定義します。

このプロセスを自動化するには、Tonal Range Auto機能を使用します。

Color Correction(カラーカメラのみ)#

Tonal Range機能をサポートするカラーカメラでは、この機能を使用してカラーシフトを修正することもできます。

画像内のカラーがシフトされると、3つのRGB(赤、緑、青)ヒストグラムが整列されずに表示されます。例えば、画像に赤のキャストがある場合、赤のヒストグラムは緑と青のヒストグラムよりも右側に表示されます(以下の例を参照)。

Tonal Range機能を使用すると、RGBヒストグラムを手動で調整して、カラーシフトを低減することができます。

RGB Histogram Alignment Animation

RGBヒストグラムは、ソース値とターゲット値を設定して、すべてのヒストグラムがストレッチし、同様の開始点と終了点に移動するように調整できます。

このプロセスを自動化するには、Tonal Range Auto機能を使用します。

サンプルコード#

// Enable tonal range adjustments
camera.TonalRangeEnable.SetValue(TonalRangeEnable_On);
// Specify that the summed RGB pixel values are used for tonal range adjustments
camera.TonalRangeSelector.SetValue(TonalRangeSelector_Sum);
// Set the dark source and target values
camera.TonalRangeSourceDark.SetValue(30);
camera.TonalRangeTargetDark.SetValue(0);
// Set the bright source and target values
camera.TonalRangeSourceBright.SetValue(240);
camera.TonalRangeTargetBright.SetValue(255);
INodeMap& nodemap = camera.GetNodeMap();
// Enable tonal range adjustments
CEnumParameter(nodemap, "TonalRangeEnable").SetValue("On");
// Specify that the summed RGB pixel values are used for tonal range adjustments
CEnumParameter(nodemap, "TonalRangeSelector").SetValue("Sum");
// Set the dark source and target values
CIntegerParameter(nodemap, "TonalRangeSourceDark").SetValue(30);
CIntegerParameter(nodemap, "TonalRangeTargetDark").SetValue(0);
// Set the bright source and target values
CIntegerParameter(nodemap, "TonalRangeSourceBright").SetValue(240);
CIntegerParameter(nodemap, "TonalRangeTargetBright").SetValue(255);
// Enable tonal range adjustments
camera.Parameters[PLCamera.TonalRangeEnable].SetValue(PLCamera.TonalRangeEnable.On);
// Specify that the summed RGB pixel values are used for tonal range adjustments
camera.Parameters[PLCamera.TonalRangeSelector].SetValue(PLCamera.TonalRangeSelector.Sum);
// Set the dark source and target values
camera.Parameters[PLCamera.TonalRangeSourceDark].SetValue(30);
camera.Parameters[PLCamera.TonalRangeTargetDark].SetValue(0);
// Set the bright source and target values
camera.Parameters[PLCamera.TonalRangeSourceBright].SetValue(240);
camera.Parameters[PLCamera.TonalRangeTargetBright].SetValue(255);
/* 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 tonal range adjustments */
errRes = PylonDeviceFeatureFromString(hdev, "TonalRangeEnable", "On");
CHECK(errRes);
/* Specify that the summed RGB pixel values are used for tonal range adjustments */
errRes = PylonDeviceFeatureFromString(hdev, "TonalRangeSelector", "Sum");
CHECK(errRes);
/* Set the dark source and target values */
errRes = PylonDeviceSetIntegerFeature(hdev, "TonalRangeSourceDark", 30);
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "TonalRangeTargetDark", 0);
CHECK(errRes);
/* Set the bright source and target values */
errRes = PylonDeviceSetIntegerFeature(hdev, "TonalRangeSourceBright", 240);
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "TonalRangeTargetBright", 255);
CHECK(errRes);
# Enable tonal range adjustments
camera.TonalRangeEnable.Value = "On"
# Specify that the summed RGB pixel values are used for tonal range adjustments
camera.TonalRangeSelector.Value = "Sum"
# Set the dark source and target values
camera.TonalRangeSourceDark.Value = 30
camera.TonalRangeTargetDark.Value = 0
# Set the bright source and target values
camera.TonalRangeSourceBright.Value = 240
camera.TonalRangeTargetBright.Value = 255

pylon Viewerを使用して、パラメーターを簡単に設定することもできます。