不完全なバーコードと画像補正
using IronBarCode;
using IronSoftware.Drawing;

// Choose which filters are to be applied (in order)
// Set cacheAtEachIteration = true to save the intermediate image data after each filter is applied
var filtersToApply = new ImageFilterCollection(cacheAtEachIteration: true) {
    new SharpenFilter(),
    new InvertFilter(),
    new ContrastFilter(),
    new BrightnessFilter(),
    new AdaptiveThresholdFilter(),
    new BinaryThresholdFilter(),
    new GaussianBlurFilter(),
    new MedianBlurFilter(),
    new BilateralFilter()
};

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Set chosen filters in BarcodeReaderOptions
    ImageFilters = filtersToApply,

    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
};

// Read with the options applied
BarcodeResults results = BarcodeReader.Read("screenshot.png", myOptionsExample);

AnyBitmap[] filteredImages = results.FilterImages();

// Export intermediate image files to disk
for (int i = 0 ; i < filteredImages.Length ; i++)
    filteredImages[i].SaveAs($"{i}_barcode.png");

// Or
results.ExportFilterImagesToDisk("filter-result.jpg");
NuGet Download
PM > Install-Package BarCode
不完全なバーコードと画像補正

不完全なバーコードと画像補正

IronBarcodeは、BarcodeReaderOptions内で簡単に適用できる多くの画像前処理フィルターを提供しています。 例えば、Contrastのようなフィルターを選択すると、画像の読み取りが改善されるかもしれません。 選択した順序が適用される順序であることに注意してください。

各フィルター適用後の中間画像データを保存するオプションがあります。 これはSaveAtEachIterationプロパティで切り替えることができます。

コード例の主要ポイント:

  • Contrastなどのさまざまな画像フィルターで設定します。
  • フィルターは特定の順序で追加され、適用されるべき順序を示します。
  • trueに設定することで、ライブラリは各フィルター適用後に中間画像を保存し、デバッグや分析に役立ちます。
  • 最後に、画像からバーコードを読み取り、バーコードの種類と値をコンソールに出力します。
IronBarcodeの画像補正について詳しく見る
GitHubで見る

準備はできましたか?

Nuget Downloads 2,540,041バージョン:2026.11リリースされたばかり