How to represent numbers as characters in an image
1 次查看(过去 30 天)
显示 更早的评论
I have a file which contains numbers which are the coefficients obtained from wavelet thresholding of a data/signal by issuing the command signal_coeff=cwt(signal,1:32,'sym2','plot');colormap jet;surf(signal_coeff); .How do I convert this data of numbers to characters based on maximum entropy thresholding and then as an image(24 bit RGB) using a grid like visual representation where each square contains a letter. Should I use num2str or char(coeff) and how do I go about it.Please note that my knowledge in matlab is very limited and as such I could not understand how to do all these steps. Any help would be appreciated.
0 个评论
回答(1 个)
Walter Roberson
2012-1-13
Your question is difficult for me to understand.
If you have a number, then if you use num2str() you would end up with multiple characters unless the number was exactly one of 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. If you use char() on a number then you would end up with one character if the number was an integer in the range 0 to 65535, and you would get warnings if you had negative values or you had any fractions.
Once you have your character or characters, you could arrange them in a matrix, but a matrix of characters cannot be used as an image by any MATLAB routine that I can think of. The MATLAB display routines or image-saving routines require matrices which are of the data type uint8, uint16, or double (some might permit single)
The connection between the numbers in the file and the conversion to characters "based upon maximum entropy thresholding" is not something I do not understand. You said that the coefficients were generated from "a data/signal", which implies that the data was not originally character, so I do not know why you want to output as character.
It would make more sense to me if you had not referred to characters at all, and had instead said that you needed to create a matrix of uint8.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 AI for Signals and Images 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!