Extract data from the image

2 次查看(过去 30 天)
Maruthi Maruthi
Maruthi Maruthi 2017-12-7
编辑: DGM 2023-11-29
Sir, how to extract data from the image file. I attached sample figure, I need the value 4795 from the image. Please help me sir.

回答(1 个)

DGM
DGM 2023-11-29
编辑:DGM 2023-11-29
Why would you save an image by embedding it in a figure? Creating completely pointless obstacles is a great way to make sure nobody takes the time to answer. Save images with imwrite(). Avoid JPG when appropriate.
% the image was obviously a JPG to begin with
% but i'm not going to lossy transcode it again
inpict = imread('asdf.png');
imshow(inpict,'border','tight')
% extract the text
roi = [0.51 49.51 39.98 21.98];
ocrResults = ocr(inpict,roi)
ocrResults =
ocrText with properties: Text: '4795↵↵' CharacterBoundingBoxes: [6×4 double] CharacterConfidences: [6×1 single] Words: {'4795'} WordBoundingBoxes: [6 56 29 9] WordConfidences: 0.9669 TextLines: {'4795'} TextLineBoundingBoxes: [6 56 29 9] TextLineConfidences: 0.9669
% this can be expected to break as non-numeric "words" are recognized
thenumber = str2double(ocrResults.Words)
thenumber = 4795

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by