Skip to content

This project is a lightweight Python tool that helps you compare two images and determine whether they are identical or different. It uses Structural Similarity Index (SSIM) to go beyond simple pixel matching, making it robust against small changes like resizing or minor color shifts.

Notifications You must be signed in to change notification settings

rsakib15/image-comparator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Comparator

A lightweight Python tool for comparing two images to detect differences using the Structural Similarity Index (SSIM) from scikit-image. Perfect for image processing, quality assurance, and computer vision projects.

Features

  • Computes a similarity score (SSIM) between two images.
  • Classifies images as identical, similar, or different based on a customizable threshold.
  • Saves a difference image (diff.png) to highlight changes.
  • Simple command-line interface (CLI) for easy use.
  • Supports all OpenCV-compatible image formats (e.g., PNG, JPG, BMP).
  • Lightweight and extensible for integration into larger workflows.

Prerequisites

  • Python 3.8 or higher
  • pip for dependency installation
  • Git for cloning the repository

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/image-comparator.git
    cd image-comparator
    
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Required packages:

    opencv-python
    scikit-image
    numpy

Usage

Basic Usage (CLI)

Compare two images by providing their file paths:

python compare.py path/to/image1.jpg path/to/image2.jpg

Options

--threshold : Set the SSIM threshold for similarity (default: 0.99). --save-diff: Save a difference image as diff.png.

Example with options: python compare.py images/image1.jpg images/image2.jpg --threshold 0.95 --save-diff

Example Output

When images differ:

Similarity Score: 0.8432
Images are different!
Difference image saved as diff.png

When images are similar:

Similarity Score: 0.9981
Images are identical (or very similar).

About

This project is a lightweight Python tool that helps you compare two images and determine whether they are identical or different. It uses Structural Similarity Index (SSIM) to go beyond simple pixel matching, making it robust against small changes like resizing or minor color shifts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages