Skip to content

SomshekharArabali/CSDF-mini_project-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Image Forgery Detection using ELA

A Python-based tool for detecting potential image forgeries using Error Level Analysis (ELA) technique. This project helps identify manipulated regions in JPEG images by analyzing compression artifacts.

πŸ“‹ Table of Contents

Overview

This tool implements Error Level Analysis, a forensic technique that detects areas within an image that have been modified or manipulated. When an image is saved as JPEG multiple times, different regions show different error levels depending on how many times they've been compressed. Forged areas typically show different error levels compared to the original parts of the image.

Features

  • βœ… ELA Analysis - Performs Error Level Analysis on input images
  • βœ… Brightness & Contrast Enhancement - Improves visibility of compression artifacts
  • βœ… Block-based Detection - Scans images in blocks to identify potential forgery regions
  • βœ… Automated Reporting - Prints coordinates of suspicious blocks
  • βœ… Visual Output - Generates ELA difference images for manual inspection

Requirements

Python 3.x
PIL (Pillow)

Installation

Step 1: Clone the Repository

git clone https://github.com/yourusername/image-forgery-detection.git
cd image-forgery-detection

Step 2: Install Dependencies

pip install Pillow

Usage

Basic Usage

  1. Update the image_path variable with your input image location
  2. Update the output_ela_path variable with your desired output location
  3. Run the script:
python image_forgery_detection.py

Code Example

if __name__ == "__main__":
    image_path = "path/to/your/image.jpeg"
    output_ela_path = "path/to/output/ela_result.jpeg"
    
    forgery_detection(image_path, output_ela_path)

Customization

You can adjust the detection parameters:

# Adjust JPEG quality for ELA (default: 90)
ela_analysis(image_path, output_path, quality=90)

# Adjust block size and threshold for detection
forgery_detection(image_path, output_path, block_size=16, threshold=30)

How It Works

ELA Analysis Process

  1. Opens the original image
  2. Saves it at a specified JPEG quality level
  3. Calculates the difference between original and re-compressed version
  4. Enhances brightness and contrast for better visibility
  5. Scales the difference to maximize visibility

Forgery Detection Process

  1. Divides the ELA image into blocks
  2. Analyzes each block for maximum difference values
  3. Reports blocks that exceed the threshold as potential forgeries

Parameters

Parameter Description Default Value Range
quality JPEG compression quality for ELA 90 0-100
block_size Size of blocks for detection (pixels) 16 8-64
threshold Detection sensitivity 30 0-255

Parameter Guidelines

  • Quality: Lower values (70-85) create more compression artifacts, making differences more visible
  • Block Size: Smaller blocks (8-16) provide finer detection but may increase false positives
  • Threshold: Higher values reduce sensitivity; lower values increase detection but may cause false positives

Output

Visual Output

The tool generates an ELA image that shows compression artifacts as a visual representation.

Console Output

The script prints coordinates of blocks with potential forgeries:

Potential forgery detected in block at (128, 64)
Potential forgery detected in block at (144, 64)
Potential forgery detected in block at (160, 80)

Interpretation

Reading ELA Images

  • πŸ”΄ Bright/White areas - Regions with higher error levels (potentially manipulated)
  • ⚫ Dark/Black areas - Consistent compression levels (likely original)
  • 🟑 Moderate areas - May require further investigation

Understanding Results

The tool reports specific block coordinates where the difference exceeds the threshold. These coordinates indicate the top-left corner of each suspicious block.

Limitations

⚠️ Important Considerations:

  • Only works with JPEG images
  • Results require manual interpretation
  • High threshold values may miss subtle forgeries
  • Low threshold values may produce false positives
  • Not 100% accurate - should be used as one of multiple forensic tools
  • Original uncompressed images will show uniform error levels

Use Cases

  • πŸ” Digital forensics investigations
  • βœ”οΈ Image authenticity verification
  • πŸ–ΌοΈ Detecting photo manipulations
  • πŸ“š Educational purposes for learning about image forensics
  • πŸ“° Verifying news and media images
  • πŸŽ“ Academic research in digital forensics

Contributing

Contributions are welcome! Here are some areas for improvement:

  • Support for PNG and other image formats
  • GUI interface for easier use
  • Advanced detection algorithms
  • Improved visualization techniques
  • Batch processing capability
  • Statistical analysis of results

How to Contribute

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/improvement)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add new feature')
  5. Push to the branch (git push origin feature/improvement)
  6. Create a Pull Request

License

This project is open-source and available under the MIT License.

Disclaimer

⚠️ Important: This tool is intended for educational and legitimate forensic purposes only. Always ensure you have proper authorization before analyzing images that don't belong to you. The developers are not responsible for any misuse of this tool.

Author

Created for Computer Science Digital Forensics (CSDF) coursework.

References


⭐ If you find this project helpful, please consider giving it a star!

About

A Python-based tool for detecting potential image forgeries using Error Level Analysis (ELA) technique

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages