ocr wont work on single digit in an image

7 ビュー (過去 30 日間)
Oliver Stilz
Oliver Stilz 2019 年 12 月 9 日
回答済み: Mahesh Taparia 2019 年 12 月 13 日
Hey,
i have attached an example programm which explains my problem. I read an image that contains serveral digits. If i canalyze the whole image using OCR it works fine. Now when i crop out a single digit it does not anymore.
is there possibilities to give ocr further parameters to for example tell it that the number is close to the size of the whole picture?
example picture i used:
zahlen.bmp
[Files, Path] = uigetfile('*.bmp', 'Select CSV File Measurement for Calibration', 'MultiSelect', 'off');
FileName = strcat(Path, char(Files));
image = imread(FileName);
image = imresize(image, [200 NaN]);
figure()
imshow(image);
rest = ocr(image);
number = char(rest.Words)
[row, col] = size(image);
rect = [col/30*zahl, 0, col/30, row];
im_solo = imcrop(image, rect);
figure();
imshow(im_solo);
rest = ocr(im_solo);
number = char(rest.Words)

回答 (1 件)

Mahesh Taparia
Mahesh Taparia 2019 年 12 月 13 日
Hi Oliver,
The single character is not recognized may be due to irregular background or the text is sparse. In this case, if you disable the automatic layout in the ocr command it will work. You can run the following code to recognize a single digit:
results = ocr(im_solo,'TextLayout','Block');
results.Text
For more information, you can refer to the documentation link of ‘ocr’.

カテゴリ

Help Center および File ExchangeLanguage Support についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by