Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 即使我保存了完整的8位灰度,从加密图像中解密图像的质量也很低_Image_Image Processing_Encryption_Steganography - Fatal编程技术网

Image 即使我保存了完整的8位灰度,从加密图像中解密图像的质量也很低

Image 即使我保存了完整的8位灰度,从加密图像中解密图像的质量也很低,image,image-processing,encryption,steganography,Image,Image Processing,Encryption,Steganography,我在做图像隐写术 我有两张同样大小的照片, 我将第二张图像保存为第一张图像中的灰度。 我保存了完整的8位灰度图像 但是在提取的时候,我得到的图像质量很低。。 这是我的密码 加密 for (int i = 0; i < simple.Height; i++) { for (int j = 0; j < simple.Width; j++) { pixelToHide = se

我在做图像隐写术 我有两张同样大小的照片, 我将第二张图像保存为第一张图像中的灰度。 我保存了完整的8位灰度图像 但是在提取的时候,我得到的图像质量很低。。 这是我的密码

加密

for (int i = 0; i < simple.Height; i++)
        {
            for (int j = 0; j < simple.Width; j++)
            {
                pixelToHide      =    secretGreyScale.GetPixel(j, i);
                BitsToHide       =    getBytes(pixelToHide.R);

                pixelForHiding   =    simple.GetPixel(j, i);
                AlphaBits        =    getBytes(pixelForHiding.A);
                RedBits          =    getBytes(pixelForHiding.R);
                GreenBits        =    getBytes(pixelForHiding.G);
                BlueBits         =    getBytes(pixelForHiding.B);

                AlphaBits[6]     =    BitsToHide[0];
                AlphaBits[7]     =    BitsToHide[1];
                RedBits[6]       =    BitsToHide[2];
                RedBits[7]       =    BitsToHide[3];
                GreenBits[6]     =    BitsToHide[4];
                GreenBits[7]     =    BitsToHide[5];
                BlueBits[6]      =    BitsToHide[6];
                BlueBits[7]      =    BitsToHide[7];

                newAlpha        =     getInt(AlphaBits);
                newRed          =     getInt(RedBits);
                newGreen        =     getInt(GreenBits);
                newBlue         =     getInt(BlueBits);

                simple.SetPixel(j, i, Color.FromArgb(newAlpha, newRed, newGreen, newBlue));
            }
        }
解密

for (int i = 0; i < EncryptedImage.Height; i++)
        {
            for (int j = 0; j < EncryptedImage.Width; j++)
            {
                pixelToDecrypt = EncryptedImage.GetPixel(j, i);

                AlphaBits = getBytes(pixelToDecrypt.A);
                RedBits = getBytes(pixelToDecrypt.R);
                GreenBits = getBytes(pixelToDecrypt.G);
                BlueBits = getBytes(pixelToDecrypt.B);

                BitsToDecrypt[0] = AlphaBits[6];
                BitsToDecrypt[1] = AlphaBits[7];
                BitsToDecrypt[2] = RedBits[6];
                BitsToDecrypt[3] = RedBits[7];
                BitsToDecrypt[4] = GreenBits[6];
                BitsToDecrypt[5] = GreenBits[7];
                BitsToDecrypt[6] = BlueBits[6];
                BitsToDecrypt[7] = BlueBits[7];

                newGrey = getInt(BitsToDecrypt);


                hiddenImage.SetPixel(j, i, Color.FromArgb(newGrey, newGrey, newGrey));
            }
        }
getBytes是将int转换为位的函数,而getint则相反。 PixelToHide和PixelForHiding是一种颜色类型
Simple是我必须在其中隐藏SecretFreyScale图像的图像。

由于没有显示子函数,所以很难看到代码中发生了什么,因此我将尝试用一般方法回答-

出于订单考虑:为了进行加密,您需要缩小要隐藏伪代码的图像,假设采用LSB/little-endian CPU体系结构:

((secretByte AND 00000011) << 6) OR (publicByte AND 00111111)
如果不缩放该值,则最大值将为255中的最大值4,这当然会变得非常微弱

如果您不想进行位移位,您可以使用除法和乘法,但您需要位掩码:

Enc: ((secretByte / 64) AND 11000000) OR (publicByte AND 00111111)

Dec: (imageByte AND 11000000) * 64

另一个功能只是将字节转换为int,反之亦然。但是m存储所有8位灰度图像。。。。难道它不应该给我同样的印象吗??其次,为了提取图像,像素中除了R、G、B之外还有其他信息需要保存吗properly@assassino隐写术通常通过在两个位范围内隐藏两个图像来工作。但是对于不可见的秘密图像,它们只能占用1-2个较低的位。您也可以使用RGB-重要的部分是分离位范围。秘密图像的质量将降低,以便能够适应这两个位。您可以将图像或消息编码为例如2D条形码并隐藏,或者使用大图像并将较小的图像分散到区域中,然后将区域合并回8位。如果不使用整个代码来测试结果,此段看起来很好。为了确保,pixelToHide已经是灰度级,所以为像素选择哪个颜色平面无关紧要。怀疑:您保存加密图像的格式是什么?有些格式不支持透明度png应该可以。还有另一个问题。当我从图片盒中获取像素时,它会改变许多位,从而降低图像质量。但当我使用相同的位图时,它会给出正确的修改像素值。。这意味着setPixel函数有问题???我真的不知道,我正在使用*.bmp exytension保存图像。但这并不重要,因为如果我不保存图像并直接从picturebox中获取图像,我会给我同样的问题。我不理解你刚才提到的第二个问题。请你更新一下你的问题,详细说明一下,并提供完整的源代码。当我从位图中读取值时,我修改的像素与我更改的像素相同,值与我更改的像素相同,但如果我将该图像放入picturebox或保存它,然后如果我从picturebox中读取该图像,则像素的值将被忽略改变了,或者说图像质量降低了。
Enc: ((secretByte / 64) AND 11000000) OR (publicByte AND 00111111)

Dec: (imageByte AND 11000000) * 64