0

I have an image I want to hide some text in it

I think I should get the bitplanes as follows:

a=imread('insect.gif');

[m n]=size(a);

for i=1:m,
    for j=1:n,
        b8(i,j)=bitand(a(i,j),128);
        b7(i,j)=bitand(a(i,j),64);
        b6(i,j)=bitand(a(i,j),32);
        b5(i,j)=bitand(a(i,j),16);
        b4(i,j)=bitand(a(i,j),8);
        b3(i,j)=bitand(a(i,j),4);
        b2(i,j)=bitand(a(i,j),2);
        b1(i,j)=bitand(a(i,j),1);
    end
end

so that I have first bit in "b1",second bit in "b2",third bit in "b3",....

s='class is good'
h=dec2bin(s,8)

it will give me my text each character in 8 bits I think I should hide my text in the LSB of the matrix of the image but I don't know how to do that.

4

3 回答 3

0

实际上有两种方法:

第一个是将数据隐藏在图像中,当数据和图像没有任何共同点时,通常称为“隐写术”。

第二个是嵌入注释数据,当数据描述图像时。在这种情况下,数据和图像具有紧密的空间关系。

您所指的称为“位平面修改”。您可以在网上查看质量要求,但在大多数情况下,几乎可以节省每个字节最多更改 4 位(我们使用https://ece.uwaterloo.ca/~z70wang/research/iwssim/进行质量测量)。

还请注意颜色空间转换,因为图像几乎从不存储在 RGB 颜色空间中。

于 2014-09-14T10:28:44.193 回答
0

检查文件交换上的LSB STEGANOGRAPHY提交。

代码是开放的,这正是您所需要的。

于 2012-04-28T05:21:04.193 回答
0

假设您有一个字节图像(8 位),那么让我们看看前 3 个编码字节或 24 个像素。还假设我们要隐藏值 255、1 和 12。

在编码 3 个值之前

  MSB----LSB
1: 00000000  
2: 00000000
3: 00000000
4: 00000000
5: 00000000
6: 00000000
7: 00000000
8: 00000000

9: 00000000
10: 00000000
11: 00000000
12: 00000000
13: 00000000
14: 00000000
15: 00000000
16: 00000000

17: 00000000
18: 00000000
19: 00000000
20: 00000000
21: 00000000
22: 00000000
23: 00000000
24: 00000000

编码 3 个值后

  MSB----LSB
1: 00000001 
2: 00000001
3: 00000001
4: 00000001
5: 00000001
6: 00000001
7: 00000001
8: 00000001

9: 00000000
10: 00000000
11: 00000000
12: 00000000
13: 00000000
14: 00000000
15: 00000000
16: 00000001

17: 00000000
18: 00000000
19: 00000000
20: 00000000
21: 00000001
22: 00000001
23: 00000000
24: 00000000

所以您应该看到您需要做的就是确保每个像素的 LSB 为 0 或 1。(即您应该只需要 b1(i,j)=bitand(a(i,j),1);更改更高的有效位可能会显着改变图像)

function pixVal = setPixel(pixVal, zeroOne)

   isOdd = mod(pixVal,2);

  if zeroOne == 1
    if ~isOdd 
       pixVal = pixVal +  1;
    end
  else 
    if isOdd
       pixVal = pixVal - 1;
    end
  end

end    



function arr = setTextInArr( arr, text )

 %convert text to binary
 lsb = dec2bin(text,8)';

 for i=1:numel(lsb)
    val = arr(i);
    val = setPixel(val, str2num(lsb(i)));
    arr(i) = val;
 end

end

在小图像中编码“hi”

>> img = zeros(8,16, 'uint8')

img =

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

>> s = 'hi'

s =

hi

>> encImg = setTextInArr(img,s)

encImg =

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     1     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     1     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     1     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
     0     1     0     0     0     0     0     0     0     0     0     0     0     0     0     0
于 2012-04-28T07:13:54.147 回答