所以这就是我想要做的。我对matlab完全陌生。我使用它才一天左右,这是我的老师要求我做的一些事情。使用 LSB 算法在图像中嵌入语句或字符串组。该字符串将从文件中读取。到目前为止,我还没有使用任何文件操作。我正在尝试使用一个字符,但我不知道出了什么问题。算法看起来很简单,但我的输出,即封面和 steg 像素都显示相同的值。:(
cover=imread('D:\l.jpg');
steg=cover;
l=1;
LSB=0;
height = size (cover, 1);
width = size (cover, 2);
message = 'J' ;
mdec = uint8(message);
mbin = dec2bin(mdec, 8);
mbins= mbin(:);
len=length(mbins);
for i = 1:height
for j = 1:width
if(l<=len)
LSB = mod(cover(i,j), 2);
if(mbins(l)==LSB)
steg(i,j) = cover(i,j);
else if (mbins(l)~=LSB && LSB==1 && mbins(l)==0)
steg(i,j) = cover(i,j)-1;
else if (mbins(l)~=LSB && LSB==0 && mbins(l)==1)
steg(i,j) = cover(i,j)+1;
end
end
end
l=l+1;
end
end
end
imwrite(steg,'D:\hidden.jpg');
%imshow(steg)
cover(1, 1:8)
steg(1, 1:8)