I need a Matlab function that prepares an image for digit and letter recognition.

What I need now is to convert the original RGB image to a binary image that every pixel in it is white except the pixels corresponding to letters and digits, as well as all digit and letter must appear chromatic/saturated, i.e. appear full of color. enter image description here

Here is the code I have been tested. As you can see some pixels of a letter or digit are white.

I = imread('img6.png');   % read the image into the matrix
Ig = rgb2gray(I);

Icon = imadjust(Ig);


1- How we can convert the original image to a high contrast image?

2- How the shadows around letters and digits can be removed?


First, many OCR programs automatically perform image processing, including possible color conversion, image filtration, dilation/erosion, and monochrome conversion, in order to improve the quality of OCR operation. Especially good in this are neural-network enabled cloud-based OCR applications.

If you absolutely need local MATLAB program to perform the image processing supposedly preparing the document for recognition, first check if MATLAB or its addons have some kind of image thresholding function: the function which outputs a monochrome (black/white) image given a scanned document. If there is no ready thresholding function, you can try and code it. An introduction into a computer graphics required to successfully code an image preparation operations "for digit and letter recognition" you will find in https://tesseract-ocr.github.io/tessdoc/ImproveQuality and elsewhere, if you search words and phrases highlighted in this answer.

You may find useful this ref, which, although lacking MATLAB code, contains code snippets written in common computer languages.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.