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

KSSV
KSSV 2021년 6월 7일
Wht error you are getting?
Anca Chivulescu
Anca Chivulescu 2021년 6월 7일
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?
Walter Roberson
Walter Roberson 2021년 6월 7일
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.
Anca Chivulescu
Anca Chivulescu 2021년 6월 7일
Thank you!

댓글을 달려면 로그인하십시오.

 채택된 답변

KSSV
KSSV 2021년 6월 7일

0 개 추천

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

Anca Chivulescu
Anca Chivulescu 2021년 6월 7일
Thank you!
KSSV
KSSV 2021년 6월 7일
Thanks is accepting or voting the answer... ;)
Anca Chivulescu
Anca Chivulescu 2021년 6월 8일
I want to! But how? I can't find the option to do that
Anca Chivulescu
Anca Chivulescu 2021년 6월 8일
Done!
Anca Chivulescu
Anca Chivulescu 2021년 6월 8일
편집: Walter Roberson 2021년 6월 8일
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);
Walter Roberson
Walter Roberson 2021년 6월 8일
Is your image possibly 128 rows high? Your code creates one entry in dec_text for each row of I.
Anca Chivulescu
Anca Chivulescu 2021년 6월 8일
Yes. It has 128 rows and colums... Is that why? Do i need to modiffy the size?
Walter Roberson
Walter Roberson 2021년 6월 8일
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.
Anca Chivulescu
Anca Chivulescu 2021년 6월 8일
Thank you so very much!
Anca Chivulescu
Anca Chivulescu 2021년 6월 9일
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

질문:

2021년 6월 7일

댓글:

2021년 6월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by