MATLAB cannot write text on images
조회 수: 5 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Geoff Hayes
2017년 1월 18일
편집: Geoff Hayes
2017년 1월 18일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!