How to set DPI Setting in OCR

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

Dots Per Inch (DPI) is a fundamental measurement of image quality, determining the level of detail present in a scanned document or digital photograph. While scanning documents is a fast and efficient way to digitize physical records, the process can often result in low-resolution files, especially when using default or "quick scan" settings. This lack of detail makes the text appear blurry or pixelated, presenting a significant obstacle for data extraction.

This is where OCR performance is directly impacted. OCR engines function by analyzing the precise shapes and patterns of characters to convert them into machine-readable text. When an image has a low DPI, there aren't enough pixels to clearly define each letter, causing fine details to be lost and leading to inaccurate results.

However, IronOCR is engineered to overcome these common challenges. It has been finely tuned to achieve high accuracy on scans with resolutions as low as 225 DPI.

Quickstart: Set TargetDPI for Sharper OCR Results

In one simple line, you can configure IronOCR to upscale low-resolution images—improving text clarity and recognition with minimal effort. Developers can get started instantly using IronOCR's clean API.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronOCR with NuGet Package Manager

    PM > Install-Package IronOcr

  2. Copy and run this code snippet.

    var result = new IronOcr.IronTesseract().Read(new IronOcr.OcrInput { TargetDPI = 300 }.LoadImage("low-res.png"));
  3. Deploy to test on your live environment

    Start using IronOCR in your project today with a free trial
    arrow pointer

DPI Setting Example

This example uses a sample image with a low resolution of approximately 100 DPI and adds artificial noise to demonstrate the effectiveness of theTargetDPIfeature.

The actual text in the image is: "Testing testing testing blurry text example example example".

Blurry Text Image

Code Example

In this example, we'll set theTargetDPIto 300 to upscale the image resolution to 300 DPI. Afterward, we'll load the input image from above and print out the extracted test withTextand the confidence level withConfidence.

:path=/static-assets/ocr/content-code-examples/how-to/dpi-setting.cs
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();

using var ocrInput = new OcrInput();
// Set the target DPI to 300 for better OCR accuracy
ocrInput.TargetDPI = 300;

ocrInput.LoadImage(@"images\image.png");

// Perform OCR on the image with the specified DPI
var ocrResult = ocrTesseract.Read(ocrInput);
// Display the text extracted from the image
Console.WriteLine(ocrResult.Text);
// Display the confidence level of the OCR result
Console.WriteLine(ocrResult.Confidence);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Text Output

As the output shows, IronOCR achieves an 85% confidence score. Despite the significant noise and low initial DPI of the source image, the result is exceptionally accurate, demonstrating the power of the upscaling feature.

IronOCR includes built-in capabilities that can automatically enhance low-resolution images by upscaling them, all within a single library.

DPI Setting Comparison

To illustrate the difference, here is the result of processing the same low-resolution image without setting theTargetDPIproperty.

Finding the correct DPI is a balance. High DPI is more accurate but slower; low DPI is faster but less reliable. When in doubt, let Iron Tesseract's automatic preprocessing determine the optimal settings. You can also disable the automatic upscaling by setting the TargetDPI property to 0 .

Output

Text Output

Without upscaling, the confidence score drops to 79%, and the extracted text is significantly less accurate. This comparison clearly highlights how setting a TargetDPI can dramatically improve OCR results on low-quality images.

DPI Setting for PDF

When processing a PDF, IronOCR will upscale the entire document to the target DPI, not just the images contained within it.

While a higher DPI can often lead to better OCR results, the optimal setting can vary significantly between different PDFs. Suppose you are unsure which value to use. In that case, it is best to leave the DPI at its default setting and allow IronOCR to determine the best configuration for your document automatically.

Advertencia The maximum value for TargetDPI is 32,766. Setting a DPI higher than this limit will cause an exception. This happens because the resulting image dimensions would exceed Tesseract's maximum supported size of 32,767 x 32,767 pixels. If the limit is exceeded, you will receive the following error message: 'TargetDPI is too high and would result in an image too large ({new_width} x {new_height}) for Tesseract. The maximum image size for Tesseract is 32767 x 32767'

Preguntas Frecuentes

¿Qué es el DPI en el contexto de OCR?

DPI significa puntos por pulgada, que mide la resolución de una imagen. En OCR, establecer un DPI apropiado puede mejorar la precisión del reconocimiento de texto, especialmente en imágenes de baja resolución.

¿Cómo afecta la configuración de DPI en la precisión de OCR en IronOCR?

Configurar el DPI correcto en IronOCR puede mejorar significativamente la precisión del reconocimiento de texto al proporcionar entradas de imagen más claras, reduciendo errores en la identificación de caracteres, especialmente en imágenes de baja resolución.

¿Cuáles son los ajustes de DPI recomendados para resultados óptimos de OCR?

Para obtener resultados óptimos de OCR, se recomienda usar imágenes con un DPI de al menos 300. Sin embargo, IronOCR ofrece características para mejorar las imágenes, permitiendo un OCR efectivo en imágenes de menor DPI.

¿Puedo mejorar imágenes de baja resolución en IronOCR para obtener mejores resultados?

Sí, IronOCR ofrece funcionalidad de mejora de imagen que puede aumentar la resolución de imágenes de baja calidad, mejorando así la precisión de OCR.

¿IronOCR admite el ajuste automático de DPI?

IronOCR permite configuraciones de DPI personalizables, habilitando ajustes automáticos para optimizar el rendimiento de OCR según la calidad de la imagen de entrada.

¿Cómo configuro el DPI en IronOCR usando C#?

Puede configurar el DPI en IronOCR especificando el valor de DPI deseado en su código C#. La documentación proporciona ejemplos de código para guiarlo a través de este proceso.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
¿Listo para empezar?
Nuget Descargas 5,044,537 | Versión: 2025.11 recién lanzado