Save JPG image on matlab without changing the quantization table

1 view (last 30 days)
I'm working on a steganography method, and I'm trying to test it against noise and Gaussian low pass filter. I edited the image, and I want to save the changes, I'm using imsave, and imwrite, but both methods change the quantization table and the huffman tables of my image, I'm looking for a way to save the image without altered the quantization tables and the huffman tables.

Answers (1)

Walter Roberson
Walter Roberson on 7 Aug 2015
In order to do that, you would need to access the binary representation of the JPEG file, find out where the data is stored in the file and overwrite it.
  2 Comments
Bilal Maskaleh
Bilal Maskaleh on 8 Aug 2015
I don't think it is a good idea, in order to do that, we should repeat the jpeg compression over the image which is already compressed.
Walter Roberson
Walter Roberson on 8 Aug 2015
Your edited image is not already compressed. You need to read the binary .jpg file to extract the quantization tables and huffman tables, use those to compress the edited image getting out the compressed coefficients, and then write the compressed coefficients in binary on top of the original compressed coefficients in the .jpg file where they must be exactly the same length as the original binary compressed coefficients.
imread() is not at all capable of telling you want the quantization tables and huffman tables are that are stored in a .jpg file, and there is no JPEG class like there is a TIFF class. You will need to either write the code to find the tables yourself or you will have to find someone who has written it already, somewhere on the Internet. You might want to start by looking at libjpeg

Sign in to comment.

Categories

Find more on Denoising and Compression in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!