C#을 사용하여 바코드에 이미지 보정 필터를 적용하는 방법

C# 이미지 보정 필터를 사용하여 바코드 디코딩 개선하기

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronBarcodeSharpenFilterContrastFilter와 같은 내장 이미지 보정 필터를 제공하여 흐릿하거나 불완전한 바코드 이미지를 프로그래밍적으로 개선하여 외부 이미지 편집 소프트웨어나 이미지를 다시 캡처하지 않고도 읽기 정확도를 향상시킵니다.

모든 이미지가 완벽하지는 않으며, 이미지 품질이 저하된 것은 IronBarcode에서 바코드를 성공적으로 읽지 못하게 만드는 주요 요인 중 하나입니다. 이미지를 재촬영하거나 외부 이미지 향상 소프트웨어를 사용하는 대신, IronBarcode는 프로그램적으로 이미지 품질을 향상시키는 내장 필터를 제공합니다. 이러한 필터는 IronBarcode가 어려운 이미지를 읽고 전반적인 정확성을 향상시키는 데 도움을 줍니다.

계속 읽어가며 IronBarcode에서 사용할 수 있는 이미지 보정 필터, 그 필터가 이미지에 미치는 영향, 그리고 그것을 적용하는 방법에 대해 알아보세요. 보다 포괄적인 바코드 읽기 기법은 바코드 읽기 튜토리얼을 확인하세요.

빠른 시작: 바코드 읽기를 개선하기 위한 샤프닝 및 대비 필터 적용

단계에서는 IronBarcode의 SharpenFilterContrastFilterBarcodeReaderOptions에서 ImageFilterCollection을 사용하여 적용할 수 있습니다. 이 방법은 최소한의 설정과 외부 도구의 필요 없이 바코드 스캐닝을 개선합니다.

  1. NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/BarCode 설치하기

    PM > Install-Package BarCode
  2. 다음 코드 조각을 복사하여 실행하세요.

    BarcodeResults results = IronBarCode.BarcodeReader.Read("input.png", new IronBarCode.BarcodeReaderOptions { ImageFilters = new IronBarCode.ImageFilterCollection() { new IronBarCode.SharpenFilter(3.5f), new IronBarCode.ContrastFilter(2.0f) } });
  3. 실제 운영 환경에서 테스트할 수 있도록 배포하세요.

    무료 체험판으로 오늘 프로젝트에서 IronBarcode 사용 시작하기

    arrow pointer

이미지 필터를 적용하여 바코드 읽기를 개선하는 방법은?

필터를 적용하려면 ImageFilterCollection 클래스를 인스턴스화하고 각 필터의 인스턴스를 개별적으로 생성하세요. 그런 다음 객체를 ImageFilters 객체의 BarcodeReaderOptions 속성에 할당하세요. 옵션 객체를 샘플 이미지와 함께 Read 메소드에 전달하세요. 고급 설치 옵션은 NuGet 패키지 가이드를 확인하세요.

아래 이미지를 샘플 이미지로 사용하십시오.

Blurred barcode with number 4900203187590 showing poor image quality before filtering enhancement

이미지가 상당히 흐릿하게 보입니다. 그러나 밝기는 적절하며, 흰색과 검정색은 구분 가능합니다. 따라서 바코드 가독성을 개선하기 위해 SharpenFilterContrastFilter는 최소한으로 적용하세요. 아래 코드 조각을 참조하여 이미지에 필터를 적용하여 이를 읽고 콘솔에 결과를 표시하세요.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-apply-filter.cs
using IronBarCode;
using System;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection()
    {
        new SharpenFilter(3.5f),
        new ContrastFilter(2)
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Write the result value to console
foreach (BarcodeResult result in results)
{
    Console.WriteLine(result.Text);
}
$vbLabelText   $csharpLabel

위의 코드 조각은 필터를 적용하고 바코드를 읽고 필터링된 이미지를 디스크에 내보냅니다. 샘플 이미지와 필터링된 이미지의 비교가 아래에 나와 있습니다.

Blurry barcode image with number 4902030187590 demonstrating poor image quality
Barcode with improved readability after applying image filters, showing clear vertical lines and number 4902030187590

IronBarcode에서는 어떤 이미지 보정 필터를 제공하나요?

IronBarcode는 이미지 보정에 특별히 설계된 여러 이미지 필터를 제공합니다. 이 필터들은 불완전한 바코드 이미지를 읽고, 읽기 정확성을 향상시키는 데 도움을 줍니다. 그러나 이 필터가 작동하는 방식을 이해하여 적합한 필터 선택여러 필터 사용 시 또는 잘못된 필터 사용 시 발생할 수 있는 성능 문제 방지를 피하십시오. 사용 가능한 필터에는 다음이 포함됩니다:

  • AdaptiveThresholdFilter
  • BinaryThresholdFilter
  • BrightnessFilter
  • ContrastFilter
  • InvertFilter
  • SharpenFilter
  • ErodeFilter
  • DilateFilter
  • HistogramEqualizationFilter
  • 블러 필터
    • GaussianBlurFilter
    • BilateralFilter
    • MedianBlurFilter

필터가 적용되는 순서는 ImageFilterCollection 내 위치에 따라 결정됩니다. 이 필터들에 대한 자세한 API 문서는 API 참고서를 방문하세요.

적응형 임계값 필터는 어떻게 작동하나요?

AdaptiveThresholdFilter는 이미지를 이진화하기 위한 임계값을 자동으로 결정하는 Bradley Adaptive Threshold 기법을 이미지에 적용하는 IronBarcode에서 제공되는 필터입니다. 이 필터는 조명이 일정하지 않고 배경 밝기 수준이 다양한 이미지에 이상적입니다.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-adaptive-threshold.cs
using IronBarCode;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new AdaptiveThresholdFilter(0.9f),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Export file to disk
results.ExportFilterImagesToDisk("adaptiveThreshold_0.9.png");
$vbLabelText   $csharpLabel

아래는 다양한 값을 사용하여 필터를 적용한 결과입니다.

Vertical lines showing different adaptive threshold filter outputs with solid and dashed patterns
Low-quality barcode image showing UPC number 902030187590 with significant visual distortion

생성자는 구성에 대한 추가 매개변수를 허용합니다:

  • Upper: 문턱값을 위한 상위(흰색) 색상.
  • Lower: 문턱값을 위한 하위(검은색) 색상.
  • Threshold: 이진화를 위한 문턱값 한계(0.0-1.0).
  • Rectangle: 프로세서를 적용할 사각형 영역.

위의 출력 이미지에 나와 있듯이 이미지는 검정색만 남도록 이진화되었습니다. 바코드 읽기에는 여전히 이상적이지 않은 것처럼 보이지만, 필터는 조합하여 사용해야 합니다. 최상의 결과를 얻기 위해 매개변수 민감도를 실험해 보십시오.

바이너리 임계값 필터는 어떻게 작동합니까?

BinaryThresholdFilter은 주어진 임계값에서 픽셀을 분할하여 색상 요소의 밝기를 비교하여 이미지를 필터링합니다. AdaptiveThresholdFilter와 유사하게, 이 필터는 올바르게 사용되지 않으면 새롭거나 원치 않는 노이즈를 소개할 수 있습니다. 그러나 IronBarcode는 필터 속성에 대한 기본값을 설정했습니다.

AdaptiveThresholdFilter와 유사하게, BinaryThresholdFilter는 구성에 대한 동일한 추가 매개변수를 허용합니다:

  • Upper: 문턱값을 위한 상위(흰색) 색상.
  • Lower: 문턱값을 위한 하위(검은색) 색상.
  • Threshold: 이진화를 위한 문턱값 한계(0.0-1.0).
  • Rectangle: 프로세서를 적용할 사각형 영역.
:path=/static-assets/barcode/content-code-examples/how-to/image-correction-binary-threshold.cs
using IronBarCode;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new BinaryThresholdFilter(0.9f)
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Export file to disk
results.ExportFilterImagesToDisk("binaryThreshold_0.9.png");
$vbLabelText   $csharpLabel

아래는 샘플 이미지에 필터를 적용한 샘플 출력입니다.

Three examples of binary threshold filter outputs showing sparse, dotted, and dense vertical line patterns
Barcode image processed with 0.9 binary threshold filter showing black and white contrast

위의 출력 이미지를 관찰하면 샘플이 흑백으로 이진화되었습니다. 그러나 이 필터는 명백히 이 이미지에 적합하지 않습니다. 바코드 막대가 제거되고 새로운 소음이 발생하기 때문입니다. 어려운 바코드 시나리오를 처리하려면 우리의 인식되지 않는 바코드에 대한 문제 해결 가이드를 참조하세요.

더 나은 바코드 읽기를 위해 이미지 밝기는 어떻게 조정하나요?

BrightnessFilter는 IronBarcode의 이미지 필터 컬렉션에서 또 다른 필수 필터입니다. 이름에서 알 수 있듯이, 이 필터는 바코드 이미지의 밝기를 조정합니다. 이 생성자의 입력은 출력 이미지의 밝기 을 변하게 합니다. 기본값은 1이며, 이는 이미지를 변경하지 않습니다. 값이 0이면 완전히 검은색 이미지를 생성하며, 1보다 큰 값은 이미지를 더 밝게 만듭니다.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-brightness.cs
using IronBarCode;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new BrightnessFilter(1.5f),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Export file to disk
results.ExportFilterImagesToDisk("brightness_1.5.png");
$vbLabelText   $csharpLabel

아래는 샘플 입력에 이 필터를 적용한 후의 출력 이미지입니다.

Blurry UPC barcode sample showing default brightness level before filter enhancement
Blurry barcode with product number 4902030187590, demonstrating low brightness or poor image quality

바코드 이미지를 향상시키기 위해 대비 필터를 어떻게 사용하나요?

ContrastFilter는 이미지의 대비 수준을 조정합니다. 이미지 대비는 이미지 내부의 다양한 요소 간의 색상 강도의 차이를 나타냅니다. 대비 수준을 높이면 세부 사항의 가시성이 향상되어 이미지가 생생하고 인상적으로 보이며, 대비를 줄이면 이미지가 부드럽고 차분하게 보입니다. 바코드 맞춤화에 대한 자세한 내용은 바코드 스타일 맞춤화하는 방법 가이드를 참조하세요.

기본값은 1이며, 이는 이미지를 변경하지 않습니다. 값이 0이면 완전히 회색 이미지를 생성하며, 1보다 큰 값은 이미지 대비를 증가시킵니다.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-contrast.cs
using IronBarCode;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new ContrastFilter(1.5f),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Export file to disk
results.ExportFilterImagesToDisk("contrast_1.5.png");
$vbLabelText   $csharpLabel

이 필터를 샘플 입력에 적용하면 아래의 이미지가 생성됩니다.

Blurry barcode with number 4902030187590 demonstrating default contrast filter settings
Blurry barcode with number 4902030187590 demonstrating low contrast image quality

반전 필터는 언제 사용해야 하나요?

이 필터는 이미지 내부의 색상을 반전시켜 반대 색상을 만들며, 예를 들어 흰색은 검정이 되고 검정은 흰색이 됩니다. 배경색이 있는 바코드 이미지를 읽을 때 특히 유용합니다. BinaryThresholdFilter와 달리, 이 필터는 민감도를 지정할 필요 없이 색상을 직접 반전시킵니다. 또한, 이 필터는 CropRectangle과 함께 사용되어 전체 이미지 대신 색상을 반전해야 할 이미지 내 위치를 지정할 수 있습니다. 크롭 영역 지정 자습서에서 크롭 영역 지정에 대해 자세히 알아보세요.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-invert.cs
using IronBarCode;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new InvertFilter(),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Export file to disk
results.ExportFilterImagesToDisk("invert.png");
$vbLabelText   $csharpLabel

아래의 출력 이미지는 샘플 입력 이미지에 이 필터를 적용한 결과입니다.

Blurry UPC barcode showing number 480203187590 - original image before invert filter application
Blurry inverted barcode showing white bars on dark background with number sequence 4902030187590

Sharpen 필터로 흐릿한 바코드 이미지를 어떻게 수정하나요?

IronBarcode는 선명화 필터를 제공합니다. 이 필터는 이미지의 선명도를 높이며 흐릿한 이미지를 처리할 때 매우 유용합니다. 이 필터는 필터 객체를 인스턴스화할 때 Sigma 값을 조정하여 이미지의 선명도를 조정할 수 있습니다. 기본값은 3입니다. 시그마 값을 높이면 이미지의 선명도가 증가합니다. 다른 성능 최적화 옵션은 읽기 속도 옵션 가이드를 확인하세요.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-sharpen.cs
using IronBarCode;
using System;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new SharpenFilter(0.5f),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Export file to disk
results.ExportFilterImagesToDisk("sharpen_0.5.png");
$vbLabelText   $csharpLabel

The image below is the sharpened version of the sample input image.

Blurry barcode image demonstrating unsharpened quality before applying sharpen filter
Blurred barcode example showing effects of image quality degradation

위의 이미지와 원본 이미지를 비교하면 더 선명해보이며, IronBarcode를 사용한 바코드 읽기에 도움이 됩니다. 대부분의 경우, SharpenFilter는 항상 ImageFilterCollection 클래스의 다른 필터와 함께 적용됩니다.

침식 필터는 무엇에 사용됩니까?

ErodeFilter는 작은 흰색 소음을 제거하고 모양 가장자리 근처의 픽셀을 제거하여 바코드 막대를 두껍게 합니다. 이 필터는 바코드 배경에 많은 흰 반점이 있거나 바코드 이미지의 해상도가 너무 낮거나 흐릿하여 막대가 합쳐지는 경우에 가장 잘 사용됩니다. ErodeFilter는 바의 두께를 증가시키면서 배경의 흰 반점을 제거합니다. 불완전한 이미지를 처리하는 방법에 대한 더 많은 정보는 우리의 불완전한 바코드 예제를 참조하세요.

필터를 위한 kernelSize을 나타내는 정수를 입력하여 부식 효과를 증가시키세요. 커널 크기가 클수록 입력 이미지에 대한 효과가 강해집니다. kernelSize은 정사각형이며 이 예에서는 5x5 커널이 됩니다.

예를 들어, ErodeFilter에 큰 커널 크기를 사용하여 필터의 효과를 보여줍니다.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-erode.cs
using IronBarCode;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new ErodeFilter(5),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Export file to disk
results.ExportFilterImagesToDisk("erodeFilter.jpg");
$vbLabelText   $csharpLabel
Blurry barcode showing number 4002030187590 - example for erode filter demonstration
Blurred barcode showing vertical black and white stripes with numerical code

위의 입력 및 출력 이미지를 비교하면, 필터입력에 더 큰 커널 크기를 사용한 공격적인 특성으로 인해 일부 막대가 눈에 띄게 두꺼워진 것을 알 수 있습니다. 그러나 전체 이미지의 흰 점들은 줄어들었습니다. 침식 필터 특성상 커널 크기가 커질수록 위의 그림에서처럼 너무 공격적으로 적용되면 얇은 막대를 지울 수 있습니다. ErodeFilter에 입력하는 커널 크기 값을 변경하여 효과를 테스트하고 개선하세요.

확장 필터가 바코드 읽기에 어떻게 도움이 됩니까?

DilateFilterErodeFilter의 역으로 작동하며, 주로 배경인 밝은 영역을 객체 경계에 픽셀을 추가하여 확장합니다. 이 필터는 작은 간격을 메우거나 저대비 영역을 강화하여 손상되거나 흐릿한 바코드를 수리하는 동안, 바코드 막대에 대한 효과는 직관과 다릅니다. 확장은 밝은 공간을 확장하므로, 결과적으로 어두운 요소(흰색 배경이 있다고 가정하여)인 검은 바코드 막대는 얇아집니다. 이 필터는 특히 바코드 막대가 너무 두껍거나 결합된 경우에 효과적이지만, 과도한 사용은 막대를 지나치게 좁게 만들어 스캔 정확도를 떨어뜨릴 수 있습니다.

위와 마찬가지로 필터를 위한 kernelSize을 나타내는 정수를 입력하여 필터의 효과를 증가시키세요.

아래의 예에서, DilateFilter의 효과를 보여주기 위해 큰 커널 크기를 사용하십시오.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-dilate.cs
using IronBarCode;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new DilateFilter(5),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Export file to disk
results.ExportFilterImagesToDisk("dilateFilter.jpg");
$vbLabelText   $csharpLabel
Blurry barcode image showing number 4902030187590 - example for dilate filter processing
Blurred barcode with numerical sequence below vertical bars

위의 이미지에서 볼 수 있듯이 DilateFilter의 공격적인 사용은 바코드 구조를 파괴하여 서로 가까운 막대를 결합하고 조용한 영역을 생성할 수 있습니다. 입력 이미지에 따라 커널 크기 값을 크게 하거나 작게 변경하여 이미지의 효과를 테스트하고 개선하세요.

히스토그램 균등화 필터는 언제 사용해야 합니까?

HistogramEqualizationFilter는 이미지의 명도를 개선하기 위해 픽셀의 강도를 재분배하여 이미지 명암 대비를 향상시킵니다. 주로 명암 대비가 낮고 이미지가 흐릿하거나 자연광이 떨어지는 그림자나 밝은 빛 반사 같은 것들이 있는 경우에 사용됩니다. 픽셀 밝기 분포인 이미지 히스토그램을 분석함으로써 어두운 픽셀은 더 어두워지고 밝은 픽셀은 더 밝아지는 강도 범위를 확장하여 픽셀 값을 재분배하여 명암 대비를 강화합니다.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-histogram-equalization-filter.cs
using IronBarCode;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new HistogramEqualizationFilter(),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.png", options);

// Export file to disk
results.ExportFilterImagesToDisk("histogramEqualizationFilter.jpg");
$vbLabelText   $csharpLabel
Blurry barcode with number 4902030187590 used as test image for histogram equalization filter
Barcode with vertical black and white stripes showing number 4902030187590

위의 이미지에서 볼 수 있듯이, 원본 이미지에 비해 검은 막대는 더 어두워 보여지고 공간은 더 밝아 보입니다.

바코드 노이즈 감소에 도움이 되는 블러 필터는 무엇입니까?

가우시안 블러 필터가 이미지 노이즈를 어떻게 줄입니까?

GaussianBlurFilter는 이미지에 가우시안 블러를 적용합니다. 이 필터는 보통 이미지의 노이즈를 줄입니다. 불완전한 바코드 처리를 다루기 위한 포괄적인 가이드를 보려면 이미지 방향 수정 튜토리얼을 참조하십시오.

이 필터는 가우시안 함수를 사용하여 이미지의 인접한 픽셀 값을 평균하여 작동합니다. 이 방법은 두 가지 조정 가능한 요소에 의존합니다:

  • Kernel: 픽셀을 평균화하는 데 사용되는 행렬.
  • Sigma: 블러 강도를 제어하는 값.

기본 kernel 크기는 3x3 픽셀이며, 기본 Sigma 값은 3.0로, 중간 정도의 흐림을 생성합니다. Sigma 값을 증가시키면 더 강한 블러 효과가 발생합니다. 블러 필터가 평균을 내는 이웃의 크기를 제어하기 위해 kernel을 사용자 정의할 수 있습니다.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-gaussianblur.cs
using IronBarCode;

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new GaussianBlurFilter(3, 3, 3.0f),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sharpen.webp", myOptionsExample);

// Export file to disk
results.ExportFilterImagesToDisk("gaussianBlur.png");
$vbLabelText   $csharpLabel

이 필터를 샘플 입력에 적용하면 아래의 이미지가 생성됩니다.

Blurry barcode with number 4902030187590 demonstrating poor image quality
Barcode image with Gaussian blur filter applied, showing blurred vertical lines and distorted numbers

쌍방형 필터는 언제 사용해야 합니까?

BilateralFilter는 가장자리를 유지하면서 이미지를 부드럽게 합니다. 단순한 블러 기법이 모든 픽셀에 동일하게 영향을 주는 것과 달리, 쌍방형 필터는 색상 차이와 픽셀 거리를 모두 고려하여 가장자리 보존에 효과적입니다.

이 방법은 세 가지 조정 가능한 요인에 의존합니다:

  • NeighborhoodDiameter: 픽셀 이웃의 직경(기본값: 5).
  • SigmaColor: 색상 차이 영향 수준을 결정하는 색상 영향력(기본값: 75.0).
  • SigmaSpace: 거리 영향을 결정하는 공간 영향력(기본값: 75.0).
:path=/static-assets/barcode/content-code-examples/how-to/image-correction-bilateral.cs
using IronBarCode;

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new BilateralFilter(5, 75, 75),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sharpen.webp", myOptionsExample);

// Export file to disk
results.ExportFilterImagesToDisk("bilateral.png");
$vbLabelText   $csharpLabel

이 필터를 샘플 입력에 적용하면 아래의 이미지가 생성됩니다.

Blurred barcode demonstrating poor image quality with vertical lines and numbers 4902030187590
Blurred barcode with numbers 4902030187590 demonstrating poor image quality

노이즈 감소에 있어 MedianBlur 필터의 차별점은 무엇입니까?

MedianBlurFilter는 주변 픽셀의 중간값으로 각 픽셀의 값을 대체하여 이미지의 노이즈를 줄입니다. 이 필터는 특히 가장자리를 보존하면서 노이즈를 제거하는 데 뛰어납니다. 바코드 읽기 설정에 대해 더 알아보려면 바코드 읽기 설정 가이드를 방문하세요.

  • KernelSize: 중앙값 계산을 위한 이웃의 크기(홀수여야 함, 기본값: 5).
:path=/static-assets/barcode/content-code-examples/how-to/image-correction-medianblur.cs
using IronBarCode;

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new MedianBlurFilter(5),
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sharpen.webp", myOptionsExample);

// Export file to disk
results.ExportFilterImagesToDisk("medianBlur.png");
$vbLabelText   $csharpLabel

이 필터를 샘플 입력에 적용하면 아래의 이미지가 생성됩니다.

Blurry barcode example showing poor image quality with digital artifacts and reduced readability
Barcode with median blur filter applied showing blurred vertical lines and number 4902030187590

각 처리 단계에서 필터링된 이미지를 저장하는 방법은?

바코드에 여러 필터를 적용할 때, 각 필터 방법 후에 출력을 보는 것이 어려울 수 있습니다. 이 기능은 각 필터가 적용된 후, 처리된 순서대로 필터링된 이미지를 저장할 수 있게 해줍니다. 이 기능을 활성화하려면 먼저 trueImageFilterCollection 생성자에 전달하십시오. 그런 다음 ExportFilterImagesToDisk 메서드를 사용하여 출력 이미지의 경로와 이름을 제공합니다. 바코드를 저장하는 방법에 대한 더 많은 예제는 바코드를 이미지로 변환하는 예제를 참조하십시오.

:path=/static-assets/barcode/content-code-examples/how-to/image-correction-save-iterations.cs
using IronBarCode;

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Choose which filters are to be applied (in order)
    ImageFilters = new ImageFilterCollection(true) {
        new SharpenFilter(3.5f),
        new AdaptiveThresholdFilter(0.5f),
        new ContrastFilter(2)
    },
};

// Apply options and read the barcode
BarcodeResults results = BarcodeReader.Read("sample.webp", myOptionsExample);

// Export file to disk
results.ExportFilterImagesToDisk("filteredImage.png");
$vbLabelText   $csharpLabel

코드의 순서대로 필터가 적용되며 출력 이미지는 각 반복의 결과를 반영합니다:

  • Sharpen -> After Sharpen
  • Sharpen + AdaptiveThreshold -> After AdaptiveThreshold
  • Sharpen + AdaptiveThreshold + Contrast -> After Contrast
Blurry barcode with number 4902030187590
Blurry UPC barcode showing number 4902030187590
Degraded barcode example showing poor image quality with number 9020301875905
Heavily pixelated barcode with UPC number 902030187590

ImageFilters 속성 외에도 BarcodeReaderOptions에 다른 속성을 추가하여 더 정확한 읽기를 합니다; 더 많은 정보는 이 기사를 참고하십시오.

자주 묻는 질문

이미지 보정 필터란 무엇이며 바코드 판독에 왜 필요한가요?

IronBarcode의 이미지 보정 필터는 흐릿하거나 불완전한 바코드 이미지를 프로그램적으로 개선하는 내장 도구입니다. 이미지 품질 저하는 바코드 판독 실패의 주요 원인 중 하나이기 때문에 이러한 필터는 필수적입니다. IronBarcode는 외부 이미지 편집 소프트웨어를 사용하거나 이미지를 다시 촬영할 필요 없이 판독 정확도를 향상시키는 SharpenFilter 및 ContrastFilter와 같은 필터를 제공합니다.

바코드 스캔 품질을 향상시키기 위해 이미지 보정 필터를 적용하는 방법은 무엇인가요?

IronBarcode에서 필터를 적용하려면 ImageFilterCollection 인스턴스를 생성하고 개별 필터 인스턴스를 추가합니다. 그런 다음 이 컬렉션을 BarcodeReaderOptions의 ImageFilters 속성에 할당하고 Read 메서드에 전달합니다. 예를 들면 다음과 같습니다. new BarcodeReaderOptions { ImageFilters = new ImageFilterCollection() { new SharpenFilter(3.5f), new ContrastFilter(2.0f) } }.

흐릿한 바코드 이미지에 적합한 이미지 필터는 무엇인가요?

흐릿한 바코드 이미지의 경우, IronBarcode는 SharpenFilter와 ContrastFilter를 모두 사용할 것을 권장합니다. SharpenFilter는 흐릿한 이미지의 가장자리 선명도를 높여주고, ContrastFilter는 밝은 영역과 어두운 영역의 구분을 명확하게 해줍니다. 이 두 필터는 함께 작동하여 별도의 이미지 처리 없이도 바코드를 더 읽기 쉽게 만들어 줍니다.

이미지 보정 필터의 강도를 사용자 지정할 수 있나요?

네, IronBarcode에서는 각 필터에 사용자 지정 값을 설정할 수 있습니다. 예를 들어, SharpenFilter는 선명도 강도를 조절하는 부동 소수점 매개변수(예: 3.5f)를 허용하고, ContrastFilter는 대비 수준을 조정하는 매개변수(예: 2.0f)를 허용합니다. 이러한 사용자 지정 기능을 통해 다양한 이미지 환경에 맞춰 필터 효과를 최적화할 수 있습니다.

바코드 이미지를 개선하려면 외부 이미지 편집 도구가 필요한가요?

아니요, IronBarcode는 내장 이미지 보정 필터를 제공하여 외부 이미지 편집 도구가 필요하지 않도록 합니다. SharpenFilter 및 ContrastFilter와 같은 이러한 프로그래밍 방식 필터는 .NET 애플리케이션 내에서 직접 이미지 품질을 향상시켜 시간을 절약하고 타사 소프트웨어에 대한 의존성을 없애줍니다.

하릴 하시미 빈 오마르
소프트웨어 엔지니어
모든 훌륭한 엔지니어처럼, 하이릴은 열정적인 학습자입니다. 그는 C#, Python, Java에 대한 지식을 갈고닦아 Iron Software의 팀원들에게 가치를 더하고 있습니다. 하이릴은 말레이시아의 Universiti Teknologi MARA에서 화학 및 공정 공학 학사 학위를 취득한 후 Iron Software 팀에 합류했습니다.
시작할 준비 되셨나요?
Nuget 다운로드 2,108,094 | 버전: 2026.3 방금 출시되었습니다
Still Scrolling Icon

아직도 스크롤하고 계신가요?

빠른 증거를 원하시나요? PM > Install-Package BarCode
샘플을 실행하세요 실이 바코드로 변하는 모습을 지켜보세요.