Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
The Aspose.OCR recognition engine can handle images of any size. However, very small and very large image sizes can adversely affect recognition:
Aspose.OCR offers flexible processing filters that allow you to upscale small images, shrink large images, or resize an image to predefined width and height.
To scale images up or down proportionally, use the Scale
processing filter. The filter takes a scaling ratio (floating point number) as a parameter:
Scaling ratio | Result | Example |
---|---|---|
0 to 1 |
Shrink the image proportionally to the specified percentage. | Scale(0.3F) - proportionally reduce the width and height of the image down to 30%. |
1 |
Keep the original image size. | |
Above 1 |
Upscale the image proportionally to the specified percentage. | Scale(2) - proportionally increase the width and height of the image to twice its original size. |
Scale
filter also allows you to select an interpolation algorithm as an optional parameter.
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
// Scale the image to twice its original size using bilinear interpolation
Aspose.OCR.Models.PreprocessingFilters.PreprocessingFilter filters = new Aspose.OCR.Models.PreprocessingFilters.PreprocessingFilter();
filters.Add(Aspose.OCR.Models.PreprocessingFilters.PreprocessingFilter.Scale(2, Aspose.OCR.Filters.InterpolationFilterType.Triangle));
// Add an image to OcrInput object and apply processing filters
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage, filters);
input.Add("source.png");
// Save processed image to the folder
Aspose.OCR.ImageProcessing.Save(input, @"C:\result");
// Recognize image
Aspose.OCR.OcrOutput results = recognitionEngine.Recognize(input);
foreach(Aspose.OCR.RecognitionResult result in results)
{
Console.WriteLine(result.RecognitionText);
}
You can manually define the width and height of the target image (in pixels) using the Resize
processing filter. It also allows you to select an interpolation algorithm as an optional parameter.
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
// Resize the image to 1000x1000 pixels with bilinear interpolation
Aspose.OCR.Models.PreprocessingFilters.PreprocessingFilter filters = new Aspose.OCR.Models.PreprocessingFilters.PreprocessingFilter();
filters.Add(Aspose.OCR.Models.PreprocessingFilters.PreprocessingFilter.Resize(1000, 1000, Aspose.OCR.Filters.InterpolationFilterType.Triangle));
// Add an image to OcrInput object and apply processing filters
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage, filters);
input.Add("source.png");
// Save processed image to the folder
Aspose.OCR.ImageProcessing.Save(input, @"C:\result");
// Recognize image
Aspose.OCR.OcrOutput results = recognitionEngine.Recognize(input);
foreach(Aspose.OCR.RecognitionResult result in results)
{
Console.WriteLine(result.RecognitionText);
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.