hello! I'm having a litle trouble while running my code. I've hidden a text document behind a picture and i wish by decoding it to be able to see the hideen text. Somehow it seems something is not right because it apears in the matlab workspace in a vector form. is it posible to see the initial text? i've used the ASCII code...
my code
I=imread('im1.png');
function [dec_text]=decodare_txtf(I)
[row, col] = size(I);
dec_text = zeros(1, row);
pas = col/4;
for i = 1 : row
aux = 0;
aux = uint8(aux);
for j = 1:4
aux = aux * 2^2;
aux = aux + mod(I(i,j*pas), 2^2);
end
dec_text(i) = char(aux);
end
text = char(dec_text);
A = mat2str(text);
imshow('im1.png'),title('Imagine decodata');
disp(A);
end
i've attached the files in question.

4 个评论

Wht error you are getting?
i don't know if the text mesage has to be in that form, lots of numbers from 0 to 255 randomnly placed, or have to do something else to be able to see the text whit the original content. or is a line i forgot to put somewhere and that is why i can't see the text. i've attached the results. is this how it has to be?
After you assign the imread to I, you need to make a call to the function. Matlab does not not assume that the function should be called just because it is present in the file.

请先登录,再进行评论。

 采纳的回答

You need to save the below code into a function named: decodare_txtf.m in some folder.
function [dec_text]=decodare_txtf(I)
[row, col] = size(I);
dec_text = zeros(1, row);
pas = col/4;
for i = 1 : row
aux = 0;
aux = uint8(aux);
for j = 1:4
aux = aux * 2^2;
aux = aux + mod(I(i,j*pas), 2^2);
end
dec_text(i) = char(aux);
end
text = char(dec_text);
A = mat2str(text);
imshow('im1.png'),title('Imagine decodata');
disp(A);
end
After saving the function, you should add it's path or make that folder as present working directory and call the function.
I=imread('im1.png');
[dec_text]=decodare_txtf(I) ;

10 个评论

Thanks is accepting or voting the answer... ;)
I want to! But how? I can't find the option to do that
Whit the same code, how can i make it to show me the full text? it's showing me only the first 128 characters. Where do i make the mistake? I have to recal the code again? And i deleted the function.
Now the code is this
I=imread('somename.png');
[row ,col] = size(I);
dec_text = zeros(1, row);
pas = col/4;
for i = 1 : row
aux = 0;
aux = uint8(aux);
for j = 1:4
aux = aux * 2^2;
aux = aux + mod(I(i,j*pas), 2^2);
end
dec_text(i) = char(aux);
end
dec_text = char(dec_text);
disp(dec_text);
Is your image possibly 128 rows high? Your code creates one entry in dec_text for each row of I.
Yes. It has 128 rows and colums... Is that why? Do i need to modiffy the size?
For each row, the code takes the last column in each "quarter", and uses 2 bits from it, building up to a total of 4*2 = 8 bits for each row. With 128 rows, that gives you 128 entries.
Your text file, 1.txt, is not used in any way by the code you posted.
Perhaps the code is intended to be the decoding portion. If so, then the way it is constructed assumes that you encode exactly 8 bits per row, so if you have more than 128 characters, you would need a larger image with more rows. Or you would need to change the way the data was hidden.
Thank you so very much!
I've changed both the text length and image size. 1024/1024 and it worked. Thank you for your help!

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Convert Image Type 的更多信息

产品

版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by