Problems in recognising text with OCR from clear logical array

5 次查看(过去 30 天)
Hello, I have a clean image containing only some lines of text. It is the result of exporting a logical array of pixels.
Using OCR command, TEXT property results to be empty. I tried with jpg and png format, as in the attached figures.
The code I am using is just
xxx=imread(name_file);
ocr(xxx)
ans =
ocrText with properties:
Text: ''
CharacterBoundingBoxes: [0×4 double]
CharacterConfidences: [0×1 single]
Words: {0×1 cell}
WordBoundingBoxes: [0×4 double]
WordConfidences: [0×1 single]
TextLines: {0×1 cell}
TextLineBoundingBoxes: [0×4 double]
TextLineConfidences: [0×1 single]
Thank you very much

采纳的回答

Jonas
Jonas 2024-1-30
i guess it is just a mishandling of the automatic mode recognition:
I=imread('testOCR.png');
I=rgb2gray(I);
imshow(I);
c=ocr(I,"LayoutAnalysis","block");
c.Words
ans = 4×1 cell array
{'122591'} {'1EHEOE'} {'d1596M'} {'MTSEPL'}
since this contains errors, you could try to blur out the edges, maybe this helps :D
J=imgaussfilt(I,4);
J=imsharpen(J,'Radius',4,'Amount',4);
imshow(J);
c=ocr(J,"LayoutAnalysis","block");
c.Words
ans = 4×1 cell array
{'132831'} {'1BHEOR'} {'41896M'} {'MTSGPU'}
this is better, but still not without errors (3 instead of 9 in the first line). maybe this can help you do change your image in such a way, that it can work

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Text Analytics Toolbox 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by