1
votes

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
have you read the article? What Went Wrong? Adjusting the 'TextLayout' parameter did not help. To understand why OCR continues to fail, you have to investigate the initial binarization step performed within ocr. You can use graythresh to check this initial binarization step because both ocr and graythresh use Otsu's method for image binarization. - Henrik

1 Answers

2
votes

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.