不完善的條碼和圖像修正
IronBarcode 提供了許多可在 BarcodeReaderOptions 中輕鬆應用的過濾器。 選擇可能改善圖像閱讀的過濾器,例如銳化、反轉(顏色), 和對比。請記住,您選擇它們的順序就是它們應用的順序。
using IronBarCode; using IronSoftware.Drawing; using System.Linq; // Choose which filters are to be applied (in order); var filtersToApply = new ImageFilterCollection() { new SharpenFilter(), new InvertFilter(), new ContrastFilter(), new BrightnessFilter(), new AdaptiveThresholdFilter(), new BinaryThresholdFilter() }; BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions() { // Set chosen filters in BarcodeReaderOptions: ImageFilters = filtersToApply, // Other Barcode Reader Options: Speed = ReadingSpeed.Balanced, ExpectMultipleBarcodes = true, }; // And, apply with a Read: BarcodeResults results = BarcodeReader.Read("screenshot.png", myOptionsExample); AnyBitmap[] filteredImages = results.FilterImages(); // Export file 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 Imports System.Linq ' Choose which filters are to be applied (in order); Private filtersToApply = New ImageFilterCollection() From { New SharpenFilter(), New InvertFilter(), New ContrastFilter(), New BrightnessFilter(), New AdaptiveThresholdFilter(), New BinaryThresholdFilter() } Private myOptionsExample As New BarcodeReaderOptions() With { .ImageFilters = filtersToApply, .Speed = ReadingSpeed.Balanced, .ExpectMultipleBarcodes = True } ' And, apply with a Read: Private results As BarcodeResults = BarcodeReader.Read("screenshot.png", myOptionsExample) Private filteredImages() As AnyBitmap = results.FilterImages() ' Export file to disk For i As Integer = 0 To filteredImages.Length - 1 filteredImages(i).SaveAs($"{i}_barcode.png") Next i ' Or results.ExportFilterImagesToDisk("filter-result.jpg")
Install-Package BarCode
IronBarcode 提供了許多可在 BarcodeReaderOptions 中輕鬆應用的過濾器。 選擇可能改善圖像閱讀的過濾器,例如銳化、反轉(顏色), 和對比。請記住,您選擇它們的順序就是它們應用的順序。