How to save a string as a image in Matlab?

cover_str = 'Most teachers waste their time by asking questions that are intended to discover what a pupil does not know, whereas the true art of questioning is to discover what the pupil does know or is capable of knowing.';
image = text2im(cover_str);
imwrite(image,'image2.png');
I am trying to save a string as a image by using the above code but it is not working properly.
Thanks

6 Comments

Try replacing image variable with other variable name which is not a MATLAB function. Like try img instead of image variable while using text2im function.
is it https://www.mathworks.com/matlabcentral/fileexchange/75021-text2im that you are using?
What problem are you observing?
cover_str = 'Most teachers waste their time by asking questions that are intended to discover what a pupil does not know, whereas the true art of questioning is to discover what the pupil does know or is capable of knowing.';
img = text2im(cover_str);
imwrite(img,'image2.png');
When i execute this code then image generated from the string i attaching in the attachment. Image is not generated properly.
Thanks
Rik
Rik on 5 May 2020
Edited: Rik on 5 May 2020
What is improper about it? If you need a larger font you can use my version of the text2im function.
You need to wrap the text yourself if that is what you want.

Sign in to comment.

Answers (0)

Categories

Tags

Asked:

on 1 May 2020

Commented:

on 5 May 2020

Community Treasure Hunt

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

Start Hunting!