MATLAB cannot write text on images
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have been trying to write text on generated figure using the insertText function. Even when using the following example code given in the Mathworks website:
I = imread('peppers.png');
position = [1 50; 100 50];
value = [555 pi];
RGB = insertText(I,position,value,'AnchorPoint','LeftBottom');
I am still getting errors saying:
cell contents reference from a non-cell array object.
Error in listTrueTypeFonts>createFontInfo (line 93)
if ~ismember(fontNameCell{p},fontList) && ~isempty(fontNameCell{p})
I typed in the following to check system font availability on my MATLAB setup:
listTrueTypeFonts
I still get the same error message. But my Windows 10 installation shows several TrueType fonts installed.
0 Commenti
Risposte (1)
Geoff Hayes
il 18 Gen 2017
Modificato: Geoff Hayes
il 18 Gen 2017
Debangshu - according to insertText text input argument, your value should be a text character vector or cell array of text character vectors. I think that the MATLAB example is incorrect and that they are missing a step to convert this to a cell array of strings like
text_str = {'555', num2str(pi)};
or
text_str = cell(1,length(value));
for k=1:length(value)
text_str{k} = num2str(value(k));
end
RGB = insertText(I,position, text_str,'AnchorPoint','LeftBottom');
This is similar to what they did in a previous example (converting the numeric array to a cell string array).
0 Commenti
Vedere anche
Categorie
Scopri di più su Text Data Preparation 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!