1

I am creating a Python 3 application for steganography, specifically JPEG steganography. For this reason, I have to implement some basic JPEG compression to access the quantized DCT coefficients and embed bits into the LSBs. I have implemented all of this, but now I have a problem with saving the coefficients as a JPEG image.

All of the libraries I have found will perform full JPEG compression when saving an image with the .jpg extension. But I don't want it, as I have already done the lossy parts of the compression myself. I want it to only perform the lossless parts and save the image without performing DCT transformation and quantization on it again.

Has anyone tried to do this before? Are there any libraries out there that let you essentially save a 2 or 3 dimensional numpy.ndarray as a JPEG image without performing lossy compression on it again?

Here is an example of how the transformed, quantized, and embedded coefficients look:

[[[-48.  -1.  -9.]
  [ -3.   0.   1.]
  [  0.  -0.  -0.]
  ...
  [  0.  -0.   0.]
  [ -0.  -0.   0.]
  [ -0.  -0.  -0.]]
 [[  3.   0.  -2.]
  [ -0.  -0.   0.]
  [  0.   0.   0.]
  ...
  [ -0.   0.  -0.]
  [  0.   0.  -0.]
  [ -0.  -0.   0.]]
 [[ -0.   0.   0.]
  [ -0.   0.   0.]
  [  0.   0.   0.]
  ...
  [  0.   0.  -0.]
  [ -0.   0.   0.]
  [  0.   0.  -0.]]]
nodzu
  • 11
  • 2
  • 1
    I would have thought if you are able to code the DCT, it would be relatively simple by comparison, to do the entropy coding aspect! :-) – Mark Setchell Jun 04 '19 at 12:42
  • Welcome to Stack Overflow. Make sure you read the [FAQ](https://stackoverflow.com/help) to know what questions to avoid and how to construct a good question. Asking for libraries is considred off topic. You are correct in that all you have to do is implement the second (and lossless) phase of jpeg encoding. You can either a) read up on the standard to see what you have to do by yourself, or b) borrow a complete jpeg encoder (or library) and modify the part after it obtains the quantised DCT coefficients to inject your steganographic algorithm. – Reti43 Jun 04 '19 at 14:12

0 Answers0