text string from image matrix

8 次查看(过去 30 天)
Suppose the matrix is as in the attached figure, given by the binary matrix H or P etc. Then what is the syntax for getting the digitized string 'H' or 'P', i.e. for a hypothetical function matrix2string,
str{1}=matrix2string(H)
str{2}=matrix2string(P)
how to get the digitized string H and P, which can be used in the arguments of the 'text' or the 'uicontrol' statement. This string will get plotted on the figure at the position specified in the arguments of the 'text' or the 'uicontrol'.
H is the 7x7 matrix in this example. str is the text string (str{1}=H in this case). Using the following
uicontrol('Position',[x1 y1 x2 y2],'String',str{1})
can we get the letter H to appear at the 'Position' specified ? Thanks.

采纳的回答

Cris LaPierre
Cris LaPierre 2020-11-12
This is called optical character recognition, or OCR. MATLAB has functions for this (see here).
h = [0 1 0 0 0 1 0
0 1 0 0 0 1 0
0 1 0 0 0 1 0
0 1 1 1 1 1 0
0 1 0 0 0 1 0
0 1 0 0 0 1 0
0 1 0 0 0 1 0];
imagesc(h)
L = ocr(h,'TextLayout','character');
L.Text
ans = 'H'

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by