Converting Image to Excel Format

I have screenshots of some data that I want to convert to excel format. Data is in a row/column format. I want to keep the formatting.
I am using Computer Vision (OCR) and Image Processing Toolbox to do this. Here is my code:
rawimage = imread('Capture.png');
grayimage = rgb2gray(raw_image);
threshold = graythresh(grayimage);
bw = imbinarize(grayimage,threshold);
imshow(bw);
results = ocr(bw,'TextLayout','Auto');
text = results.Text;
filename = 'csvtest.csv';
csvwrite(filename,text)
So this code successfully reads my data. There is no problem with the OCR. However, the text result given in only one cell. After I export this into csv format with the last line of code, it exports every single character into one cell. I want the words, numbers, sentences, not each character in one cell.
Can anyone help?

Antworten (1)

Gopichandh Danala
Gopichandh Danala am 27 Apr. 2018

0 Stimmen

Here I am considering a cell arrray and splitting them into multiple cells based on spaces then saving into csv with each word in a next line
String = {'Some random string seperating words by space'};
strings = strsplit(char(String));
fid = fopen('junk.csv','w');
fprintf(fid,'%s\n',strings{1,:});
fclose(fid);

3 Kommentare

Birtan Derin
Birtan Derin am 27 Apr. 2018
Unfortunately that wouldn't work as some cells in my data contain more than one words. I was thinking more of an OCR type of solution. I mean I've seen examples online where OCR managed to separate each word, but I don't understand why it wouldn't work on mine.
Gopichandh Danala
Gopichandh Danala am 27 Apr. 2018
I don't have computer vision toolbox to recreate this
PRACHI Sood
PRACHI Sood am 3 Mai 2020
I am facing the same problem.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 27 Apr. 2018

Kommentiert:

am 3 Mai 2020

Community Treasure Hunt

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

Start Hunting!

Translated by