コンテンツにスキップ

Defect Pixel Correction#

Defect Pixel Correctionカメラ機能を使用すると、センサーの個々の画素の感度差の影響を最小限に抑えることができます。

取得した画像では、均一な光が使用されていても、一部の画素が他の画素よりも大幅に明るくまたは暗く見える場合があります。この問題は、個々の画素の感度の違いが原因で発生します。これは、製造上の許容誤差が原因です。

機能を使用する#

The implementation of this feature varies by camera series:

ace 2 R/X and boost R Cameras#

Basler ace 2 R, ace 2 X, and boost R cameras support static defect pixel correction. This correction is based on files that are stored on the camera and contain a list of defect pixel coordinates.

「静的」とは、常に同じ指定画素欠陥座標が補正プロセスに使用されることを意味します。画像取得中、これらの画素の輝度値は、隣接する画素の輝度値に基づいて置き換えられます。

次の画素欠陥補正ファイルをカメラに保存できます。

  • Factory file: Contains the coordinates of defect pixels that were detected during camera production.
  • User file: Contains user-defined coordinates. You can upload this file to the camera. This allows you to define new defect pixels that might have occurred over time.

情報

Basler ace 2 X cameras also support dynamic pixel defect correction. For more information, see Pixel Correction Beyond.

pylon Viewerを使用した画素欠陥補正#

Static Defect Pixel Correction(pylon Viewer)を参照してください。

pylon APIを使用した画素欠陥補正#

情報

Baslerは、pylon Viewerを使用して画素欠陥補正を実行することを推奨します。

pylon APIは、独自のアプリケーションで画素欠陥補正を実装する場合にのみ使用してください。

Static Defect Pixel Correction Modeの設定#

To set the static defect pixel correction mode, set the BslStaticDefectPixelCorrectionMode parameter to one of the following values:

  • Factory (default): Static defect pixel correction is based on the defect pixels stored in the factory correction file.
  • User: Static defect pixel correction is based on the defect pixels stored in the user correction file.
    Note that when setting this mode via the pylon API, only the user-defined pixels will be used. When setting the User incl. Factory correction mode via the pylon Viewer, user-defined pixels will be used in addition to the pixels stored in the factory file.
  • Off: The camera does not perform static defect pixel corrections.
ユーザーDefect Pixel Correctionファイルのアップロード#

ユーザー画素欠陥補正ファイルをアップロードする前に、ファイルが次のファイル形式に準拠していることを確認してください。

ファイルは、値が0の4バイトを含む4バイトのヘッダーで始まる必要があります。ヘッダーに続いて、ファイルには画素欠陥エントリーが含まれている必要があります(最大4096の画素欠陥を指定できます)。各エントリーは、14ビットのy座標、14ビットのx座標、4ビットのタイプの順に、32ビットで構成されています。

例:座標x = 1およびy = 2の画素欠陥エントリー

Bit   |31          18| |17           4| |3  0|
Value |00000000000010| |00000000000001| |0000|
      | y = 2        | | X = 1        | |type|

pylon Viewerを使用してユーザー画素欠陥補正ファイルをアップロードするには、次の手順を実行します。

  1. pylon Viewerの[カメラ]メニューで、[ファイルアクセス]をクリックします。
  2. [Camera File]ドロップダウンボックスで、[User Defect Pixel Correction]を選択します。
    User Defect Pixel Correctionエントリーがない場合、カメラは補正ファイルのアップロードをサポートしていません。
  3. [Upload]をクリックして、アップロードするファイルに移動します。
  4. [開く]をクリックします。

To apply the user defect pixel correction file after uploading, make sure that the BslStaticDefectPixelCorrectionMode parameter is set to User and execute the BslStaticDefectPixelCorrectionReload command.

Defect Pixel Correctionファイルのダウンロード#

画素欠陥補正ファイル(工場補正ファイルなど)をダウンロードすると、ダウンロードしたファイルに独自の測定済み画素欠陥を追加する場合に便利です。画素欠陥エントリーの完全なリストを新しいユーザー補正ファイルに保存できます。

pylon Viewerを使用して画素欠陥補正ファイルをダウンロードするには、次の手順を実行します。

  1. pylon Viewerの[カメラ]メニューで、[ファイルアクセス]をクリックします。
  2. [Camera File]ドロップダウンボックスで、ダウンロードするファイルに応じて、[Static Factory Defect Pixel Correction]または[Static User Defect Pixel Correction]を選択します。
    適切なエントリーがない場合、カメラはファイルのダウンロードをサポートしていません。
  3. [ダウンロード]をクリックし、ファイルを保存するディレクトリーに移動して、任意のファイル名を入力します。
  4. [開く]をクリックします。
Static Defect Pixel Correctionファイルステータス#

The StaticDefectPixelCorrectionFileStatus parameter can take the following values:

  • FileStatusUnknown: The status of the defect pixel correction file is unknown. Acquire an image to change the file status.
  • FileOk: The defect pixel correction file is valid.
  • FileNotFound: The defect pixel correction file can't be found. It has never been uploaded or was deleted.
  • FileEmpty: The defect pixel correction file has no entries. The file header is valid but the file doesn't contain any defect pixels. The defect pixel correction process is aborted.
  • InvalidHeader: The defect pixel correction file header is invalid. The file must have a 4-byte file header.
  • InvalidSize: The defect pixel correction file size is invalid. The maximum number of defective pixels must not exceed 4096.
  • InvalidSorting: The sorting of entries in the defect pixel correction file is invalid. The defect pixel correction process is aborted.
  • InvalidFileEntry: At least one entry in the defect pixel correction file has an invalid size. The defect pixel correction process is aborted.
  • InvalidClustering: An invalid cluster has been found. Three or more adjacent pixels in a row are considered an invalid cluster. Any defect pixels between other defect pixels can't be corrected.

The defect pixel correction file can contain a maximum number of defect pixels. To get the number, get the value of the BslStaticDefectPixelCorrectionMaxDefects parameter.

boost Vカメラ#

Basler boost V カメラは、静的画素欠陥補正をサポートしています。この補正は、画素欠陥座標のリストを含むカメラに保存されたファイルに基づいて行われます。

「静的」とは、常に同じ指定画素欠陥座標が補正プロセスに使用されることを意味します。画像取得中、これらの画素の輝度値は、隣接する画素の輝度値に基づいて置き換えられます。

Defect Pixel Correctionの実行#

情報

pylon Viewer の内蔵静的 Defect Pixel Correction 機能は boost V カメラをサポートしていません。

boost V カメラで画素欠陥補正を行うには、pylon Viewer または pylon API の機能ツリーを使用します。

boost V カメラで画素欠陥補正を行うには、次のようにします。

  1. Set the BslStaticDefectPixelCorrectionMode parameter to the desired correction mode:

    • Factory: Only defect pixels whose coordinates are stored in the factory file are corrected. The factory file is generated during camera production and can't be changed.
    • User: You can specify custom defect pixel coordinates.
    • Off: The camera does not perform static defect pixel corrections.
  2. If you selected User:

    1. 画像内の画素エラーを見つけて、画素欠陥の x 座標と y 座標を書き留めます。
    2. Set the BslStaticDefectPixelCorrectionYCoordinate parameter to the y coordinate of the first defect pixel.
    3. Set the BslStaticDefectPixelCorrectionXSelector parameter to X0.
    4. Set the BslStaticDefectPixelCorrectionXCoordinate parameter to the x coordinate of the first defect pixel.
    5. If there's another defect pixel with the same y coordinate, but a different x coordinate, set the BslStaticDefectPixelCorrectionXSelector parameter to the next entry, e.g., X1, and enter the next x coordinate.
    6. 他のすべての画素エラーについて、手順 b を繰り返します。
    7. Execute the BslStaticDefectPixelCorrectionSave command to save changes to flash memory.

情報

  • You can use the BslStaticDefectPixelCorrectionCount parameter to check how many image pixels are currently being corrected.
  • You can set the BslStaticDefectPixelCorrectionTestMode parameter to On to set all corrected pixels to completely white. This helps to find pixels that are being corrected in your images.

画素欠陥座標の除去#

工場ファイル内のピクセル座標は除去できません。

ただし、カスタム画素欠陥座標、つまり「User」補正モードで入力された座標は除去できます(上記参照)。そうするためには、次のようにします。

  • If you want to remove a single custom defect pixel coordinate:

    1. Set the BslStaticDefectPixelCorrectionYCoordinate parameter to the y coordinate of the defect pixel.
    2. Set the BslStaticDefectPixelCorrectionXSelector parameter to the entry that holds the x coordinate of the defect pixel, e.g., X0.
    3. Set the BslStaticDefectPixelCorrectionXCoordinate parameter to 0xFFFF.
    4. Execute the BslStaticDefectPixelCorrectionSave command to save changes to flash memory.
  • If you want to remove all custom defect pixel coordinates:

    1. Execute the BslStaticDefectPixelCorrectionClearAll command. This sets all BslStaticDefectPixelCorrectionXCoordinate parameter values to 0xFFFF.
    2. Execute the BslStaticDefectPixelCorrectionSave command to save changes to flash memory.

dartおよびpulseカメラ#

Basler dartとpulseカメラでは、次の2種類の画素補正を実行できます。

  • The static pixel correction corrects pixels that have significantly lesser intensity values than their neighboring pixels, including completely black pixels.
  • The dynamic pixel correction corrects pixels that have significantly higher intensity values than their neighboring pixels, including completely white pixels. An internal threshold value defines when a pixel is detected as a "hot pixel". "Dynamic" means that the defect pixel correction is calculated individually for each acquired image.

Defect Pixel Correction Modeの設定#

To set the defect pixel correction mode, set the BslDefectPixelCorrectionMode parameter to one of the following values:

  • On (default): The camera performs static and dynamic pixel corrections.
  • StaticOnly: The camera performs the static pixel correction only.
  • Off: The camera does not perform pixel corrections.

サンプルコード#

ace 2 R/X and boost R Cameras#
// Set static user defect pixel correction
camera.BslStaticDefectPixelCorrectionMode.SetValue(BslStaticDefectPixelCorrectionMode_User);
// Reload static defect pixel correction file
camera.BslStaticDefectPixelCorrectionReload.Execute();
INodeMap& nodemap = camera.GetNodeMap();
// Set static user defect pixel correction
CEnumParameter(nodemap, "BslStaticDefectPixelCorrectionMode").SetValue("User");
// Reload static defect pixel correction file
CCommandParameter(nodemap, "BslStaticDefectPixelCorrectionReload").Execute();
// Set static user defect pixel correction
camera.Parameters[PLCamera.BslStaticDefectPixelCorrectionMode].SetValue(PLCamera.BslStaticDefectPixelCorrectionMode.User);
// Reload static defect pixel correction file
camera.Parameters[PLCamera.BslStaticDefectPixelCorrectionReload].Execute();
/* 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 static user defect pixel correction */
errRes = PylonDeviceFeatureFromString(hdev, "BslStaticDefectPixelCorrectionMode", "User");
CHECK(errRes);
/* Reload static defect pixel correction file */
errRes = PylonDeviceExecuteCommandFeature(hdev, "BslStaticDefectPixelCorrectionReload");
CHECK(errRes);
# Set static user defect pixel correction
camera.BslStaticDefectPixelCorrectionMode.Value = "User"
# Reload static defect pixel correction file
camera.BslStaticDefectPixelCorrectionReload.Execute()
boost Vカメラ#
// Set the defect pixel correction mode to User
camera.BslStaticDefectPixelCorrectionMode.SetValue(BslStaticDefectPixelCorrectionMode_User);
// Assume there are two defect pixels at coordinates (120,430) and (182,430)
// Set the y coordinate to 430
camera.BslStaticDefectPixelCorrectionYCoordinate.SetValue(430);
// Select entry X0 and assign the first x coordinate
camera.BslStaticDefectPixelCorrectionXSelector.SetValue(BslStaticDefectPixelCorrectionXSelector_X0);
camera.BslStaticDefectPixelCorrectionXCoordinate.SetValue(120);
// Select entry X1 and assign the second x coordinate, which is in the same line
camera.BslStaticDefectPixelCorrectionXSelector.SetValue(BslStaticDefectPixelCorrectionXSelector_X1);
camera.BslStaticDefectPixelCorrectionXCoordinate.SetValue(182);
// Save changes to flash memory
camera.BslStaticDefectPixelCorrectionSave.Execute();
INodeMap& nodemap = camera.GetNodeMap();
// Set the defect pixel correction mode to User
CEnumParameter(nodemap, "BslStaticDefectPixelCorrectionMode").SetValue("User");
// Assume there are two defect pixels at coordinates (120,430) and (182,430)
// Set the y coordinate to 430
CIntegerParameter(nodemap, "BslStaticDefectPixelCorrectionYCoordinate").SetValue(430);
// Select entry X0 and assign the first x coordinate
CEnumParameter(nodemap, "BslStaticDefectPixelCorrectionXSelector").SetValue("X0");
CIntegerParameter(nodemap, "BslStaticDefectPixelCorrectionXCoordinate").SetValue(120);
// Select entry X1 and assign the second x coordinate, which is in the same line
CEnumParameter(nodemap, "BslStaticDefectPixelCorrectionXSelector").SetValue("X1");
CIntegerParameter(nodemap, "BslStaticDefectPixelCorrectionXCoordinate").SetValue(182);
// Save changes to flash memory
CCommandParameter(nodemap, "BslStaticDefectPixelCorrectionSave").Execute();
// Set the defect pixel correction mode to User
camera.Parameters[PLCamera.BslStaticDefectPixelCorrectionMode].SetValue(PLCamera.BslStaticDefectPixelCorrectionMode.User);
// Assume there are two defect pixels at coordinates (120,430) and (182,430)
// Set the y coordinate to 430
camera.Parameters[PLCamera.BslStaticDefectPixelCorrectionYCoordinate].SetValue(430);
// Select entry X0 and assign the first x coordinate
camera.Parameters[PLCamera.BslStaticDefectPixelCorrectionXSelector].SetValue(PLCamera.BslStaticDefectPixelCorrectionXSelector.X0);
camera.Parameters[PLCamera.BslStaticDefectPixelCorrectionXCoordinate].SetValue(120);
// Select entry X1 and assign the second x coordinate, which is in the same line
camera.Parameters[PLCamera.BslStaticDefectPixelCorrectionXSelector].SetValue(PLCamera.BslStaticDefectPixelCorrectionXSelector.X1);
camera.Parameters[PLCamera.BslStaticDefectPixelCorrectionXCoordinate].SetValue(182);
// Save changes to flash memory
camera.Parameters[PLCamera.BslStaticDefectPixelCorrectionSave].Execute();
/* 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 defect pixel correction mode to User */
errRes = PylonDeviceFeatureFromString(hdev, "BslStaticDefectPixelCorrectionMode", "User");
CHECK(errRes);
/* Assume there are two defect pixels at coordinates (120,430) and (182,430) */
/* Set the y coordinate to 430 */
errRes = PylonDeviceSetIntegerFeature(hdev, "BslStaticDefectPixelCorrectionYCoordinate", 430);
CHECK(errRes);
/* Select entry X0 and assign the first x coordinate */
errRes = PylonDeviceFeatureFromString(hdev, "BslStaticDefectPixelCorrectionXSelector", "X0");
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "BslStaticDefectPixelCorrectionXCoordinate", 120);
CHECK(errRes);
/* Select entry X1 and assign the second x coordinate, which is in the same line */
errRes = PylonDeviceFeatureFromString(hdev, "BslStaticDefectPixelCorrectionXSelector", "X1");
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "BslStaticDefectPixelCorrectionXCoordinate", 182);
CHECK(errRes);
/* Save changes to flash memory */
errRes = PylonDeviceExecuteCommandFeature(hdev, "BslStaticDefectPixelCorrectionSave");
CHECK(errRes);
# Set the defect pixel correction mode to User
camera.BslStaticDefectPixelCorrectionMode.Value = "User"
# Assume there are two defect pixels at coordinates (120,430) and (182,430)
# Set the y coordinate to 430
camera.BslStaticDefectPixelCorrectionYCoordinate.Value = 430
# Select entry X0 and assign the first x coordinate
camera.BslStaticDefectPixelCorrectionXSelector.Value = "X0"
camera.BslStaticDefectPixelCorrectionXCoordinate.Value = 120
# Select entry X1 and assign the second x coordinate, which is in the same line
camera.BslStaticDefectPixelCorrectionXSelector.Value = "X1"
camera.BslStaticDefectPixelCorrectionXCoordinate.Value = 182
# Save changes to flash memory
camera.BslStaticDefectPixelCorrectionSave.Execute()
dartおよびpulseカメラ#
// Disable defect pixel correction
camera.BslDefectPixelCorrectionMode.SetValue(BslDefectPixelCorrectionMode_Off);
INodeMap& nodemap = camera.GetNodeMap();
// Disable defect pixel correction
CEnumParameter(nodemap, "BslDefectPixelCorrectionMode").SetValue("Off");
// Disable defect pixel correction
camera.Parameters[PLCamera.BslDefectPixelCorrectionMode].SetValue(PLCamera.BslDefectPixelCorrectionMode.Off);
/* 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 */
/* Disable defect pixel correction */
errRes = PylonDeviceFeatureFromString(hdev, "BslDefectPixelCorrectionMode", "Off");
CHECK(errRes);
# Disable defect pixel correction
camera.BslDefectPixelCorrectionMode.Value = "Off"

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