Final Final Report Mazen Walid
Final Final Report Mazen Walid
Level Analysis
Team Members
Bassem Gabr Sadaqah 120210142
Mohamed Kamal Kamel 120200137
Mazen Walid Ahmed 120200020
Table of Contents
1 Abstract ........................................................................................................................................ 3
2 Teaser Figure ................................................................................................................................ 4
3 Introduction ................................................................................................................................. 4
4 Approach ...................................................................................................................................... 4
5 Experiments C Results................................................................................................................. 6
5.1 Dataset ................................................................................................................................. 6
5.2 Experimental Setup ............................................................................................................. 6
5.3 Evaluation Metrics ............................................................................................................... 7
5.4 Results Table........................................................................................................................ 7
5.5 Comparison with Baseline .................................................................................................. 7
5.6 Parameter Tuning ................................................................................................................ 8
6 Ǫualitative Results ....................................................................................................................... 8
6.1 Detailed Observations ......................................................................................................... 8
Conclusion ............................................................................................................................................ 9
Future work ........................................................................................................................................ 10
References ......................................................................................................................................... 10
1 Abstract
With the rise of digital media, image tampering has become a widespread concern. From social
media posts to legal evidence, the authenticity of images can no longer be taken for granted. In this
project, a simple and explainable method for detecting image forgeries using Error Level Analysis
(ELA) is presented. An implementation of a lightweight system that highlights tampered regions and
uses a small convolutional neural network (CNN) to classify images as either real or fake. An 85%
accuracy on the CASIA v2 tampering dataset is achieved, demonstrating that even basic tools can
provide effective forensic insights.
2 Teaser Figure
The image shown above shows a side-by-side comparison of an original photograph of a lush green landscape
and its ELA-transformed version. The ELA image highlights a spliced region where a tree has been
artificially added, with the word "FAKE" overlayed to emphasize the manipulation.
3 Introduction
The manipulation of digital images has become accessible to anyone with basic editing tools, raising
significant concerns in areas where visual integrity is critical. Techniques like splicing, cloning, or
object removal can alter image content subtly yet deceptively. Traditional deep learning-based
forgery detectors are powerful but often opaque and computationally expensive.
Error Level Analysis (ELA) provides a visual, interpretable method to highlight modified image
regions. It leverages JPEG compression characteristics to detect differences in compression levels
that may indicate tampering. This project combines ELA with a small, custom-built CNN to classify
images, focusing on transparency, simplicity, and effectiveness.
4 Approach
The project uses the concept of Error Level Analysis (ELA), a traditional image forensics technique.
JPEG images lose quality every time they are resaved. If a region is edited and reinserted into an
image, its compression level often differs from the rest of the image.
The system performs the following steps:
This project adopts a sequential approach, starting with image preprocessing and ending with
classification using a model.
• Subtracting the recompressed image from the original to compute a difference image.
The goal of ELA is to expose compression differences that may suggest tampering, as altered
regions usually compress differently than the rest of the image.
Step 2: Preprocessing
The ELA image is resized to a uniform size of 128x128 pixels to ensure compatibility with the
CNN input. The pixel values are normalized to the range [0, 1] by dividing by 255.
The CNN consists of two convolutional layers with ReLU activation and 3x3 kernels, each
followed by 2x2 max pooling. After flattening, a dense layer with 128 neurons and dropout (0.5)
connects to the final sigmoid output layer for binary classification.
The model is compiled with the Adam optimizer and binary cross-entropy loss and trained for
10 epochs, which provides a good balance between learning and overfitting for this dataset
size.
Step 4: Prediction
During testing, the model predicts whether an ELA-transformed image is "Real" or "Fake." The
prediction is based on a probability threshold (0.5). Visual results are also displayed to allow
manual interpretation.
The following list contains the tools and libraries used in this project:
Implementation Notes
The codebase is structured modularly to improve clarity and maintainability. Separate Python
scripts were developed for distinct tasks: one for generating ELA images (ela.py), one for
training the CNN model (train_model.py), and one for making predictions (predict.py). This
modular approach allowed for easier testing and debugging. Throughout development, the
design was refined based on iterative performance evaluations, ensuring that both the
classification accuracy and the interpretability of the results met the project goals. This
structured methodology simplifies future modifications and encourages reuse in similar image
analysis applications. It also aligns with best practices in software development, such as
separation of concerns and minimal coupling between modules.
5 Experiments G Results
5.1 Dataset
• Accuracy: 85.1%
• Precision: 87.3%
• Recall: 82.6%
Metric Value
Accuracy 85.1%
Precision 87.3%
Recall 82.6%
The results table above shows that the model correctly predicted the class (Real or Fake) in
85.1% of test cases, indicating strong overall performance. Precision, at 87.3%, reflects how
many images labeled as "Fake" by the model were actually fake, which is crucial for reducing
false accusations. Recall, at 82.6%, measures how many actual fake images were successfully
detected, highlighting the model's ability to identify tampered content. Together, these metrics
confirm the model's reliability for forgery detection while also identifying areas for future
improvement.
In summary, the model maintains a high level of precision, which is critical in reducing false
alarms when labeling an image as fake. The recall score reflects the model’s ability to detect a
wide range of manipulations. These scores, when combined with overall accuracy,
demonstrate the system’s effectiveness in real-world scenarios where both trustworthiness
and detection sensitivity are important.
The model's performance was compared against a naive baseline where predictions are made
randomly. A random classifier would be expected to achieve approximately 50% accuracy,
reflecting pure chance in binary classification. In contrast, this model achieved over 85% accuracy,
clearly demonstrating the advantage of using ELA features and a trained CNN. This comparison
reinforces the effectiveness of the approach in reliably detecting manipulated images.
5.6 Parameter Tuning
Several tuning experiments were conducted to optimize the CNN’s performance. Increasing the
number of convolution filters from 16 to 64 enhanced the model’s ability to detect more complex
spatial features within ELA images. This change led to more nuanced feature extraction, which
improved classification accuracy.
Additionally, a dropout rate of 0.5 was applied before the final dense layer to reduce the likelihood
of overfitting. This helped maintain generalization across both training and validation datasets. Other
hyperparameters such as learning rate and batch size were tested in earlier iterations but showed
marginal impact compared to the improvements gained from adjusting filter size and dropout.
6 Ǫualitative Results
The visual examples below demonstrate how Error Level Analysis (ELA) transforms images and
how our CNN interprets these transformations to classify them as "Real" or "Fake." This
section provides a deeper qualitative analysis of the model's behavior on various image types
from the CASIA v2 dataset.
The Error Level Analysis (ELA) transformation provides direct visual insights into our model's
classification decisions. For real, untampered images (true negatives), the ELA output typically
shows a uniform, low-intensity noise pattern across the entire image. This consistency reflects a
single, original JPEG compression history, and the CNN learns to recognize this subtle, even noise
as a signature of authenticity. Conversely, when the model correctly identifies fake images (true
positives), the ELA transformation often reveals distinct, bright, and high-contrast regions—either as
clear outlines or prominent patches, precisely where manipulation like splicing or copy-move
forgery has occurred. These bright areas signify differing compression characteristics between the
original and altered parts, a key feature the CNN leverages for accurate detection.
However, the system can encounter challenges, leading to misclassifications. False positives, where
a real image is incorrectly flagged as fake, usually happen with authentic images that have
undergone multiple re-compressions or were initially saved at very low JPEG quality. In these cases,
the ELA image presents widespread, brighter, and somewhat inconsistent noise across the entire
frame, mimicking the appearance of tampering. The CNN, trained to spot anomalies, can sometimes
over-sensitize to these inherent high or irregular compression artifacts, leading to a false alarm. On
the other hand, false negatives, where a fake image is missed and classified as real, often arise from
highly skilled forgeries. Here, the manipulated regions are blended so seamlessly, or the tampering
method introduces such minimal compression differences, that the ELA image shows only very faint
or diffuse irregularities, making them hard to distinguish from the natural noise of an authentic
image. The subtle ELA artifacts simply fall below the model's learned detection threshold in such
challenging scenarios.
Despite these complexities, the inherent interpretability of the ELA-based approach remains a
significant advantage. The ELA-transformed image itself serves as a visual "heatmap," directly
pinpointing potential areas of manipulation. This transparency allows for human verification and
understanding of the model's decision, moving beyond a black-box classification and fostering
greater trust in the system's output.
Conclusion
This project successfully developed and validated a transparent and efficient method for
digital image forgery detection, leveraging the unique characteristics revealed by Error Level
Analysis (ELA) in conjunction with a lightweight Convolutional Neural Network (CNN).
By training the CNN on ELA-transformed images from the CASIA v2 dataset, the system
achieved a solid accuracy of over 85% (specifically 85.1% accuracy, 87.3% precision, and
82.6% recall). This performance significantly surpasses a random baseline, unequivocally
demonstrating the effectiveness of combining ELA features with a supervised learning
approach.
A key strength of this methodology lies in its minimal computational requirements, making it a
viable solution for real-time or resource-constrained applications, unlike many
computationally intensive deep learning models. Furthermore, the inherent visual
interpretability provided by ELA is a critical advantage; the ELA-transformed image itself serves
as a direct indicator of potential manipulation, allowing human experts to visually corroborate
the model's predictions and understand why a decision was made.
This combination of accuracy, efficiency, and interpretability fulfills the project's primary
objectives, offering a robust and understandable tool for image tampering detection.
Future work
To further enhance this system, we can explore several promising directions:
1. Video Forensics: Extend the ELA and CNN approach to analyze individual frames in
video sequences, enabling the detection of tampering in video content like deepfakes.
2. Advanced Explainable AI (XAI): Integrate tools like Grad-CAM to pinpoint the exact
regions in the original image that trigger the CNN's forgery detection, offering even
deeper insights.
4. Multi-Modal Analysis: Combine ELA with other forensic techniques such as shadow
detection, metadata analysis, and noise pattern analysis to build a more robust and
comprehensive forgery detection framework.
References
1. CASIA Image Tampering Dataset: http://forensics.idealtest.org
2. ELA Technique Overview: https://29a.ch/photo-forensics/#error-level-analysis
3. TensorFlow/Keras Documentation: https://keras.io/
4. PIL Documentation: https://pillow.readthedocs.io
5. OpenCV Library: https://opencv.org