Problems with optical character recognition

1 次查看(过去 30 天)
I am implementing an automatic graph image digitizer. I'm trying to determine the labels on the axes, I use the built-in function ocr() to determine them. It can initially determine the exact values if the x and y axes are linear scales. But if the axes are logarithmic scale then the ocr() function cannot determine the exact logarithmic values on each axis. Is there any way I can get those logarithmic values?
Here is the images that I cropped from my input graph image:
How can the logarithmic values be determined on those images?
  2 个评论
Image Analyst
Image Analyst 2021-12-11
What does your ocr() give? Like 107, 106, 105, etc. If so you'll just have to recognize that the third number is the power of ten.
Trong Link
Trong Link 2021-12-13
I can do so if I know the axes are logarithmic scale. I'm assuming my digitizer doesn't know what scale the axes are, linear or logarithmic.

请先登录,再进行评论。

回答(1 个)

yanqi liu
yanqi liu 2021-12-13
编辑:yanqi liu 2021-12-13
yes,sir,if we can get the figure or .fig file,may be use figure handle can get the property value
but,if just image,it is an digits ocr problem,the logarithmic data type may be use the height to classify between normal digits、logarithmic digits
when get the class,use image segment to get the number list,and make the right number or the small height number as exponential number
here is an example
clc; clear all; close all;
img = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/830925/image.png');
img = rgb2gray(img);
bw = imbinarize(img,'adaptive','ForegroundPolarity','dark','Sensitivity',0.4);
bw2 = imdilate(imclose(~bw, strel('square', 7)), strel('square', 7));
stats = regionprops(bw2);
rect1 = stats(1).BoundingBox;
bwi = imcrop(bw, round(rect1));
bwi = imresize(bwi, 40/size(bwi,1), 'bilinear');
statsi = regionprops(~bwi);
ocrResults=ocr(bwi,'CharacterSet','0123456789')
ocrResults =
ocrText with properties: Text: '107↵↵' CharacterBoundingBoxes: [5×4 double] CharacterConfidences: [5×1 single] Words: {'107'} WordBoundingBoxes: [8 8 40 24] WordConfidences: 0.6906
str = strtrim(ocrResults.Text)
str = '107'
rectsi = cat(1, statsi.BoundingBox);
rectsi = sortrows(rectsi, 1);
if rectsi(end, 4)/rectsi(1, 4) < 0.8
% the right number height
str = [str(1:end-1) '^' str(end)];
end
str
str = '10^7'
figure; imshow(img, [])
hold on; rectangle('position', rect1, 'EdgeColor', 'g', 'LineWidth', 2)
text(rect1(1), rect1(2), str, 'color', 'r')

类别

Help CenterFile Exchange 中查找有关 Language Support 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by