JSTEG algorithm
Input: A cover image (JPEG), and a secret message (binary data to embed).
Step 1: Convert the RGB cover image into YCbCr. Divide the image into blocks
with each having dimensions of 8 x8.
For each subimage, do the following steps:
Step 2: ShiF the gray-levels in the range [-128, 127]. DCT requires range be
centered around 0
Apply Forward DCT -> 64 coefficients (1 Detail Coefficient at F(0,0) + 63
Approximation Coefficients at other positions)
Step 3. Quantize the coefficients using the equation (i.e., reduce the amplitude
of coefficients that do not contribute a lot). This
is usually done using Q(u,v); a quantization table
Step 4. Embed secret data into the quantized DCT Coefficients
• Skip the DC coefficient from embedding(61 in this example).
• Skip coefficients that are equal to 0, or equal to 1 or -1 (to avoid
introducing zeros). These are skipped because modifying them could
create noticeable artifacts or change compression efficiency.
• Take the binary message bits.
• For each usable DCT coefficient, replace its Least Significant Bit (LSB) with
one bit from the secret message.
• Continue until all bits are embedded (or coefficients run out).
61 -3 2 0 2 0 0 -1
4 -4 2 0 0 0 0 0
-1 -2 0 0 -1 0 -1 0
0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
Image block after quantization
After inserting message bits 0010101 in row major order at the highlighted
positions:
61 -2 2 0 3 0 0 -1
4 -5 2 0 0 0 0 0
-1 -3 0 0 -1 0 -1 0
0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
Zig-zag sequence:
61 -2 4 -1 -5 2 0 2 -3 0 0 0 0 0 3 0 0 0 1 0 0 0 0 0 0 -1 0 0 -1 0 0 0 0 1 0 0 0 0 0 0
0-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Step 6. Encode the coefficients using Huffman coding
When decoding:
• JPEG entropy decoding recovers the quantized coefficients.
• Read the LSBs of non-zero AC coefficients
• This will recover the hidden sequence
Huffman Encoding Technique
Consider a 10x10 image with gray level intensity levels from a1 to a6, with the
following frequencies (number of occurrences of each value ):
a1 = 10
a2 = 40
a3 = 6
a4 = 10
a5 = 4
a6 = 30
----------
Total no of pixels = 100
Forward Pass
1. Sort probabilides per symbol. e.g., Probability of pixel a1 is 10/100 = 0.1
2. Combine the lowest two probabilides
3. Repeat Step2 undl only two probabilides remain.
Backward Pass
4. Assign code symbols going backwards
Hence to encode the sequence a3, a1, a2, a2, a6; subsdtute with the codes.
Encoded output: 010100111100
Avg code length = 0.4*1 + 0.3*2 + 0.1*3 + 0.1*4 + 0.06*5 + 0.04*5 = 2.2
bits/symbol
Huffman Decoding
• Coding/decoding can be implemented using a look-up table.
• Decoding can be done unambiguously.
[Link]