DOUBLE JPEG COMPRESSION DETECTION FOR DISTINGUISHABLE BLOCKS IN IMAGES COMPRESSED WITH SAME QUANTIZATION MATRIX
This project performs error analysis on JPEG-compressed images using the UCID dataset. It identifies rounding and truncation errors in DCT coefficients, processes them, and trains a Support Vector Machine (SVM) model for classification of iamges as double or simple compressed.
project_root/
├── *.py `` # Python scripts
├── *.m # MATLAB scripts
└── ...
├── data/ # Expects `ucid.v2` folder here (level equivalent to root)
- Download the UCID dataset (e.g., from here).
- Place it outside the project root directory like so:
../data/ucid.v2/
Install using:
pip install -r requirements.txt
MATLAB is required for intermediate processing steps.
python data_maker.py
This converts all UCID images to grayscale JPEGs using a specific quality factor.
Run patch_maker.py
twice:
python patch_maker.py
- First with
train=True
- Then with
train=False
Modify the path variable inside the script before each run to ensure correct file I/O.
Run this in terminal:
matlab -nodisplay -nosplash -r "save_error_images; exit"
This will:
- Compute error blocks
- Extract DCT coefficients
- Separate rounding and truncation errors
- Save
.mat
files for training and testing
python run_all_mat_2_npz.py
Converts MATLAB .mat
files to NumPy .npz
format.
python svm.py
Trains an SVM classifier on the error features and evaluates the performance.
To save error blocks as images:
python visualise.py
To generate plots for rounding and truncation error distributions:
python visualise_r_t.py
- MATLAB is required for DCT error extraction.
- Ensure file paths are correctly set in each script before running.
- Tested with Python 3.8+ and MATLAB R2021b.
This project is intended for academic and research use only.