[英]Why does GIF pixel values change when saved in python?
I'm trying to write a steganography applcation using the LSB method and it works so far well enough for a few image formats . 我正在尝试使用LSB方法编写隐写术应用程序,到目前为止,它对于某些图像格式已经足够好了。
However it doesn't work for GIF images since i have noticed that the saved gif has a few different pixel values (usually +- 1) and the LSB method relies on changing the least significant bit so a few different values throws the decoding algorithm off. 但是,它不适用于GIF图像,因为我注意到保存的gif具有几个不同的像素值(通常为+-1),而LSB方法依赖于更改最低有效位,因此,几个不同的值会导致解码算法无法正常运行。
i have tried using both imageio and PIL.Image and it's the same problem in both cases 我尝试过同时使用imageio和PIL.Image,在两种情况下都是相同的问题
So basically my question is : Why does the pixel values change when saved and is it even possible to use LSB for encoding and decoding a GIF ? 所以基本上我的问题是:为什么像素值在保存时会发生变化,甚至可以使用LSB来编码和解码GIF?
Thanks for your help. 谢谢你的帮助。
Gif is lossless it should not change the pixels, I recently did a little application using LSB method with gif format here is few things you should do: Gif是无损的,它不应该更改像素,我最近使用LSB方法和gif格式做了一个小应用程序,这是您应该做的几件事:
make sure when you encoded right, try replacing the pixel(0,0) then verify if the value is change if not so check the decoding 确保正确编码后,尝试替换pixel(0,0),然后验证值是否更改(如果未更改),请检查解码
make sure that the gif color is 255 确保gif颜色为255
you will encounter this later but you should put the original metadata and delay time when assembling the frames 您稍后会遇到此问题,但组装框架时应放置原始元数据和延迟时间
These are the main issues, other than that as I said earlier it is a lossless compression just like png it should not change the pixels so the problem is either in coding/decoding or type of the RGB color. 这些是主要问题,除了我之前说的那样,它是无损压缩,就像png一样,它不应更改像素,因此问题出在编码/解码或RGB颜色类型上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.