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
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.
回答 (1 件)
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')
str = strtrim(ocrResults.Text)
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
figure; imshow(img, [])
hold on; rectangle('position', rect1, 'EdgeColor', 'g', 'LineWidth', 2)
text(rect1(1), rect1(2), str, 'color', 'r')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!