Predict Original JPEG Quality Factor with ML

Machine learning models can accurately predict the original, pre-compression quality factor (QF) of a modified JPEG image. By analyzing subtle quantization artifacts, discrete cosine transform (DCT) coefficient distributions, and compression inconsistencies, modern machine learning and deep learning architectures can reverse-engineer an image's compression history. This forensic capability remains effective even when the image has undergone subsequent editing, cropping, or re-compression.

The Mechanics of JPEG Compression Artifacts

JPEG compression operates in the frequency domain. An image is divided into 8x8 pixel blocks, transformed using the Discrete Cosine Transform (DCT), and quantized using a specific quantization table determined by the Quality Factor (ranging from 1 to 100).

Quantization is inherently lossy and rounds DCT coefficients to specific integer steps. This rounding leaves behind a distinct mathematical footprint:

How Machine Learning Detects the Primary Quality Factor

When an image is modified—such as being edited and saved again at a different quality level—it undergoes "double compression." Machine learning systems predict the primary QF by recognizing the interaction between the original and secondary compression stages.

1. Feature-Based Classifiers

Traditional machine learning methods extract engineered features from the image:

2. Deep Convolutional Neural Networks (CNNs)

Deep learning models typically outperform traditional feature-based methods by operating directly on raw pixels or unquantized DCT domains:

Key Challenges in Modified JPEGs

While prediction is reliable under controlled conditions, several modifications complicate the prediction process:

Real-World Applications

Predicting the original quality factor plays a vital role in digital media verification: