# text string from image matrix

4 visualizzazioni (ultimi 30 giorni)
v k il 12 Nov 2020
Commentato: v k il 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.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Cris LaPierre il 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'
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
v k il 13 Nov 2020
My sincere thanks.

Accedi per commentare.

### Categorie

Scopri di più su Text Detection and Recognition in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by