I am Not able To sort Out How to achieve This.
1 view (last 30 days)
Show older comments
OK I am a beginner. I have written a code for changing rgb values of a image by inputting ASCII value from a text file. I only changed row 1 for now. What i need to do is that I want to create another text file and store the original text in it using ASCII value in row 1 of newly created image
0 Comments
Accepted Answer
Thorsten
on 19 Nov 2014
Edited: Thorsten
on 19 Nov 2014
You could simplify your code
I = rgb2gray(imread('peppers.png'));
T = 'Hallo World';
I(1,1:length(T)) = uint8(T);
To get the text back from the image you need to know the length of the text. Than you can retrieve it using
T2 = char(I(1,1:length(T))
and write it to a file with fwrite.
1 Comment
Thorsten
on 19 Nov 2014
Edited: Thorsten
on 19 Nov 2014
Please look at the second part of my answer where I tried to address how to recover the ASCII values from the image. Note that there is no way to distinguish an ASCII value in the image from an gray value. In the image, it's all a number (a uint8) between 0 and 255, so you need the position in the image where the text has been stored.
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!