Effacer les filtres
Effacer les filtres

Problems with optical character recognition

1 vue (au cours des 30 derniers jours)
Trong Link
Trong Link le 11 Déc 2021
Commenté : Trong Link le 13 Déc 2021
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 commentaires
Image Analyst
Image Analyst le 11 Déc 2021
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 le 13 Déc 2021
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.

Connectez-vous pour commenter.

Réponses (1)

yanqi liu
yanqi liu le 13 Déc 2021
Modifié(e) : yanqi liu le 13 Déc 2021
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')

Community Treasure Hunt

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

Start Hunting!

Translated by