通过LSB替换方法理解图像隐写术 [英] Understanding image steganography by LSB substitution method

查看:2321
本文介绍了通过LSB替换方法理解图像隐写术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解



如果我们决定隐藏k位从秘密图像中,我们希望那些是最重要的位。类似地,我们可以将它们隐藏在封面图像的k个最低有效位中。 k值越大,你就会隐藏更多的信息以保证更忠实的重建,但是你会给封面带来更多的失真。



让我们看看分解代码中的嵌套函数以查看它们的作用。我将使用 k 而不是 n 来保持与上述部分的一致性。



bitcmp(2 ^ k - 1,8)为8位创建2 ^ k - 1的补码。例如,如果k = 3,则2 ^ k - 1就像位 00000111 ,显然它的补码是 11111000 。我们将使用这个数字作为掩码,所以 mask = bitcmp(2 ^ k - 1,8)



bitand(x,mask)将封面图像的最后k位清零, x 。这是按位AND操作,我们称第二部分为掩码的原因是因为在我们有1的任何地方,我们保留原始位,我们得到0,我们得到0.让我们调用 clearing_pixels = bitand(x,mask)



bitshift(y,8-k)仅保留秘密的k个最高位。例如,对于k = 3,我们实现 abcxxxxx - > 00000abc 。这是通过向右移动5个位置来完成的。这是逻辑转换操作。我们将此结果称为 secret = bitshift(y,8-k)



最后, bitor(clearing_pixels,secret)简单地将两者结合在一起。清除的像素清除最后的k位,秘密最多为k位,因此这两个部分不相互作用;我们得到了一个纯粹的组合。


I am having a very hard time in understanding the LSB based steganography method given in Section 2. The examples in the internet are very confusing and unclear. I am following the Matlab implementation https://www.mathworks.com/matlabcentral/fileexchange/41326-steganography-using-lsb-substitution and the paper titled, "A SURVEY ON IMAGE STEGANOGRAPHY USING LSB SUBSTITUTION TECHNIQUE " download link (https://irjet.net/archives/V4/i5/IRJET-V4I566.pdf)

Section 5 of this paper gives an example of the LSB based method. Suppose, P1 = [10011011], P2 = [01101010], P3 = [11001100] are the 3 bytes of the cover image into which the message M = [011] is to be embedded. The result of the embedding is P1 = [10011010], P2 = [01101011], P3 = [11001101].

I am clueless how this answer comes. Can somebody please help in giving the steps/working example to clear the concept?

Based on my understanding of the Matlab code, Stego = uint8(round(bitor(bitand(x, bitcmp(2^n - 1, 8)) , bitshift(y, n - 8))));

if n is the number of bits to be substituted, then the group of n bits are replaced by doing a complement/ comparison of the group of n bits of the cover image (x variable) with the n bits of the message (y variable). If the bits are same, then no replacement, else the bits are swapped. I dont't know if my understanding is correct or not.

解决方案

Your confusion stems from the fact that all 3 sources you're looking at talk about something different.

Paper 2, section 5

This describes the most basic form of LSB pixel substitution steganography. Each pixel is described by 8 bits. For each pixel we clear out the LSB and substitute it with one bit of the secret message. For example,

pixels = [xxxxxxxa, xxxxxxxb]
message = [c, d]
stego_pixels = [xxxxxxxc, xxxxxxxd]

Where x, a, b, c and d are bits and we don't care what x is.

Paper 1, section 2

This is the generalised form of LSB pixel substitution steganography. Instead of embedding the secret in the LSB, you embed it in the k-most LSBs. If k = 1, then we have the simple form described above. The mathematical equations is this section mean the following:

  1. We have an image of size MxN, with each pixel having a value between 0 and 255 (8 bits).
  2. We have an n-bit message, with each bit being either 0 or 1. For example, for 12 bits it'd be m = [a, b, c, d, e, f, g, h, i, j, k, l].
  3. Since we'll be embedding k bits per pixel, we group our message bits in groups of k. Assume that k = 3, then, m' = [abc, def, ghi, jkl]. Obviously, each group can have a value between 0 and 2^k - 1. Furthermore, the number of groups in m' cannot exceed the size of our image, or we won't be able to embed the whole message.
  4. We clear out the last k bits from each pixel and we substitute them with one group of m'. When you take the modulo of a number with 2^k, the remainder you get is the last k bits of the original number. So by subtracting them, we clear out the last k bits.
  5. Similar to the previous step, if we want to extract the message, we take the modulo of each pixel with 2^k to get the last k bits, where we have embedded our message. It's trivial to stitch these bit groups and obtain the original message, m, back.

Matlab code

This code hides an image of size MxN to a cover image of the same size. The idea here is the MSB holds the most information about the image and the LSB the least. For example, this is the bit plane decomposition of this image.

If we decide to hide k bits from the secret image, we want those to be the k most significant bits. Similarly, we can hide them in the k least significant bits of the cover image. The larger the k value, the more bits you'll hide from the secret for a more faithful reconstruction, but the more distortion you'll introduce to the cover.

Let's break down the nested functions in the code to see what they do. I'll use k instead of n to maintain consistency with the above sections.

bitcmp(2^k - 1, 8) creates the complement of 2^k - 1 for 8 bits. For example, if k = 3, then 2^k - 1 is like having the bits 00000111 and obviously its complement is 11111000. We're going to use this number as a mask, so mask = bitcmp(2^k - 1, 8).

bitand(x, mask) zeroes out the last k bits of the cover image, x. This is the bitwise AND operation and the reason we called the second part a mask is because anywhere we have a 1, we keep the original bit and anywhere we have a 0, we get a 0. Let's call cleared_pixels = bitand(x, mask).

bitshift(y, 8 - k) keeps only the k most significant bits of the secret. For example, for k = 3 we achieve abcxxxxx -> 00000abc. This is done by shifting the number 5 places to the right. This is a logical shift operation. We'll call this result secret = bitshift(y, 8 - k).

Finally, bitor(cleared_pixels, secret) simply combines the two together. The cleared pixels have the last k bits cleared and the secret is at most k bits, so the two parts don't interact; we get a pure combination.

这篇关于通过LSB替换方法理解图像隐写术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆