Question

I am working on image steganography problem in which i have to hide some text information inside the png image file. After successful steganograpy operation, the resultant image which is generated is larger than the original file. As i am using LSB steganography ( 1 bit, 2 bit, 3 bit) it should not increase file size because the data which is being stored is inside the existing bits of the image. No additional bytes are added to the original image. So i am not able to understand that why this happens. Conceptually it should not increase resultant file size.

For e.g.

Original File Size : 88 KB Text file size : 382KB Resultant PNG file size : 487 KB

I read that PNG employs "lossless data compression". So what i assume that PNG might be storing the image in compressed format so when i read that image bytes from the image they gets expanded and as a result my image size is increased. Please correct me if i am wrong. Any kind of help will be appreciated.

Was it helpful?

Solution

Conceptually it should increase or at least change the resultant file size. Compression depends on correlations in the image, in particular correlations in pixel values. You are changing pixel values, so you are eliminating some correlations that the compression is depending on. Saying "data which is being stored is inside the existing bits of the image" makes no sense when you are compressing. There is not only existing bits, but existing correlations you are changing.

Effectively you are adding noise in the low bits, which will always increase the size of losslessly compressed data.

Simple example: if you start off with a linear gradient in the image, with neighboring pixel values 200, 201, 202, 203, 204, 205, 206, and 207. The filter applied by PNG will take differences, which will result in (assuming you're at the start of a line) 200, 1, 1, 1, 1, 1, 1, 1. The sequence of ones compresses very well. Then you add noise in the low bits and change it to 207, 202, 205, 206, 204, 209, 210, and 210. Now the differences are: 207, -5, 3, 1, 2, 5, 4, 0. A sequence like that won't compress nearly as well as a bunch of ones.

OTHER TIPS

This is a format problem because you open the image file, per e.g. JPG format file and open the raw image and for this raw image you apply the LSB, then you save this raw image as PNG format and the data of the RAW image is more bigger that the JPG file bytes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top