How to Read MICR Cheque using IronOCR
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: Extract MICR Line from Cheque in C#
Easily read the MICR line from a cheque image with IronOCR in just one step. This simple example demonstrates how to swiftly extract critical financial information, such as routing and account numbers, using the IronOCR library. Perfect for developers looking to automate cheque processing efficiently and accurately within their .NET applications.
Get started making PDFs with NuGet now:
Install IronPDF with NuGet Package Manager
Copy and run this code snippet.
var result = new IronOcr.IronTesseract().ReadMicr("cheque.jpg");Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download the C# library for reading MICR cheques
- Instantiate the OCR engine
- Set the
Languagesetting to MICR - Use the
Readmethod to extract data from the sample cheque image - Access the OcrResult property to view and manipulate the extracted data
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

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.csusing 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.comOutput

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.
Here is the output image after drawing the specified bounding box on our example cheque.
Output

The light blue rectangle confirms that we have correctly isolated the MICR line for processing.
Frequently Asked Questions
What is the purpose of using IronOCR for reading MICR cheques?
IronOCR streamlines the process of reading MICR cheques by accurately extracting critical data such as routing and account numbers, reducing manual errors and increasing efficiency in financial processing.
How do I get started with reading MICR cheques using IronOCR?
To begin reading MICR cheques with IronOCR, download the C# library, instantiate the OCR engine, set the Language to MICR, and use the Read method to extract data from cheque images.
What specific library package is required for MICR reading in IronOCR?
You need to install the IronOcr.Languages.MICR package to perform MICR reading with IronOCR.
How can I ensure accurate MICR line reading using IronOCR?
Specify the MICR line's location by setting a rectangular boundary on the OcrInput. This focused approach, combined with the MICR language setting, ensures accurate extraction of financial information.
What are the key components of a MICR line that IronOCR extracts?
IronOCR extracts the check number, routing number, and account number from the MICR line, which are essential for financial transactions.
How can I verify the OCR region for the MICR cheque using IronOCR?
You can visualize the ContentArea by drawing the rectangle on the input image and saving it with StampCropRectangleAndSaveAs to ensure correct coordinate selection.
What output can I expect from the IronOCR MICR reading process?
The output includes the transit number, routing number, and account number, presented with statistical accuracy confidence for each character.
How do I define the bounding box for the MICR line in IronOCR?
Use an image editor to find the top-left and bottom-right coordinates of the MICR line on your cheque image, then calculate the rectangle's properties for the bounding box.




