필터 지우기
필터 지우기

how to give color to an output text

조회 수: 255 (최근 30일)
Elysi Cochin
Elysi Cochin 2013년 4월 8일
댓글: Michael 2020년 11월 18일
i saved my output in txt file.....
myOutput = Image Processing is interesting
i wanted to display the word "Process" in green color and the remaining words in black color itself....
i found a link in which we can format the text in different ways....
but in all those examples we give the full text to change color... but i want only a portion of the text to change its color...
if found the starting position of Process and the position upto which i want to change color... but i dont know how to keep the other text colors black and "Process" only green...... please can someone help me solve it.... i need the output to be displayed either in command window or txt file.... but the only thing is the change in color shud be there.....please do reply....

채택된 답변

Cedric
Cedric 2013년 4월 8일
편집: Cedric 2013년 4월 8일
Use a combination of FPRINTF and CPRINTF, without outputting CR/LF before the "final" end of line.
>> fprintf('This is a ') ; cprintf('_red', 'colorful ') ; fprintf('example!\n') ;
but be aware that CPRINTF is rather slow.
>> tic ; for k = 1:1e2, fprintf('.') ; end ; fprintf('\n') ; toc
....................... ..
Elapsed time is 0.001758 seconds.
>> tic ; for k = 1:1e2, cprintf('_red', '.') ; end ; fprintf('\n') ; toc
....................... ..
Elapsed time is 1.458687 seconds.

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 4월 8일
I know this isn't what you want, but in case others want to know how to "burn" colored text into images, see this link : http://www.mathworks.com/matlabcentral/fileexchange/38721-embed-text-and-graphics-in-an-image

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by