Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
5.42.0
metadata
title: Diff Highlighter
emoji: 🏢
colorFrom: indigo
colorTo: red
sdk: gradio
sdk_version: 5.22.0
app_file: app.py
pinned: false
Object Difference Highlighter
Overview
The Object Difference Highlighter is a computer vision application that identifies and isolates new objects in a scene. Given two images of the same scene—one without an object and another with an added object (taken seconds apart)—the app intelligently detects what has changed while filtering out environmental noise like moving foliage, slight shadows, or minor lighting changes.
Key Features
- Intelligent Object Detection: Identifies real, meaningful changes between two similar images
- Noise Filtering: Eliminates false positives from environmental variations (wind-moved objects, minor lighting changes)
- Multiple Detection Algorithms:
- SSIM (Structural Similarity Index Measure): Detects structural differences
- Background Subtraction: Filters out background to focus on foreground changes
- Optical Flow: Detects motion-based changes between frames
- Comprehensive Visualization: Six different views to analyze and understand the changes
Visual Outputs
The application provides six different views arranged in three rows:
Row 1: Base Comparison
- Blended Image: A 50/50 blend of both input images
- Raw Difference Overlay: Unprocessed pixel differences shown in magenta on the original image
Row 2: Algorithm Results
- Highlighted Differences: Areas identified as changed by the selected algorithm
- Black & White Mask: Binary mask showing exactly what areas the algorithm detected as changed
Row 3: Final Composition
- Composite Image: Scene from the first image with only the detected object from the second image
- Final Difference Overlay: Differences between the original scene and the composite image shown in magenta
Use Cases
- Photography: Remove unwanted elements from otherwise perfect shots
- Surveillance: Detect new objects in monitored areas
- Research: Analyze scene changes in controlled environments
- Wildlife Monitoring: Detect animals in natural settings
- Retail/Inventory: Track object placement and removal
Installation & Setup
1. Clone the Repository
git clone https://github.com/your-username/object-difference-highlighter.git
cd object-difference-highlighter
2. Install Dependencies
Ensure you have Python installed, then run:
pip install -r requirements.txt
3. Run the Application
python app.py
The application will launch in your default web browser via Gradio.
Usage Guide
Step 1: Upload Images
- Upload two images:
- Image Without Object (Scene): The base scene without the object of interest
- Image With Object: The same scene with the added object
Step 2: Configure Parameters
- Comparison Method: Select the algorithm best suited for your images
- SSIM works well for most cases
- Background Subtraction is good for static cameras
- Optical Flow works well for slight camera movements
- Gaussian Blur: Adjust to reduce noise (higher values for noisier images)
- Thresholding Technique: When using SSIM, determines how differences are identified
Step 3: Process & Review Results
- Click Process to generate all six visualizations
- Compare the different views to understand how well the algorithm detected the new object
- Use the mask and highlighted differences to evaluate detection quality
- The composite image shows the final result with only the detected object added to the scene
Dependencies
- Python 3.7+
- OpenCV
- NumPy
- Scikit-Image
- Gradio