Can any one help be to debug it?

1 次查看(过去 30 天)
fp = fopen('C:\Users\hello\Documents\MATLAB\Full RSA Implement\plaintext.txt','r+');
SecretMsg=fread(fp,256*256*3/8);
fclose(fp);
SM=de2bi(SecretMsg);
SM1=reshape(SecretMsg,256*3,length(SecretMsg)/(256*3));
SM=de2bi(SM1);
HS = logical(de2bi(uint8(SM1)));
[StRow,StCol]=size(HS);
I1(1:StRow,1:StCol) = HS(1:256,1:256);
I2(1:StRow,1:StCol) = HS(257:513,257:513);
I3(1:StRow,1:StCol) = HS(514:771,514:771);
II = I8*128+I7*64+I6*32+I5*16+I4*8+I3*4+I2*2+I1;
Here i have a used text file which contains 24576 characters. I want to hide in the 1st, 2nd and 3rd bit plane of cover image which is of 256X256 size.
it gives an error ??? Index exceeds matrix dimensions.
Error in ==> Spatial_thesis at 39 I1(1:StRow,1:StCol) = HS(1:256,1:256);
  2 个评论
Image Analyst
Image Analyst 2016-9-15
First of all, you didn't attach your text file. Secondly, it will be so much more faster if you learn to debug it yourself. http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/ Debugging via back and forth Answers postings is a very very slow way to do it.
I'd guess that HS is not 256x256. What is it's size? You should be able to figure that out. If not, see this
Sanjeeb Behera
Sanjeeb Behera 2016-9-16
Thank u for ur ans. But here the HS conatains 24576 character of text file i.e plaintext.txt
Then I want to hide this text file in 1st, 2nd and 3rd lsb plane of cover image which is of 256x256 size.
So here i have done in following way some part of pliantext.txt hides in 1st, and some part in 2nd and rest in 3rd part. So can u tell me how can i do it?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2016-9-16
The output of de2bi(uint8(SM1)) is going to be (something by 8) (8 because 8 bits).
Then I want to hide this text file in 1st, 2nd and 3rd lsb plane of cover image which is of 256x256 size.
However, you are accessing HS, which is not the cover image, it is the bits of the secret message.
  2 个评论
Sanjeeb Behera
Sanjeeb Behera 2016-9-16
Here HS is the secret message and the cover image bit planes are I1, I2 and I3
Walter Roberson
Walter Roberson 2016-9-16
%you overwrite the result of the first assignment to SM so there is no point doing the assignment
%SM = de2bi(SecretMsg, 8);
SM1=reshape(SecretMsg,256*3,length(SecretMsg)/(256*3));
%you do not do anything with the result of the second assignment to SM so there is no point doing the assignment
%SM = de2bi(SM1, 8);
HS = logical(de2bi(uint8(SM1), 8)) %do not assume that the source has 8 bits per character; a lot of text only needs 7 bits
At this point, HS will be 24576 by 8.
And that is as far as I can understand your code. In words, what part of HS do you think is going into the first bit plane? What part of HS do you think is going into the second bit plane?
Or consider the first character of SecretMessage. It is being broken up into 8 bits. Where are you expecting each of those 8 bits to be stored into the cover image, keeping in mind that you are storing into only 3 of the bit planes of the cover image ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by