C# IronOCR OCR 프로그램 이미지 필터를 사용한 이미지 텍스트 변환 정확도 향상 가이드
IronOCR OCR 프로그램은 이미지 텍스트 변환 전 전처리가 필요한 이미지를 읽는 데 필요한 도구를 필터 형태로 제공합니다. 이미지를 편집 가능한 형태로 변환하기 위해 다양한 필터 중에서 선택할 수 있습니다.
빠른 시작: OCR 이미지 정리를 위한 필터 적용
간단한 호출 체인 하나로, OCR 전 스캔 명확성을 향상시키기 위해 DeNoise, Binarize, Deskew 필터를 적용할 수 있습니다. 이 예시는 IronOCR의 내장 필터를 사용하여 이미지를 얼마나 쉽게 향상시킬 수 있는지, 그리고 바로 시작할 수 있는 방법을 보여줍니다.
-
NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/IronOcr 설치하기
PM > Install-Package IronOcr -
다음 코드 조각을 복사하여 실행하세요.
using var input = new IronOcr.OcrInput("scan.jpg"); input.DeNoise(true).Binarize().Deskew(45); var result = new IronOcr.IronTesseract().Read(input); -
실제 운영 환경에서 테스트할 수 있도록 배포하세요.
무료 체험판으로 오늘 프로젝트에서 IronOCR 사용 시작하기
OCR 이미지 필터 목록
다음 이미지 필터는 성능을 크게 향상시킬 수 있습니다.
Filters to change the Image OrientationRotate- 이미지를 시계 방향으로 일정 각도만큼 회전시킵니다. 반시계 방향은 음수를 사용하세요.Deskew- 이미지를 올바른 방향으로 정렬하고 직교하게 만듭니다. 이는 OCR에 매우 유용한데, Tesseract는 기울어진 스캔에 대해 5도 정도의 허용 오차를 가질 수 있기 때문입니다.Scale- OCR 입력 페이지의 크기를 비례적으로 조정합니다.
Filters to manipulate Image ColorsBinarize- 이 이미지 필터는 모든 픽셀을 중간색 없이 검은색 또는 흰색으로 만듭니다. 이는 텍스트와 배경의 대비가 매우 낮은 경우 OCR 성능을 향상시킬 수 있습니다.ToGrayScale- 이 이미지 필터는 모든 픽셀을 회색 음영으로 만듭니다. OCR 정확도는 향상되지 않을 가능성이 높지만 속도는 향상될 수 있습니다.Invert- 모든 색상을 반전시킵니다. 예를 들어 흰색이 검은색이 되고 검은색이 흰색이 됩니다.ReplaceColor- 이미지의 특정 한계 내에서 한 색상을 다른 색상으로 대체합니다.
Filters to improve Contrast in an ImageContrast- 대비를 자동으로 증가시킵니다. 이 필터는 종종 대비가 낮은 스캔 이미지에서 OCR 속도와 정확도를 향상시킵니다.Dilate- 고급 형태학. _팽창_은 이미지에서 객체의 경계에 픽셀을 추가합니다. 에로드의 정반대.Erode- 고급 형태학. _침식_은 객체 경계에서 픽셀을 제거합니다. 확장하다의 반대말.
Filters to reduce Image NoiseSharpen- 흐릿한 OCR 문서를 선명하게 하고 알파 채널을 흰색으로 평면화합니다.DeNoise- 디지털 노이즈를 제거합니다. 이 필터는 노이즈가 예상되는 시나리오에서만 사용해야 합니다.EnhanceResolution- 저품질 이미지의 해상도를 향상시킵니다. 이 필터는 _OcrInput.MinimumDPI와OcrInput.TargetDPI_가 저해상도 입력을 자동으로 감지하고 해결하므로 자주 필요하지 않습니다.
필터 예시 및 사용법
다음 예제에서는 코드 내에 필터를 적용하는 방법을 보여줍니다.
:path=/static-assets/ocr/content-code-examples/tutorials/c-sharp-ocr-image-filters-1.cs
using IronOcr;
using System;
var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadImage("my_image.png");
input.Deskew();
var result = ocr.Read(input);
Console.WriteLine(result.Text);
Imports IronOcr
Imports System
Private ocr = New IronTesseract()
Private input = New OcrInput()
input.LoadImage("my_image.png")
input.Deskew()
Dim result = ocr.Read(input)
Console.WriteLine(result.Text)
디버그 필터 / 필터는 어떤 역할을 하나요?
프로그램에서 이미지나 바코드를 읽는 데 어려움이 있는 경우, 필터링된 결과를 이미지로 저장하는 방법이 있습니다. 이렇게 하면 디버깅을 통해 각 필터가 정확히 어떤 역할을 하고 이미지를 어떻게 조작하는지 확인할 수 있습니다.
:path=/static-assets/ocr/content-code-examples/tutorials/c-sharp-ocr-image-filters-2.cs
using IronOcr;
using System;
var file = "skewed_image.tiff";
var ocr = new IronTesseract();
using var input = new OcrInput();
var pageindices = new int[] { 1, 2 };
input.LoadImageFrames(file, pageindices);
// Here we apply the filter: Deskew
input.Deskew();
// Save the input with filter(s) applied
input.SaveAsImages("my_deskewed");
// We read, then print the text to the console
var result = ocr.Read(input);
Console.WriteLine(result.Text);
Imports IronOcr
Imports System
Private file = "skewed_image.tiff"
Private ocr = New IronTesseract()
Private input = New OcrInput()
Private pageindices = New Integer() { 1, 2 }
input.LoadImageFrames(file, pageindices)
' Here we apply the filter: Deskew
input.Deskew()
' Save the input with filter(s) applied
input.SaveAsImages("my_deskewed")
' We read, then print the text to the console
Dim result = ocr.Read(input)
Console.WriteLine(result.Text)
필터 사용 사례
회전
필터 설명
회전 필터는 이미지를 수동으로 회전시켜 거의 직선에 가깝게 만드는 데 사용됩니다. IronOCR에는 Deskew()를 실행할 기능이 있지만, 허용 범위는 매우 좁고 거의 완전히 직선인 이미지(약 15도 이내)에 가장 적합합니다. 입력 이미지가 90도 꺾이거나 거꾸로 되어 있는 경우 Rotate()를 호출해야 합니다.
사용 사례 코드 예제
이것은 거꾸로 된 이미지를 수정하기 위해 Rotate()를 호출하는 예입니다:
:path=/static-assets/ocr/content-code-examples/tutorials/c-sharp-ocr-image-filters-3.cs
using IronOcr;
using System;
var image = "screenshot.png";
var ocr = new IronTesseract();
using var input = new OcrInput();
// Load at least one image
input.LoadImage(image);
// Rotate 180 degrees because image is upside-down
input.Rotate(180);
// Read image into variable: result
var result = ocr.Read(input);
// Example print to console
Console.WriteLine(result.Text);
Imports IronOcr
Imports System
Private image = "screenshot.png"
Private ocr = New IronTesseract()
Private input = New OcrInput()
' Load at least one image
input.LoadImage(image)
' Rotate 180 degrees because image is upside-down
input.Rotate(180)
' Read image into variable: result
Dim result = ocr.Read(input)
' Example print to console
Console.WriteLine(result.Text)
| `` | `` |
|---|---|
![]() |
![]() |
디스큐
필터 설명
허프 변환을 사용하여 특정 허용 오차 범위 내에서 이미지를 똑바로 맞추려고 시도합니다. 이는 이미지가 완전히 똑바로 정렬되어 있지 않은 경우에 중요합니다. 문서가 기울어지면 잘못 읽힐 수 있기 때문입니다.
사용 사례 코드 예제
이것은 기울어진 이미지를 수정하기 위해 Deskew()를 호출하는 예입니다:
:path=/static-assets/ocr/content-code-examples/tutorials/c-sharp-ocr-image-filters-4.cs
using IronOcr;
using System;
var image = @"paragraph_skewed.png";
var ocr = new IronTesseract();
using var input = new OcrInput();
// Load at least one image
input.LoadImage(image);
// Apply deskew with 15 degree snap
bool didDeskew = input.Deskew(15);
if (didDeskew)
{
// Read image into variable: result
var result = ocr.Read(input);
Console.WriteLine(result.Text);
}
else
{
Console.WriteLine("Deskew not applied because Image Orientation could not be determined.");
}
Imports IronOcr
Imports System
Private image = "paragraph_skewed.png"
Private ocr = New IronTesseract()
Private input = New OcrInput()
' Load at least one image
input.LoadImage(image)
' Apply deskew with 15 degree snap
Dim didDeskew As Boolean = input.Deskew(15)
If didDeskew Then
' Read image into variable: result
Dim result = ocr.Read(input)
Console.WriteLine(result.Text)
Else
Console.WriteLine("Deskew not applied because Image Orientation could not be determined.")
End If
규모
필터 설명
크기 조절은 이미지에 이미 있는 픽셀을 사용하여 이미지 크기를 조정하는 데 도움이 되는 유용한 이미지 조작 필터입니다. 이 기능은 이미지가 수십 픽셀 너비에 불과하여 각 막대가 한 픽셀을 차지하는 경우처럼 바코드를 스캔할 수 없거나, 텍스트가 너무 작아서 앤티앨리어싱이 적용되지 않은 경우에 사용할 수 있습니다.
1000px x 1000px의 달콤한 지점이 있으며 바코드가 잘 읽혀지며, 바코드가 발견되지 않을 경우 고려해야 합니다.사용 사례 코드 예제
바코드의 막대들 사이의 간격을 스캔을 위해 넓히기 위해 Scale()를 호출하는 예입니다:
:path=/static-assets/ocr/content-code-examples/tutorials/c-sharp-ocr-image-filters-5.cs
using IronOcr;
using System;
var image = @"small_barcode.png";
var ocr = new IronTesseract();
// Optional: This example uses a barcode
ocr.Configuration.ReadBarCodes = true;
using var input = new OcrInput();
// Load at least one image
input.LoadImage(image);
// Apply scale
input.Scale(400); // 400% is 4 times larger
// Read image into variable: result
var result = ocr.Read(input);
// Example print to console
Console.WriteLine(result.Text);
Imports IronOcr
Imports System
Private image = "small_barcode.png"
Private ocr = New IronTesseract()
' Optional: This example uses a barcode
ocr.Configuration.ReadBarCodes = True
Dim input = New OcrInput()
' Load at least one image
input.LoadImage(image)
' Apply scale
input.Scale(400) ' 400% is 4 times larger
' Read image into variable: result
Dim result = ocr.Read(input)
' Example print to console
Console.WriteLine(result.Text)
이진화
필터 설명
이진화 필터는 적응형 알고리즘에 따라 이미지의 모든 픽셀을 검정색 또는 흰색으로 분류합니다. 이 기능은 모든 색상을 제거하고 배경을 흰색으로 분리하며, 텍스트로 인식된 부분은 읽기 쉽도록 완전히 검은색으로 표시합니다.
사용 사례 코드 예제
색깔 있는 텍스트를 정렬하고 배경색과 노이즈를 제거하기 위해 Binarize()를 호출하는 예입니다:
:path=/static-assets/ocr/content-code-examples/tutorials/c-sharp-ocr-image-filters-6.cs
using IronOcr;
using System;
var image = @"no-binarize.jpg";
var ocr = new IronTesseract();
using var input = new OcrInput();
// Load at least one image
input.LoadImage(image);
// Apply Binarize
input.Binarize();
// Read image into variable: result
var result = ocr.Read(input);
// Example print to console
Console.WriteLine(result.Text);
Imports IronOcr
Imports System
Private image = "no-binarize.jpg"
Private ocr = New IronTesseract()
Private input = New OcrInput()
' Load at least one image
input.LoadImage(image)
' Apply Binarize
input.Binarize()
' Read image into variable: result
Dim result = ocr.Read(input)
' Example print to console
Console.WriteLine(result.Text)
| `` | `` |
|---|---|
![]() |
![]() |
거꾸로 하다
필터 설명
IronOCR는 이미지가 black text on a white background일 때 최상의 읽기 성능을 발휘합니다. Invert 필터는 이미지의 모든 색상을 반전시켜 이를 구현하는 데 사용됩니다.
사용 사례 코드 예제
검은색 배경을 흰색, 흰색 배경을 검은색으로 바꾸기 위해 Invert()를 호출하는 예입니다:
:path=/static-assets/ocr/content-code-examples/tutorials/c-sharp-ocr-image-filters-7.cs
using IronOcr;
using System;
var image = @"before-invert.png";
var ocr = new IronTesseract();
using var input = new OcrInput();
// Load at least one image
input.LoadImage(image);
// Apply Invert
input.Invert(true);
// Read image into variable: result
var result = ocr.Read(input);
// Example print to console
Console.WriteLine(result.Text);
Imports IronOcr
Imports System
Private image = "before-invert.png"
Private ocr = New IronTesseract()
Private input = New OcrInput()
' Load at least one image
input.LoadImage(image)
' Apply Invert
input.Invert(True)
' Read image into variable: result
Dim result = ocr.Read(input)
' Example print to console
Console.WriteLine(result.Text)
Before |
After |
|---|---|
![]() |
![]() |
자주 묻는 질문
C#에서 이미지 필터를 사용하면 OCR 정확도를 어떻게 향상시킬 수 있을까요?
IronOCR의 이미지 필터는 이미지 품질을 향상시켜 OCR 정확도를 높이는 전처리 기능을 제공합니다. 이진화 및 대비 조정 필터는 색상과 대비를 조정하여 가독성을 향상시키고, 회전 및 기울기 보정 필터는 이미지 방향을 교정합니다.
이미지 방향을 보정하는 데 사용할 수 있는 필터는 무엇입니까?
IronOCR은 이미지 방향 문제를 수정하기 위한 회전 및 기울기 보정 필터를 제공합니다. 회전 필터를 사용하면 이미지 각도를 수동으로 조정할 수 있으며, 기울기 보정 필터는 약간 기울어진 이미지를 자동으로 바로잡습니다.
이진화 필터는 이미지 전처리 과정에 어떤 영향을 미치나요?
IronOCR의 이진화 필터는 이미지 픽셀을 흑백으로 변환하여 배경색을 제거하고 텍스트 가시성을 향상시켜, 특히 대비가 낮은 환경에서 OCR 정확도를 높입니다.
노이즈 감소 필터는 언제 사용하는 것이 적절할까요?
선명도 향상 및 노이즈 제거와 같은 노이즈 감소 필터는 이미지에 디지털 노이즈가 있을 때 사용해야 합니다. 이러한 필터는 이미지를 깨끗하게 하여 텍스트를 더욱 선명하게 만들어 IronOCR에서 더 나은 OCR 결과를 얻을 수 있도록 합니다.
이미지 해상도 향상이 OCR 성능에 영향을 미칠 수 있을까요?
네, EnhanceResolution 필터를 사용하면 저품질 이미지의 해상도를 높여 OCR 성능을 향상시킬 수 있습니다. IronOCR의 기본 MinimumDPI 및 TargetDPI 설정으로도 충분한 경우가 많지만, 필요한 경우 이 필터를 통해 해상도를 추가로 향상시킬 수 있습니다.
색상 조작 필터는 OCR에서 어떤 역할을 하나요?
IronOCR의 색상 조작 필터(예: 반전, 회색조 변환, 이진화)는 이미지 색상을 조정하여 텍스트 가독성을 높입니다. 반전은 색 구성표를 변경하고, 회색조 변환은 이미지를 회색조로 변환하며, 이진화는 이미지를 흑백으로 변환합니다.
콘트라스트 필터와 샤프닝 필터의 차이점은 무엇인가요?
IronOCR의 대비 필터는 밝은 영역과 어두운 영역의 차이를 증가시켜 텍스트 선명도를 향상시키고, 선명도 필터는 가장자리를 강조하여 텍스트를 더욱 뚜렷하게 만들어 OCR 인식률을 높이는 데 도움을 줍니다.
IronOCR에서 필터링된 이미지를 저장하고 디버깅하는 방법은 무엇인가요?
IronOCR에서 필터링된 이미지를 저장하고 디버깅하려면 필터를 적용한 후 SaveAsImages 기능을 사용하십시오. 이렇게 하면 필터 효과를 시각화하고 전처리 단계가 OCR을 위한 이미지 품질을 향상시켰는지 확인할 수 있습니다.
IronOCR에서 사용할 수 있는 고급 형태학 필터에는 어떤 것들이 있습니까?
IronOCR은 팽창(Dilate) 및 침식(Erode)과 같은 고급 형태학 필터를 제공합니다. 팽창 필터는 객체 경계에 픽셀을 추가하여 특징을 강조하고, 침식 필터는 경계를 제거하여 이미지 세부 정보를 명확하게 함으로써 OCR 정확도를 향상시킵니다.







