如何编辑 JPG 文件的字节代码并保留其页眉和页脚? (爪哇语)
我已经使用 Java 在 PNG 文件中成功编码了我的隐写术程序。我的程序在 PNG 和 BMP 文件中都运行得很好。但是当我尝试在 JPG 文件中运行我的程序时,显示的数据与原始数据不同。当然,每种文件类型的标头并不相同。所以现在我想知道; PNG和JPG文件的数据结构不一样吗?我需要确切地知道如何操作 JPG 文件的字节而不影响其页眉和页脚。
谢谢。
I already have successfully coded my Steganography program in a PNG file using Java. My program works very well in both PNG and BMP files. But when I tried running my program in a JPG file, the revealed data is not the same as the original data. Certainly, the headers of each file type isn't the same. And so now I wonder; Do the data structures of PNG and JPG files aren't the same? I need to know exactly how to manipulate the bytes of a JPG file without affecting its header and the footer.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要告诉您用于图像隐写术的确切方法,例如将秘密数据隐藏在图像像素的 lsb 中,以二进制格式读取文件等。
如果您的程序是使用 lsb,那么我希望以下答案满足您的查询
- “PNG”和“BMP”实际上是无损文件格式。在创建新图像时操作这些格式的像素位后,不会丢失任何数据。这就是您能够检索所有隐藏数据的原因。
然而,“JPG”格式使用有损压缩技术,因此隐藏在像素中的数据会丢失。即使我遇到了这个问题,解决方案也存在于处理变换域中的图像。您需要使用直接余弦变换方法来实现它。
变换域涉及算法和图像变换的操作,例如离散余弦变换(DCT)和小波变换。这些方法可以隐藏图像中更重要区域的信息,并且还可以操纵图像的属性(例如亮度)。此类技术比图像域逐位隐写方法更有效。变换域技术可以应用于任何格式的图像。此外,无损和有损格式之间的转换可能会保留。
DCT 在隐写术中如何工作?
图像被分解为 8x8 的像素块。 DCT 从左到右、从上到下应用于每个块。量化表压缩每个块以缩放DCT系数,并且消息被嵌入到缩放后的DCT系数中。
该方法仍需要大量研究。我正在研究它的代码并将尽快发布。
很高兴听到其他开发人员提出其他方法或不同的有效技术。
First of all you need to tell the exact method you are using for image steganography e.g. hiding the secret data in the lsb's of the pixels of the image, reading the file in a binary format etc.
If working with lsb's is your procedure then I hope the following answer satisfies your query-
'PNG' and 'BMP' are actually lossless file formats. After manipulating the bits of pixels of these formats when you create the new image no data is lost. This is the reason you are able to retrieve all the hidden data.
'JPG' formats however use a lossy compression technique due to which the data hidden in the pixels is lost. Even I faced this problem and the solution to this exists in handling the image in transform domain. You need to use the Direct Cosine Transform method for its implementation.
The transform domain involves manipulation of the algorithms and image transforms such as discrete cosine transformation (DCT) and wavelet transformation. These methods can hide information in more significant areas of the image and may also manipulate the properties of the image like luminance. These kinds of techniques are more effective than image domain bit-wise steganographic methods. The transform domain techniques can be applied to image of any format. Also, the conversion between lossless and lossly formats may survive.
How DCT works in steganography?
The image is broken down into 8x8 blocks of pixels. DCT is applied to each block from left to right, top to bottom. The quantization table compresses each block to scale the DCT coefficients and the message is embedded in the scaled DCT coefficients.
A lot of reasearch is still required in this method. I am working on its code and will post it ASAP.
It will be a pleasure to hear of other methods or different efficient techniques from other developers.