我正在努力将文字隐藏到图片中..但我无法收到确切的短信..有人可以帮助我解决问题并弄错我的代码..价值我正在使用的是2.这里的代码如下:
clc;
close all; clear all;
clf;
cov_img=imread('pears.png');
cov_img1 =rgb2gray(cov_img);
cov_img1=imresize(cov_img1,[256 256]);
imshow(cov_img1);
k=input('enter no of bits ');
a='In this context, cryptography, steganography and water marking schemes play a vital role in establishing secret communication through encryption, hiding and embedding secret information in digital medium respectively. ';
b=dec2bin(double(a),8);
c=b(:);
d=reshape(c,[],k);
e=bin2dec(d);
[m n]=size(e);
for i=1:256;
for j=1:256;
S(i,j)=cov_img1(i,j)-mod(cov_img1(i,j),2^k)+e(i,:);
j=j+1;
end
i=i+1;
end
figure, imshow(S,[]);
%%Extraction
for i=1:256;
for j=1:256;
E(i,j)=mod(double(S(i,j)),2^k);
j=j+1;
end
i=i+1;
end
e1=dec2bin(E,2);
e2=e1';
e3=reshape(e1,[],8);
e4=bin2dec(e3);
e5=char(e4);
disp(e5)
[mse psnr]=msepsnr(cov_img1,S);
disp('PSNR value is : ');
disp(psnr);
disp(' db');
disp('MSE value is');
disp(mse);
%%%%%%%
答案 0 :(得分:-1)
我不完全理解该方法,但是你不会得到完整的消息,因为e是长度872而我只运行到256.因此S将不包括你的完整消息。您也不需要在Matlab中的for循环中执行j = j + 1。以下对我有用(即使e的长度可能在e1的定义中未知):
clc;
close all; clear all;
clf;
cov_img=imread('pears.png');
cov_img1 =rgb2gray(cov_img);
cov_img1=imresize(cov_img1,[256 256]);
imshow(cov_img1);
k=2;
a='In this context, cryptography, steganography and water marking schemes play a vital role in establishing secret communication through encryption, hiding and embedding secret information in digital medium respectively. ';
b=dec2bin(double(a),8);
c=b(:);
d=reshape(c,[],k);
e=bin2dec(d);
[m n]=size(e);
Z = zeros(256);
Z(1:length(e)) = e;
for i=1:256;
for j=1:256;
S(i,j)=cov_img1(i,j)-mod(cov_img1(i,j),2^k)+Z(i,j);
end
end
figure, imshow(S,[]);
%%Extraction
for i=1:256;
for j=1:256;
E(i,j)=mod(double(S(i,j)),2^k)';
end
end
e1=dec2bin(E(1:length(e)),2);
e2=e1;
e3=reshape(e2,[],8);
e4=bin2dec(e3);
e5=char(e4);
disp(e5')