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
Private filtersToApply = New ImageFilterCollection(cacheAtEachIteration:= True) From {
New SharpenFilter(),
New InvertFilter(),
New ContrastFilter(),
New BrightnessFilter(),
New AdaptiveThresholdFilter(),
New BinaryThresholdFilter(),
New GaussianBlurFilter(),
New MedianBlurFilter(),
New BilateralFilter()
}
Private myOptionsExample As New BarcodeReaderOptions() With {
.ImageFilters = filtersToApply,
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True
}
' Read with the options applied
Private results As BarcodeResults = BarcodeReader.Read("screenshot.png", myOptionsExample)
Private 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 i
' Or
results.ExportFilterImagesToDisk("filter-result.jpg")
Install-Package BarCode
불완전한 바코드 및 이미지 보정
IronBarcode는 BarcodeReaderOptions 내에서 쉽게 적용할 수 있는 다양한 이미지 전처리 필터를 제공합니다. 이미지 판독을 개선할 수 있는 필터를 선택하세요, 예를 들어 Sharpen, 이진 임계값, Contrast와 같은. 선택한 순서대로 필터가 적용된다는 점을 기억하십시오.
각 필터를 적용한 중간 이미지의 이미지 데이터를 저장하는 옵션이 있습니다. 이것은 ImageFilterCollection의 SaveAtEachIteration 속성으로 전환할 수 있습니다.
주요 코드 예제의 핵심 포인트:
우리는 BarcodeReaderOptions의 인스턴스를 생성하고 Sharpen, Binary Threshold, Contrast와 같은 다양한 이미지 필터로 구성합니다.
필터는 적용 순서를 나타내는 특정 순서로 추가됩니다.
cacheAtEachIteration를 true로 설정하여 각 필터 적용 후 중간 이미지를 라이브러리가 저장하게 되어 디버깅 및 분석에 유용합니다.