Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-Based Source Camera Identification of Digital Images Utilizing Sensor Noise Analysis

Python PyTorch Scikit-Learn OpenCV License

Author Info  •  Abstract  •  Methodology  •  Dataset  •  Experiments  •  Robustness  •  Few-Shot  •  Run on Kaggle  •  Structure  •  Reproducibility


Author Information


Abstract

Source camera identification (SCI) is a pivotal task in digital image forensics, enabling investigators to associate an image with its originating device. This repository implements and evaluates two distinct approaches: the traditional Photo Response Non-Uniformity (PRNU) noise analysis method and a proposed hybrid Deep Learning (DL) pipeline using a pretrained ResNet101 backbone coupled with a Support Vector Machine (SVM) classifier.

Evaluating on the VISION dataset (10,273 images, 10 devices, 6 smartphone models), this project explores their performance across same-model device classification, cross-model classification, large-scale multi-class identification, data efficiency (few-shot learning), and multi-level robustness against 38 unique image manipulations. The results indicate that while PRNU excels at matching exact physical sensors under clean conditions, the DL+SVM approach offers significantly better generalization and robust scaling in the presence of real-world post-processing manipulations (e.g., social media compression, geometric adjustments, and color filtering).


Methodology

This project contrasts physical sensor fingerprinting with high-dimensional feature representation extraction:

               +-------------------------------------------------------------+
               |                       Input Image (I)                       |
               +-------------------------------------------------------------+
                                              |
                     +------------------------+------------------------+
                     |                                                 |
                     v                                                 v
      [Traditional PRNU Pipeline]                        [Proposed Deep Learning Pipeline]
                     |                                                 |
  Wavelet Denoising (Daubechies 8) DWT                         Bilinear Resize (224x224)
                     |                                                 |
       Residual Extraction: W = I - f(I)                  Pretrained ResNet101 Feature Extractor
                     |                                                 |
  Reference Estimation: K = Mean(W_flat)                    Global Average Pooling (GAP)
                     |                                                 |
         Cross-Correlation Matrix                              2048-dim Feature Vector (L2-norm)
                     |                                                 |
   Peak-to-Correlation Energy (PCE) Matching                   RBF Support Vector Machine (SVM)
                     |                                                 |
                     v                                                 v
          Predicted Device ID                                 Predicted Device ID

1. Traditional Method: PRNU Sensor Fingerprinting

Sensor noise analysis estimates the unique pattern of pixel-to-pixel sensitivity variations caused by manufacturing imperfections.

  • Noise Extraction: A wavelet-based denoising filter $f(I)$ using Daubechies 8 (db8) wavelets at 4 decomposition levels is applied to the grayscale image $I$. The noise residual is calculated as: $$W = I - f(I)$$
  • Reference Construction: For each device, the reference pattern $K$ is estimated by averaging the noise residuals from 50 flat-field (out-of-focus, uniform) images: $$K = \frac{1}{N} \sum_{i=1}^{N} W_i$$
  • PCE Matching: Classification is performed by calculating the Peak-to-Correlation Energy (PCE) between the noise residual of a query image $W_q$ and the device reference pattern $K$. The PCE is defined as: $$PCE(W_q, K) = \frac{\max(C(x, y))^2}{\frac{1}{|M|} \sum_{(x,y) \in M} C(x, y)^2}$$ where $C(x,y)$ represents the circular cross-correlation surface, and $M$ is the correlation surface excluding a small $11 \times 11$ neighborhood around the peak. Predictions are validated against a decision threshold ($PCE > 50$).

PRNU Extraction Methodology

2. Proposed Method: Deep Learning (ResNet101 + SVM)

Instead of processing sensor-level noise, the proposed pipeline leverages high-level deep representations that capture lens artifacts, camera ISP (Image Signal Processor) curves, and color filter array (CFA) demosaicing footprints.

  • Intelligent Downsampling: Images are downsampled to $224 \times 224$ pixels via bilinear interpolation. This downsampling acts as a low-pass filter, suppressing high-frequency sensor noise (effectively disabling PRNU signatures) and forcing the network to extract device-specific features from mid-to-low spatial frequencies.
  • Feature Extractor: A pretrained ResNet101 network processes the image, generating a 2,048-dimensional feature map via Global Average Pooling (GAP).
  • Feature Normalization: Feature vectors are $L_2$ normalized to ensure robust similarity boundaries.
  • Classifier: A Support Vector Machine (SVM) with a Radial Basis Function (RBF) kernel is trained on these features: $$K(x, x') = \exp(-\gamma ||x - x'||^2)$$ The hyperparameter parameters are set to $C = 10.0$ and $\gamma = \text{'scale'}$.

Dataset

The benchmarks are conducted on the VISION Dataset, consisting of $10,273$ images. The dataset features a class distribution of flat-field images (flat), native natural scene images (nat), and natural images processed by social media platforms (natFBH for Facebook High Quality, natFBL for Facebook Low Quality, and natWA for WhatsApp).

Device ID Brand & Model Subfolder Distribution Total Images
D02 Apple iPhone 4s flat, nat, natFBH, natFBL, natWA 1,020
D03 Huawei P9 flat, nat, natFBH, natFBL, natWA 1,185
D05 Apple iPhone 5c flat, nat, natFBH, natFBL, natWA 1,750
D06 Apple iPhone 6 flat, nat, natFBH, natFBL, natWA 660
D10 Apple iPhone 4s flat, nat, natFBH, natFBL, natWA 890
D11 Samsung Galaxy S3 flat, nat, natFBH, natFBL, natWA 1,035
D14 Apple iPhone 5c flat, nat, natFBH, natFBL, natWA 1,045
D15 Apple iPhone 6 flat, nat, natFBH, natFBL, natWA 1,135
D18 Apple iPhone 5c flat, nat, natFBH, natFBL, natWA 1,020
D24 Xiaomi Redmi Note 3 flat, nat, natFBH, natFBL, natWA 1,560

Dataset Distribution


Experimental Setup & Quantitative Evaluation

Five experiments (Experiments A through E) evaluate performance limits across different classification paradigms using a 75/25 train/test split (80/10/10 split for Experiment E):

  • Experiment A: Intra-model matching between two Apple iPhone 4s devices (D02 vs. D10).
  • Experiment B: Intra-model matching between three Apple iPhone 5c devices (D05 vs. D14 vs. D18).
  • Experiment C: Intra-model matching between two Apple iPhone 6 devices (D06 vs. D15).
  • Experiment D: Inter-model/cross-brand classification between Huawei P9 (D03) and Samsung Galaxy S3 (D11).
  • Experiment E: Scaled multi-class classification across all 10 devices simultaneously.

Summary of Performance Metrics

Experiment Task Scope PRNU (PCE) DL (Softmax) DL + SVM (Proposed) Winner
Exp A iPhone 4s (2 devices) 82.29% 96.88% 97.92% DL+SVM
Exp B iPhone 5c (3 devices) 97.38% 94.24% 93.72% PRNU
Exp C iPhone 6 (2 devices) 90.00% 92.22% 93.33% DL+SVM
Exp D Inter-Brand (2 models) 71.17% 97.30% 97.30% DL+SVM
Exp E All Devices (10 classes) 74.50% 92.92% 91.59% DL+SVM

The results show that Deep Learning outperforms PRNU in 4 out of 5 configurations. PRNU achieves outstanding results in Experiment B, indicating that high-quality flat-field reference noise estimations remain highly effective when comparing identical-model devices under sterile conditions.

Experiments Comparison


Robustness Analysis

To evaluate practical utility, models trained on Experiment E were tested against simulated real-world manipulations organized into three levels of severity:

  • Level 1 (Single Processings): 38 unique tasks including JPEG compression (qualities 10 to 70), Instagram-style filters (Clarendon, Lark, Gingham, Lo-Fi, Reyes, Valencia, X-Pro II, Sepia, Grayscale), spatial rotations (5° to 90°), scaling transformations (25% to 75% crops, 50% to 75% resizes), brightness, contrast, and gaussian blur ($\sigma=1, 2$).
  • Level 2 (Dual Processings): 12 combined configurations of filters followed by JPEG compression.
  • Level 3 (Triple Processings): 8 complex workflows involving filtering, JPEG compression, and structural geometric distortions (e.g., Clarendon + JPEG Q30 + Rotate 15°).

Robustness Summary

Key Robustness Observations

  1. Compression Tolerance: The DL+SVM approach maintains above 90% validation accuracy under extreme JPEG compression (down to Q=10), whereas PRNU matching drops sharply.
  2. Social Media Distortions: Evaluated against actual compression pipelines from Facebook and WhatsApp:
    • WhatsApp Transmission: DL+SVM achieves 95.80% accuracy vs. PRNU's decline.
    • Facebook Uploads: DL+SVM yields 95.80% (High Quality) and 95.66% (Low Quality) accuracy.
  3. Geometric Vulnerability: Rotating images degrades DL+SVM classification performance at higher angles (e.g., $90^\circ$ rotation drops accuracy to $55.75%$) because convolutional features preserve spatial orientation.

Few-Shot Learning

Data constraints are common in forensic environments. We benchmarked the proposed DL model under few-shot paradigms, restricting training samples to $k = [5, 10, 15, 20, 30, 50]$ images per class.

$$\text{Few-Shot Accuracy Curve: } k=5 \ (42.42%) \rightarrow k=10 \ (49.83%) \rightarrow k=30 \ (68.50%) \rightarrow k=50 \ (76.50%)$$

This progression indicates that learning representative camera fingerprints from ISP patterns requires scaling training volumes beyond few-shot limits to match PRNU's baseline efficiency when high-quality references are available.

Few-Shot Learning


Repository Structure

camera_identification_vision/
├── camera-identification-vision.ipynb  # Primary notebook containing training & validation logic
├── nb_extract.txt                      # Extracted raw python code & markdown sections (for analysis)
├── figures/                            # Directory containing performance graphs & model curves
│   ├── dataset_distribution.png        # Dataset frequency plots
│   ├── prnu_extraction.png             # Step-by-step PRNU wavelet extraction details
│   ├── experiments_comparison.png      # Performance matrix comparison
│   ├── robustness_summary.png          # Performance comparison across Level 1-3 perturbations
│   └── few_shot_learning.png           # Accuracy progression over few-shot increments
├── results/
│   └── results_report.json             # Structured JSON report logging metric details
├── models/                             # Saved weights (PyTorch .pth and Scikit-Learn .pkl estimators)
└── checkpoints/                        # Training checkpoints and system status logs

Run on Kaggle

This project is optimized to run seamlessly in the Kaggle Kernel environment. Follow these steps to execute the code and reproduce the results:

  1. Upload Notebook: Upload camera-identification-vision.ipynb as a new notebook in your Kaggle account.
  2. GPU Hardware Accelerator: Navigate to the panel on the right, under Settings -> Accelerator, and choose GPU T4 x2 or GPU P100. Deep learning features require a GPU to train and run efficiently.
  3. Mount the Dataset: Add the VISION Dataset by searching for "VISION dataset" in Kaggle's public dataset search bar. Ensure the folders align with the training script paths.
  4. Update Paths in Config: Adjust the dataset path in the configuration cell of the notebook to match where the dataset is mounted (e.g., under /kaggle/input/):
    class Config:
        # Update to match your Kaggle input directory structure
        DATA_ROOT = '/kaggle/input/vision-dataset/vision_data'
  5. Run All Cells: Run the notebook. The script will train the models, evaluate both methodologies (PRNU & DL+SVM), compute robustness metrics, and output visualizations to /kaggle/working/figures/ and tabular summaries to /kaggle/working/results/.

Reproducibility Guide

1. Setup Environment

Install dependencies to run both traditional Wavelet algorithms and Neural Network pipelines:

pip install torch torchvision numpy pandas scikit-learn pywavelets opencv-python matplotlib seaborn tqdm psutil

2. Dataset Preparation

Ensure the VISION dataset structure aligns with the path definitions in Config:

vision_data/
├── D02_Apple_iPhone4s/
│   ├── flat/
│   └── nat/
├── D03_Huawei_P9/
│   ├── flat/
│   └── nat/
└── ... [other devices]

3. Pipeline Execution

Open and execute the cells in camera-identification-vision.ipynb. The pipeline is configured to automatically checkpoint model states, allowing you to pause and resume training tasks without loss of progress. To adjust model arguments, modify the parameter values directly in the Config block:

class Config:
    IMAGE_SIZE = 224
    BATCH_SIZE = 32
    NUM_EPOCHS = 25
    LEARNING_RATE = 0.001
    PRNU_REF_IMAGES = 50
    PCE_THRESHOLD = 50

All training histories, confusion matrices, and robustness evaluations will save to figures/ and results/ upon notebook completion.

About

A comparative study of source camera identification using PRNU and Deep Learning (ResNet101) on the VISION dataset, featuring comprehensive robustness and few-shot learning analysis.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages