IRONSOFTWAREHOME
不完美條碼與圖像校正
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");
Imports IronBarCode
Imports 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
Dim filtersToApply As New ImageFilterCollection(cacheAtEachIteration:=True) From {
    New SharpenFilter(),
    New InvertFilter(),
    New ContrastFilter(),
    New BrightnessFilter(),
    New AdaptiveThresholdFilter(),
    New BinaryThresholdFilter(),
    New GaussianBlurFilter(),
    New MedianBlurFilter(),
    New BilateralFilter()
}

Dim myOptionsExample As New BarcodeReaderOptions() With {
    .ImageFilters = filtersToApply,

    .Speed = ReadingSpeed.Balanced,
    .ExpectMultipleBarcodes = True
}

' Read with the options applied
Dim results As BarcodeResults = BarcodeReader.Read("screenshot.png", myOptionsExample)

Dim filteredImages As AnyBitmap() = results.FilterImages()

' Export intermediate image files to disk
For i As Integer = 0 To filteredImages.Length - 1
    filteredImages(i).SaveAs($"{i}_barcode.png")
Next

' Or
results.ExportFilterImagesToDisk("filter-result.jpg")
NuGet Download
PM > Install-Package BarCode
不完美條碼與圖像校正

不完美條碼與圖像校正

IronBarcode 提供許多影像預處理過濾器可供選擇,並且可以輕鬆地應用在 BarcodeReaderOptions。 選擇可以改善影像讀取的過濾器,例如 Sharpen二值化閾值Contrast。 請記得您選擇的順序就是他們應用的順序。

有選項可以將應用每個過濾器的中間影像資料儲存下來。 可以使用 SaveAtEachIteration 屬性來切換 ImageFilterCollection

範例程式碼中的重點:

  • 我們建立了一個 BarcodeReaderOptions 的實例,並使用各種影像過濾器進行配置:Binary ThresholdContrast
  • 過濾器以特定順序新增,表示應用的順序。
  • 通過將 cacheAtEachIteration 設置為 true,程式庫會在每次應用過濾器後儲存中間的影像,這對於除錯和分析很有用。
  • 最後,我們從影像中讀取條碼,並將條碼型別和值輸出至控制台。
進一步瞭解 IronBarcode 中的影像校正
在 GitHub 上查看

準備好開始了嗎?

Nuget Downloads 2,422,100版本:2026.9剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預訂您的免費即時演示
Booking Badge

全球數百萬工程師信賴

Iron Software的客戶標誌
獲取您的無義務諮詢
完成下方表單或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終保密。
全球數百萬工程師信賴
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立