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中。 选择可以改善图像读取的滤镜,如*Contrast*。 请记住,您选择它们的顺序就是应用的顺序。

可以选择保存应用每个过滤器的中间图像的数据。 这可以通过ImageFilterCollection进行切换。

来自代码示例的关键要点:

  • 我们创建一个Contrast
  • 过滤器按特定顺序添加,表示它们应该应用的顺序。
  • 通过将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 天试用密钥
无需信用卡或创建账户