I am Not able To sort Out How to achieve This.

1 Ansicht (letzte 30 Tage)
GodGOD
GodGOD am 19 Nov. 2014
Bearbeitet: GodGOD am 19 Nov. 2014
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

Akzeptierte Antwort

Thorsten
Thorsten am 19 Nov. 2014
Bearbeitet: Thorsten am 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 Kommentar
Thorsten
Thorsten am 19 Nov. 2014
Bearbeitet: Thorsten am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by