Filter löschen
Filter löschen

text string from image matrix

3 Ansichten (letzte 30 Tage)
v k
v k am 12 Nov. 2020
Kommentiert: v k am 13 Nov. 2020
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.

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 12 Nov. 2020
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'

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by