数字水印中使用的技术

时间:2013-04-13 11:44:47

标签: java image image-processing watermark

我正在尝试实现一个新的数字水印系统,这是嵌入程序

参考文件可在以下链接中找到

http://www.4shared.com/folder/UNjahlTS/_online.html

我无法理解嵌入程序,所以任何人都可以帮助,谢谢

  

private byte [] encode_text(byte [] image,byte [] addition,int offset)   {

    //check that the data + offset will fit in the image

    if (addition.length + offset > image.length) {

        throw new IllegalArgumentException("File not long enough!");

    }

    //loop through each addition byte

    for (int i = 0; i < addition.length; ++i) {

        //loop through the 8 bits of each byte

        int add = addition[i];

        for (int bit = 7; bit >= 0; --bit, ++offset) //ensure the new offset value carries on through both loops
        {

            //assign an integer to b, shifted by bit spaces AND 1

            //a single bit of the current byte

            int b = (add >>> bit) & 1;

            //assign the bit by taking: [(previous byte value) AND 0xfe] OR bit to add

            //changes the last bit of the byte in the image to be the bit of addition

            image[offset] = (byte) ((image[offset] & 0xFE) | b);

        }

    }

    return image;

}

这是嵌入程序

1 个答案:

答案 0 :(得分:1)

此算法只是替换图像像素中的最后一位,并将其替换为要在图像中隐藏它的加法字节中的位

方法的输入:

  • byte[] image:您将隐藏数据的图片
  • byte[] addition:您要隐藏的数据,
  • int offset:一个变量将决定你将从中隐藏的起始索引(这只是一个技巧,你不需要从0索引开始隐藏,这取决于你)。 / LI>

然后你将在addition数组上循环,假设数组中的第一个字节是10 它的字节是(00001010)这个数据,你将它嵌入b像素。


让我们看看如何?

假设image[offset] = 20 ---&gt;让我们说offset = 0;

int b = (add >>> bit) & 1;---->in the start loop will be (00001010)
                                                          ^

然后我将通过此添加位image[offset]替换0中的最后一个重要位

image[offset] = 20------------->00010100,当我用0

替换 LSB 1

这将是00010100---------> 20

因此,我将在image[offset]中设置包含20位信息的数组中的新0


让我们说 b = 1 image[offset] = 20

所以,当我在

中替换 LSB 2
 (20)---->00010100  by the 1 it will be 00010101  
                 ^                             ^

等于(21),因此21是嵌入1后的新值


1,2: LSB 表示:以免显着位。功能

enter image description here