コンテンツにスキップ

Tonal Range Auto#

Tonal Range Autoカメラ機能を使用すると、コントラストまたはカラーシフト、またはその両方を1回の操作で調整できます。

この機能は、カメラを光学顕微鏡で使用する場合に特に便利です。

コントラストまたはカラーシフトを手動で調整する場合は、Tonal Range機能を使用します。

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

画像のさまざまな部分の画素データを使用できる、複数のAuto Function ROIを定義できます。

機能を使用する#

Using Tonal Range Auto#

Using Tonal Range Auto with Default Settings#

オートファンクションのパラメーターは、ほとんどのシナリオで良好な結果をもたらす値にプリセットされています。

デフォルト設定を使用してコントラストまたはカラー、またはその両方を調整するには、次の手順に従います。

  1. カメラがすでに良好な画像を生成しており、低コントラストシフトカラーの問題だけが残っていることを確認します。色調範囲の操作は、既に良好な画質を持つ画像に対してのみ実行してください。
    画質を最適化する場合は、以下の手順に従います。
  2. Tonal Range Autoオートファンクションに少なくとも1つのオートファンクションROIを割り当てます。
    オートファンクションROIが画像ROIと部分的または完全にオーバーラップするようにしてください。
  3. カラーカメラを使用している場合:
    1. If you want to adjust contrast and color in a single step, set the AutoTonalRangeModeSelector parameter to ColorAndContrast.
    2. If you only want to adjust the contrast, set the AutoTonalRangeModeSelector parameter to Contrast.
    3. If you only want to correct color shifts, set the AutoTonalRangeModeSelector parameter to Color.
      (If you are using a mono camera, only contrast adjustment is available. The AutoTonalRangeModeSelector parameter is preset to Contrast and can't be changed.)
  4. Set the TonalRangeAuto parameter to Once.
    With the next image acquisition, the camera adjusts contrast or color or both using the default settings. When the adjustment is complete, the camera sets the auto function to Off and applies the adjustment to all subsequent images.
  5. 調整を微調整する場合は、Tonal Range機能を使用します。

Using Tonal Range Auto with Custom Settings#

カスタム設定を使用してコントラストまたはカラー、またはその両方を調整するには、次の手順に従います。

  1. カラーカメラを使用している場合:
    1. If you want to adjust contrast and color in a single step, set the AutoTonalRangeModeSelector parameter to ColorAndContrast.
    2. If you only want to adjust the contrast, set the AutoTonalRangeModeSelector parameter to Contrast.
    3. If you only want to correct color shifts, set the AutoTonalRangeModeSelector parameter to Color.
      (If you are using a mono camera, only contrast adjustment is available. The AutoTonalRangeModeSelector parameter is preset to Contrast and can't be changed.)
  2. パラメーターを AutoTonalRangeAdjustmentSelector パラメーターを次のいずれかの値に設定します。
    • BrightAndDark (default): Automatic adjustments are applied to dark and bright parts of your images.
    • Dark: Automatic adjustments are applied to dark parts of your images only.
    • Bright: Automatic adjustments are applied to bright parts of your images only.
  3. Specify the dark threshold value using the AutoTonalRangeThresholdDark parameter.
  4. Specify the bright threshold value using the AutoTonalRangeThresholdBright parameter.
  5. If the AutoTonalRangeModeSelector parameter is set to ColorAndContrast or Contrast:

    1. Set the AutoTonalRangeTargetDark parameter to the dark target value.
    2. Set the AutoTonalRangeTargetBright parameter to the bright target value.
    3. Set the TonalRangeAuto parameter to Once.
      With the next image acquisition, the camera adjusts contrast or color or both using the default settings. When the adjustment is complete, the camera sets the auto function to Off and applies the adjustment to all subsequent simages.
    4. 調整を微調整する場合は、Tonal Range機能を使用します。

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ペインでは、オートファンクションが実際に使用するデータが表示されない場合があります
例えば、Gamma機能は、色調範囲の操作後に処理されます。その結果、ガンマ補正は、pylon Viewerに表示されるヒストグラムに含まれますが、オートファンクションで使用するデータには含まれません。

Source and Target Values#

Tonal Range Auto機能は、Tonal Range機能と同じ概念(ソース値とターゲット値のマッピング)に基づいています。

異なる点は、カメラがソースとターゲットの値を決定する方法です。

  • カメラは、しきい値を計算して、暗さと明るさのソース値を決定します。
  • カメラは、次のように暗さと明るさのターゲット値を決定します。

    • For contrast adjustments, the camera reads the value of the AutoTonalRangeTargetDark and AutoTonalRangeTargetBright parameters.
    • カラー調整では、適切にRGBヒストグラムを調整するターゲット値がカメラによって自動的に決定されます。

カメラがソース値とターゲット値を決定すると、カメラは、Tonal Rangeトピックで説明されているとおりにコントラストとカラーの調整を行います。

Threshold Values#

階調範囲の自動調整中、ソース値はしきい値に基づいて自動的に計算されます。

You must specify the threshold values using the AutoTonalRangeThresholdDark and AutoTonalRangeThresholdBright parameters. The parameters are expressed as percentages of all pixels in your image.

情報

このセクションでは、割り当てられたオートファンクションROI画像ROIが同一であることを前提としています。これがデフォルト設定です。オートファンクションROI設定を変更した場合、パーセンテージは、割り当てられたオートファンクションROIと画像ROIのオーバーラップ領域の画素を参照します。

このパーセンテージから、カメラは次の値を計算します。

  • 暗さのしきい値は、指定した画素量がしきい値以下のピクセル値を持つヒストグラム内の値です。
  • 明るさのしきい値は、指定した画素量がしきい値以上のピクセル値を持つヒストグラム内の値です。

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

Example: Assume you set the AutoTonalRangeThresholdDark parameter to 0.3 and the AutoTonalRangeThresholdBright parameter to 0.4. The camera detects that 0.3 % of the pixels in your image have a pixel value lower than or equal to 52, and 0.4 % of the pixels in your image have a pixel value greater than or equal to 204. Therefore, the dark threshold value is 52, and the bright threshold value is 204.

Dark and Bright Threshold Illustration

サンプルコード#

// Enable contrast adjustments only
camera.AutoTonalRangeModeSelector.SetValue(AutoTonalRangeModeSelector_Contrast);
// Specify that both ends of the tonal range are to be adjusted automatically
camera.AutoTonalRangeAdjustmentSelector.SetValue(AutoTonalRangeAdjustmentSelector_BrightAndDark);
// Set the percentage of pixels that is used to calculate the dark threshold
camera.AutoTonalRangeThresholdDark.SetValue(0.3);
// Set the percentage of pixels that is used to calculate the bright threshold
camera.AutoTonalRangeThresholdBright.SetValue(0.4);
// Set the dark target value
camera.AutoTonalRangeTargetDark.SetValue(0);
// Set the bright target value
camera.AutoTonalRangeTargetBright.SetValue(255);
// Enable the Tonal Range Auto auto function
camera.TonalRangeAuto.SetValue(TonalRangeAuto_Once);
INodeMap& nodemap = camera.GetNodeMap();
// Enable contrast adjustments only
CEnumParameter(nodemap, "AutoTonalRangeModeSelector").SetValue("Contrast");
// Specify that both ends of the tonal range are to be adjusted automatically
CEnumParameter(nodemap, "AutoTonalRangeAdjustmentSelector").SetValue("BrightAndDark");
// Set the percentage of pixels that is used to calculate the dark threshold
CFloatParameter(nodemap, "AutoTonalRangeThresholdDark").SetValue(0.3);
// Set the percentage of pixels that is used to calculate the bright threshold
CFloatParameter(nodemap, "AutoTonalRangeThresholdBright").SetValue(0.4);
// Set the dark target value
CIntegerParameter(nodemap, "AutoTonalRangeTargetDark").SetValue(0);
// Set the bright target value
CIntegerParameter(nodemap, "AutoTonalRangeTargetBright").SetValue(255);
// Enable the Tonal Range Auto auto function
CEnumParameter(nodemap, "TonalRangeAuto").SetValue("Once");
// Enable contrast adjustments only
camera.Parameters[PLCamera.AutoTonalRangeModeSelector].SetValue(PLCamera.AutoTonalRangeModeSelector.Contrast);
// Specify that both ends of the tonal range are to be adjusted automatically
camera.Parameters[PLCamera.AutoTonalRangeAdjustmentSelector].SetValue(PLCamera.AutoTonalRangeAdjustmentSelector.BrightAndDark);
// Set the percentage of pixels that is used to calculate the dark threshold
camera.Parameters[PLCamera.AutoTonalRangeThresholdDark].SetValue(0.3);
// Set the percentage of pixels that is used to calculate the bright threshold
camera.Parameters[PLCamera.AutoTonalRangeThresholdBright].SetValue(0.4);
// Set the dark target value
camera.Parameters[PLCamera.AutoTonalRangeTargetDark].SetValue(0);
// Set the bright target value
camera.Parameters[PLCamera.AutoTonalRangeTargetBright].SetValue(255);
// Enable the Tonal Range Auto auto function
camera.Parameters[PLCamera.TonalRangeAuto].SetValue(PLCamera.TonalRangeAuto.Once);
/* 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 contrast adjustments only */
errRes = PylonDeviceFeatureFromString(hdev, "AutoTonalRangeModeSelector", "Contrast");
CHECK(errRes);
/* Specify that both ends of the tonal range are to be adjusted automatically */
errRes = PylonDeviceFeatureFromString(hdev, "AutoTonalRangeAdjustmentSelector", "BrightAndDark");
CHECK(errRes);
/* Set the percentage of pixels that is used to calculate the dark threshold */
errRes = PylonDeviceSetFloatFeature(hdev, "AutoTonalRangeThresholdDark", 0.3);
CHECK(errRes);
/* Set the percentage of pixels that is used to calculate the bright threshold */
errRes = PylonDeviceSetFloatFeature(hdev, "AutoTonalRangeThresholdBright", 0.4);
CHECK(errRes);
/* Set the dark target value */
errRes = PylonDeviceSetIntegerFeature(hdev, "AutoTonalRangeTargetDark", 0);
CHECK(errRes);
/* Set the bright target value */
errRes = PylonDeviceSetIntegerFeature(hdev, "AutoTonalRangeTargetBright", 255);
CHECK(errRes);
/* Enable the Tonal Range Auto auto function */
errRes = PylonDeviceFeatureFromString(hdev, "TonalRangeAuto", "Once");
CHECK(errRes);
# Enable contrast adjustments only
camera.AutoTonalRangeModeSelector.Value = "Contrast"
# Specify that both ends of the tonal range are to be adjusted automatically
camera.AutoTonalRangeAdjustmentSelector.Value = "BrightAndDark"
# Set the percentage of pixels that is used to calculate the dark threshold
camera.AutoTonalRangeThresholdDark.Value = 0.3
# Set the percentage of pixels that is used to calculate the bright threshold
camera.AutoTonalRangeThresholdBright.Value = 0.4
# Set the dark target value
camera.AutoTonalRangeTargetDark.Value = 0
# Set the bright target value
camera.AutoTonalRangeTargetBright.Value = 255
# Enable the Tonal Range Auto auto function
camera.TonalRangeAuto.Value = "Once"

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