MATLAB cannot write text on images
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Geoff Hayes
le 18 Jan 2017
Modifié(e) : Geoff Hayes
le 18 Jan 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 commentaires
Voir également
Catégories
En savoir plus sur Text Data Preparation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!