using IronOcr;// Instantiate IronTesseractIronTesseract ocrTesseract = new IronTesseract();// Add imageusing var imageInput = new OcrImageInput("sample.jpg");// Apply binarize affectimageInput.Binarize();// Export the modified imageimageInput.SaveAsImages("binarize.jpg");
using IronOcr;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Add image
using var imageInput = new OcrImageInput("sample.jpg");
// Apply binarize affect
imageInput.Binarize();
// Export the modified image
imageInput.SaveAsImages("binarize.jpg");
ImportsIronOcr' Instantiate IronTesseractPrivate ocrTesseract As New IronTesseract()' Add imagePrivate imageInput = New OcrImageInput("sample.jpg")' Apply binarize affectimageInput.Binarize()' Export the modified imageimageInput.SaveAsImages("binarize.jpg")
Imports IronOcr
' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()
' Add image
Private imageInput = New OcrImageInput("sample.jpg")
' Apply binarize affect
imageInput.Binarize()
' Export the modified image
imageInput.SaveAsImages("binarize.jpg")
using IronOcr;// Instantiate IronTesseractIronTesseract ocrTesseract = new IronTesseract();// Add imageusing var imageInput = new OcrImageInput("sample.jpg");IronSoftware.Drawing.Color currentColor = new IronSoftware.Drawing.Color("#DB645C");IronSoftware.Drawing.Color newColor = IronSoftware.Drawing.Color.DarkCyan;// Replace colorimageInput.ReplaceColor(currentColor, newColor, 80);// Export the modified imageimageInput.SaveAsImages("replaceColor");
using IronOcr;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Add image
using var imageInput = new OcrImageInput("sample.jpg");
IronSoftware.Drawing.Color currentColor = new IronSoftware.Drawing.Color("#DB645C");
IronSoftware.Drawing.Color newColor = IronSoftware.Drawing.Color.DarkCyan;
// Replace color
imageInput.ReplaceColor(currentColor, newColor, 80);
// Export the modified image
imageInput.SaveAsImages("replaceColor");
ImportsIronOcr' Instantiate IronTesseractDim ocrTesseract As New IronTesseract()' Add imageUsing imageInput As New OcrImageInput("sample.jpg") Dim currentColor As New IronSoftware.Drawing.Color("#DB645C") Dim newColor AsIronSoftware.Drawing.Color = IronSoftware.Drawing.Color.DarkCyan ' Replace color imageInput.ReplaceColor(currentColor, newColor, 80) ' Export the modified image imageInput.SaveAsImages("replaceColor")EndUsing
Imports IronOcr
' Instantiate IronTesseract
Dim ocrTesseract As New IronTesseract()
' Add image
Using imageInput As New OcrImageInput("sample.jpg")
Dim currentColor As New IronSoftware.Drawing.Color("#DB645C")
Dim newColor As IronSoftware.Drawing.Color = IronSoftware.Drawing.Color.DarkCyan
' Replace color
imageInput.ReplaceColor(currentColor, newColor, 80)
' Export the modified image
imageInput.SaveAsImages("replaceColor")
End Using
高度な色置換シナリオをどのように扱えばよいですか?
複雑なシナリオのために複数の置換を連鎖させます:
/* :path=/static-assets/ocr/content-code-examples/how-to/image-color-correction-multiple-replacements.cs */// Replace multiple colors in sequenceusing var imageInput = new OcrImageInput("multi-color-document.jpg");// Replace red text with blackimageInput.ReplaceColor(IronSoftware.Drawing.Color.Red, IronSoftware.Drawing.Color.Black, 70);// Replace blue headers with dark grayimageInput.ReplaceColor(IronSoftware.Drawing.Color.Blue, IronSoftware.Drawing.Color.DarkGray, 60);// Replace light yellow background with whiteimageInput.ReplaceColor(new IronSoftware.Drawing.Color("#FFFACD"), IronSoftware.Drawing.Color.White, 40);// Perform OCR on the cleaned imagevar result = ocrTesseract.Read(imageInput);
/* :path=/static-assets/ocr/content-code-examples/how-to/image-color-correction-multiple-replacements.cs */
// Replace multiple colors in sequence
using var imageInput = new OcrImageInput("multi-color-document.jpg");
// Replace red text with black
imageInput.ReplaceColor(IronSoftware.Drawing.Color.Red, IronSoftware.Drawing.Color.Black, 70);
// Replace blue headers with dark gray
imageInput.ReplaceColor(IronSoftware.Drawing.Color.Blue, IronSoftware.Drawing.Color.DarkGray, 60);
// Replace light yellow background with white
imageInput.ReplaceColor(new IronSoftware.Drawing.Color("#FFFACD"), IronSoftware.Drawing.Color.White, 40);
// Perform OCR on the cleaned image
var result = ocrTesseract.Read(imageInput);
ImportsIronSoftware.Drawing' Replace multiple colors in sequenceUsing imageInput As New OcrImageInput("multi-color-document.jpg") ' Replace red text with black imageInput.ReplaceColor(Color.Red, Color.Black, 70) ' Replace blue headers with dark gray imageInput.ReplaceColor(Color.Blue, Color.DarkGray, 60) ' Replace light yellow background with white imageInput.ReplaceColor(New Color("#FFFACD"), Color.White, 40) ' Perform OCR on the cleaned image Dim result = ocrTesseract.Read(imageInput)EndUsing
Imports IronSoftware.Drawing
' Replace multiple colors in sequence
Using imageInput As New OcrImageInput("multi-color-document.jpg")
' Replace red text with black
imageInput.ReplaceColor(Color.Red, Color.Black, 70)
' Replace blue headers with dark gray
imageInput.ReplaceColor(Color.Blue, Color.DarkGray, 60)
' Replace light yellow background with white
imageInput.ReplaceColor(New Color("#FFFACD"), Color.White, 40)
' Perform OCR on the cleaned image
Dim result = ocrTesseract.Read(imageInput)
End Using
using IronOcr;using System;// Instantiate IronTesseractIronTesseract ocrTesseract = new IronTesseract();// Add imageusing var imageInput = new OcrImageInput("sample.jpg");// Text color to focus onIronSoftware.Drawing.Color focusColor = new IronSoftware.Drawing.Color("#DB645C");// Specify which text color to readimageInput.SelectTextColor(focusColor, 60);// Perform OCROcrResult ocrResult = ocrTesseract.Read(imageInput);// Output result to consoleConsole.WriteLine(ocrResult.Text);
using IronOcr;
using System;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Add image
using var imageInput = new OcrImageInput("sample.jpg");
// Text color to focus on
IronSoftware.Drawing.Color focusColor = new IronSoftware.Drawing.Color("#DB645C");
// Specify which text color to read
imageInput.SelectTextColor(focusColor, 60);
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Output result to console
Console.WriteLine(ocrResult.Text);
ImportsIronOcrImportsSystem' Instantiate IronTesseractPrivate ocrTesseract As New IronTesseract()' Add imagePrivate imageInput = New OcrImageInput("sample.jpg")' Text color to focus onPrivate focusColor As New IronSoftware.Drawing.Color("#DB645C")' Specify which text color to readimageInput.SelectTextColor(focusColor, 60)' Perform OCRDim ocrResult AsOcrResult = ocrTesseract.Read(imageInput)' Output result to consoleConsole.WriteLine(ocrResult.Text)
Imports IronOcr
Imports System
' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()
' Add image
Private imageInput = New OcrImageInput("sample.jpg")
' Text color to focus on
Private focusColor As New IronSoftware.Drawing.Color("#DB645C")
' Specify which text color to read
imageInput.SelectTextColor(focusColor, 60)
' Perform OCR
Dim ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Output result to console
Console.WriteLine(ocrResult.Text)
using IronOcr;// Create OCR engine: filters are applied at the OcrInput level, so no configuration changes are needed herevar ocr = new IronTesseract();var ocrInput = new OcrInput();// Load the scanned PDF as the OCR sourceocrInput.LoadPdf("invoice.pdf");// Convert to grayscale: removes color noise that can reduce OCR accuracy on color-printed documentsocrInput.ToGrayScale();// Run OCR on the preprocessed inputOcrResult result = ocr.Read(ocrInput);// Write the searchable PDF; true = embed the grayscale-filtered image rather than the original color scanresult.SaveAsSearchablePdf("outputGrayscale.pdf", true);
using IronOcr;
// Create OCR engine: filters are applied at the OcrInput level, so no configuration changes are needed here
var ocr = new IronTesseract();
var ocrInput = new OcrInput();
// Load the scanned PDF as the OCR source
ocrInput.LoadPdf("invoice.pdf");
// Convert to grayscale: removes color noise that can reduce OCR accuracy on color-printed documents
ocrInput.ToGrayScale();
// Run OCR on the preprocessed input
OcrResult result = ocr.Read(ocrInput);
// Write the searchable PDF; true = embed the grayscale-filtered image rather than the original color scan
result.SaveAsSearchablePdf("outputGrayscale.pdf", true);
ImportsIronOcr' Create OCR engine: filters are applied at the OcrInput level, so no configuration changes are needed hereDim ocr As New IronTesseract()Dim ocrInput As New OcrInput()' Load the scanned PDF as the OCR sourceocrInput.LoadPdf("invoice.pdf")' Convert to grayscale: removes color noise that can reduce OCR accuracy on color-printed documentsocrInput.ToGrayScale()' Run OCR on the preprocessed inputDim result AsOcrResult = ocr.Read(ocrInput)' Write the searchable PDF; True = embed the grayscale-filtered image rather than the original color scanresult.SaveAsSearchablePdf("outputGrayscale.pdf", True)
Imports IronOcr
' Create OCR engine: filters are applied at the OcrInput level, so no configuration changes are needed here
Dim ocr As New IronTesseract()
Dim ocrInput As New OcrInput()
' Load the scanned PDF as the OCR source
ocrInput.LoadPdf("invoice.pdf")
' Convert to grayscale: removes color noise that can reduce OCR accuracy on color-printed documents
ocrInput.ToGrayScale()
' Run OCR on the preprocessed input
Dim result As OcrResult = ocr.Read(ocrInput)
' Write the searchable PDF; True = embed the grayscale-filtered image rather than the original color scan
result.SaveAsSearchablePdf("outputGrayscale.pdf", True)
What outputs are expected from selective color reading with OCR?
The OCR result from selective color reading focuses only on specified colors, such as extracting highlighted texts or specific warning messages, enabling precise data extraction from color-coded documents.
How can I create searchable PDFs with IronOCR?
IronOCR allows you to save modified PDFs using the SaveAsSearchablePdf method. Filters like grayscale can be applied to improve text readability and noise reduction in the resulting documents.
What preprocessing steps can enhance OCR accuracy for low-quality scans?
For low-quality scans, preprocessing steps like binarization, grayscale conversion, and color inversion can significantly improve text readability and OCR accuracy by reducing noise and enhancing contrast.
How can IronOCR help with structured data extraction?
IronOCR provides advanced processing capabilities like the OcrResult Class, which supports structured data extraction from images, making it ideal for forms with color-coded sections and highlighted text.