How to Read MICR Cheque using IronOCR

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

Manually processing checks is slow and error-prone. IronOCR streamlines this workflow with a specialized engine that accurately reads the MICR (Magnetic Ink Character Recognition) line, letting you automate the extraction of routing numbers, account numbers, and other critical data.

Quickstart: OCR Read MICR from Cheque Image

Use IronOCR to grab the MICR line fast—just set the language to MICR, specify the rectangular region where the MICR text appears, run Read(), and immediately get the result.Text string. Perfect for developers who want reliable financial data extraction with minimal setup.

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.

    string micrText = new IronOcr.IronTesseract { Language = IronOcr.OcrLanguage.MICR }.Read(new IronOcr.OcrInput().LoadImage("micr.png", new System.Drawing.Rectangle(125, 240, 310, 15))).Text;
  3. Deploy to test on your live environment

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

Read MICR Cheque Example

Reading a MICR line with IronOCR is simple and intuitive. We begin by setting the Language property of the IronTesseract instance to OcrLanguage.Micr. To ensure the engine reads the correct area, it is necessary to specify the location of the MICR line by setting a rectangular boundary on the OcrInput.

This is achieved by selecting the x and y coordinates, as well as the height and width of the bounding box rectangle, and then passing the rectangle as the second parameter when calling the Load method. Calling the Read method then processes only this defined region. This combination of the MICR language setting and a specific region guarantees that IronOCR accurately extracts the relevant financial information.

Cheque Input

MICR Cheque

The MICR Line

Check Number: This number uniquely identifies the specific cheque from the account holder's checkbook. It serves as a clear reference for tracking individual payments and maintaining transaction records.

Routing Number: This nine-digit code, enclosed by the ⑆ transit symbol, identifies the financial institution that holds the account. It's the first piece of information a clearinghouse uses to direct the cheque to the correct bank for payment.

Account Number: This identifies the specific customer account from which funds will be drawn. Its length can vary between different banks.

Code

:path=/static-assets/ocr/content-code-examples/how-to/read-micr-cheque.cs
using IronOcr;
using IronSoftware.Drawing;
using System;

// Create a new instance of IronTesseract for performing OCR operations
IronTesseract ocr = new IronTesseract();

// Set the OCR language to MICR to recognize magnetic ink characters
// Must have MICR (IronOcr.Languages.MICR) installed beforehand
ocr.Language = OcrLanguage.MICR;

// Specify the file path of the input image containing MICR text
using (var input = new OcrInput())
{
    // Specify the MICR of the image to focus on for OCR (coordinates in pixels)
    var contentArea = new Rectangle(x: 215, y: 482, width: 520, height: 20);
    input.LoadImage("micr.png", contentArea);

    // Optional: Save the cropped area for verification
    input.StampCropRectangleAndSaveAs(contentArea, Color.Aqua, "cropped.png");

    // Run the OCR engine to read the MICR text from the input image
    var result = ocr.Read(input);
    // Output the recognized text to the console
    Console.WriteLine(result.Text);

    // Transit number is the first 7 characters of the MICR string
    string transitNum = result.Text.Substring(0, 7);
    // Routing number starts from the 8th character and is 11 characters long
    string routingNum = result.Text.Substring(7, 11);
    // Account number starts from the 22nd character to the end of the string
    string accountNum = result.Text.Substring(22);
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

MICR Output

The output above showcases the three sections obtained from the MICR cheque: the transit number, the routing number, and the account number.

MICR OCR Results

The OcrResult object provides detailed information about the scan:

Text: The extracted text from OCR Input.

Confidence: Indicates the statistical accuracy confidence of an average of every character, with one being the highest and zero being the lowest.

Verifying the OCR region of the MICR Cheque

To ensure you've selected the correct coordinates for the MICR line, you can visualize the ContentArea you defined. A simple way to do this is to draw the rectangle on the input image and save it as a new file with StampCropRectangleAndSaveAs. This helps you debug and fine-tune the coordinates for optimal performance.

ConsejosTo find the coordinates for your Rectangle, you can use a simple image editor like MS Paint. Open your cheque image, hover your mouse over the top-left and bottom-right corners of the MICR line, and note the (x,y) pixel coordinates. You can then calculate the rectangle's properties: (x1, y1, width, height), where width = x2-x1 and height = y2-y1.

Here is the output image after drawing the specified bounding box on our example cheque.

Output

MICR cropped

The light blue rectangle confirms that we have correctly isolated the MICR line for processing.

Preguntas Frecuentes

¿Cuál es el propósito de utilizar IronOCR para leer cheques MICR?

IronOCR optimiza el proceso de leer cheques MICR al extraer con precisión datos críticos como números de enrutamiento y cuenta, reduciendo los errores manuales y aumentando la eficiencia en el procesamiento financiero.

¿Cómo empiezo a leer cheques MICR usando IronOCR?

Para comenzar a leer cheques MICR con IronOCR, descargue la biblioteca C#, instancie el motor OCR, configure el Idioma a MICR y use el método Leer para extraer datos de imágenes de cheques.

¿Qué paquete de biblioteca específico se requiere para la lectura de MICR en IronOCR?

Debe instalar el paquete IronOcr.Languages.MICR para realizar la lectura MICR con IronOCR.

¿Cómo puedo asegurar una lectura precisa de la línea MICR usando IronOCR?

Especifique la ubicación de la línea MICR estableciendo un límite rectangular en el OcrInput. Este enfoque enfocado, combinado con la configuración de idioma MICR, asegura la extracción precisa de información financiera.

¿Cuáles son los componentes clave de una línea MICR que IronOCR extrae?

IronOCR extrae el número de cheque, el número de enrutamiento y el número de cuenta de la línea MICR, que son esenciales para las transacciones financieras.

¿Cómo puedo verificar la región OCR para el cheque MICR usando IronOCR?

Puede visualizar el ContentArea dibujando el rectángulo en la imagen de entrada y guardándolo con StampCropRectangleAndSaveAs para asegurar una correcta selección de coordenadas.

¿Qué salida puedo esperar del proceso de lectura de MICR con IronOCR?

La salida incluye el número de tránsito, el número de enrutamiento y el número de cuenta, presentados con una confianza de precisión estadística para cada carácter.

¿Cómo defino el cuadro delimitador para la línea MICR en IronOCR?

Use un editor de imágenes para encontrar las coordenadas de la esquina superior izquierda e inferior derecha de la línea MICR en su imagen de cheque, luego calcule las propiedades del rectángulo para el cuadro delimitador.

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