1

I made a basic OCR system in Matlab using correlation. (It's not a professional project, only as an exercise and I am not using the ocr() function of Matlab). My code is working almost correctly for clean text images. But if I make the job a little harder (taking the text photo for side position with angle) my code does not give good results. I use Principal Component Analysis for correct text alignment, but if I do this (taking photo with angle), the characters are very close together and I can't separate them for the recognizing process.

Original Image and after preprocessing (adaptive thresholding, adjusting,PCA)

Original Image and after preprocessing (adaptive thresholding, adjusting,PCA)

How can I separate the characters correctly?

10a
  • 429
  • 1
  • 5
  • 21
Ahmet Anil
  • 31
  • 3
  • Please provide your code, currently your question is off-topic. – Rob Audenaerde Oct 03 '17 at 09:30
  • @RobAu: seeing the code will not help. This is a question of method. –  Oct 03 '17 at 09:33
  • @YvesDaoust I disagree. I think the problem might be in the preprocessing, and currently we have no way to see what was done. – Rob Audenaerde Oct 03 '17 at 09:37
  • (as can be seen the hole in the 'A' gets filled, so probably there is too much dilation going on, or the adaptive thresholding is not aggresive enough) – Rob Audenaerde Oct 03 '17 at 09:39
  • @RobAu: Touching characters is a common problem and adaptive thresholding is a good starting point. There is no magical method that will work for any case. I bet that adusting the threshold will make other parts of the characters disappear before the characters separate (which they might never do). –  Oct 03 '17 at 09:40
  • https://stackoverflow.com/q/2636172/461499 – Rob Audenaerde Oct 03 '17 at 09:42

1 Answers1

0

An alternative to what Yves suggests is to erode the image. Which is implemented as imerode in matlab. Perhaps scale the image first (though it is not needed here)

e.g. with this code

ocr(imerode(I,strel('disk',3)))

where I is your "BOOLEAN" black-white image, I receive

ocrText with properties:
                  Text: 'BOOLEAN↵↵'
CharacterBoundingBoxes: [9×4 double]
  CharacterConfidences: [9×1 single]
                 Words: {'BOOLEAN'}
     WordBoundingBoxes: [14 36 208 43]
       WordConfidences: 0.5477
Nicky Mattsson
  • 3,052
  • 12
  • 28