OCR image processing

1.3k views Asked by At

I am trying to use OCR of MATLAB for character recognition.This is what I am doing-

I=imread('ocr.jpg');
imshow(I);title('Original Image');
results = ocr(I);
word = results.Text

This is the image ocr.jpg enter image description here

But this is the output I get- word = Basically it is not able to recognize the character F. This is the link which I followed- http://in.mathworks.com/help/vision/examples/recognize-text-using-optical-character-recognition-ocr.html

1

There are 1 answers

0
bpatel On BEST ANSWER

Because the image only contains a single character and the text is not formatted in a typical page format (dual column, single column, etc), you'll have to set the 'TextLayout' parameter to 'Word', and provide an input ROI:

>> r = ocr(img,[91 89 22 37],'TextLayout','Word')

r = 

  ocrText with properties:

                      Text: 'F…'
    CharacterBoundingBoxes: [3x4 double]
      CharacterConfidences: [3x1 single]
                     Words: {'F'}
         WordBoundingBoxes: [94 97 16 21]
           WordConfidences: 0.9428

I used IMRECT to manually get the ROI around the "F", but you can use REGIONPROPS or vision.BlobAnalysis to automatically get the ROI around the character if your images are all black and white like the one you posted.