File size: 3,740 Bytes
0e27905
 
 
 
 
 
 
 
 
 
 
9e2fa2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
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**
```bash
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:
```bash
pip install -r requirements.txt
```

### **3. Run the Application**
```bash
python app.py
```
The application will launch in your default web browser via **Gradio**.

## Usage Guide
### **Step 1: Upload Images**
- Upload two images:
  1. **Image Without Object (Scene)**: The base scene without the object of interest
  2. **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