An open API service indexing awesome lists of open source software.

https://github.com/charanpool/image-patch-mapping

A Python toolkit for image processing — edge detection, template matching, and patch detection using OpenCV
https://github.com/charanpool/image-patch-mapping

canny-edge-detector computer-vision edge-detection image-processing numpy opencv python sobel-filter template-matching

Last synced: 16 days ago
JSON representation

A Python toolkit for image processing — edge detection, template matching, and patch detection using OpenCV

Awesome Lists containing this project

README

          

# 🖼️ Image Patch Mapping

A Python toolkit for image processing, edge detection, and template matching. Perfect for learning computer vision or building upon for your own projects!

![Python](https://img.shields.io/badge/Python-3.7+-blue.svg)
![OpenCV](https://img.shields.io/badge/OpenCV-4.x-green.svg)
![License](https://img.shields.io/badge/License-MIT-yellow.svg)
![Contributions Welcome](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)

---

## ✨ Features

| Feature | Description |
|---------|-------------|
| 🔍 **Edge Detection** | Canny (from scratch), Sobel, and Laplacian |
| 🎯 **Template Matching** | Find objects using 6 different methods |
| 🧩 **Patch Detection** | Detect uniform regions in images |
| 🔄 **Transforms** | Rotation, flipping, and resizing |

---

## 📁 Project Structure

```
image-patch-mapping/
├── src/
│ └── image_patch_mapping/ # Main package
│ ├── __init__.py
│ ├── edge_detection.py # Canny, Sobel, Laplacian
│ ├── template_matching.py # Template matching algorithms
│ ├── patch_detection.py # Uniform patch detection
│ └── transforms.py # Image transformations
├── examples/ # Example scripts
│ ├── edge_detection_demo.py
│ ├── template_matching_demo.py
│ └── patch_detection_demo.py
├── images/
│ └── samples/ # Sample images for testing
├── .github/ # Issue & PR templates
├── requirements.txt
├── setup.py
└── README.md
```

---

## 🚀 Quick Start

### Installation

```bash
# Clone the repository
git clone https://github.com/YOUR_USERNAME/image-patch-mapping.git
cd image-patch-mapping

# Install dependencies
pip install -r requirements.txt

# Or install as a package
pip install -e .
```

### Basic Usage

#### Edge Detection

```python
from image_patch_mapping import CannyEdgeDetector, sobel_filter

# Canny edge detection (implemented from scratch!)
detector = CannyEdgeDetector(sigma=1.0, low_threshold=0.05, high_threshold=0.15)
edges = detector.detect("image.jpg")

# Sobel filter
sobel_x, sobel_y, magnitude = sobel_filter("image.jpg", ksize=5)
```

#### Template Matching

```python
from image_patch_mapping import TemplateMatching

matcher = TemplateMatching("source.jpg", "template.jpg")
location, confidence = matcher.find_best_match()
print(f"Found at {location} with {confidence:.2%} confidence")
```

#### Patch Detection

```python
from image_patch_mapping import PatchDetector

detector = PatchDetector(patch_size=50, tolerance=5)
patches = detector.find_uniform_patches("image.jpg")
print(f"Found {len(patches)} uniform patches")
```

#### Image Transforms

```python
from image_patch_mapping import rotate_image

rotated = rotate_image("image.jpg", angle=45)
```

---

## 🎯 Examples

Run the demo scripts to see the toolkit in action:

```bash
# Edge detection demo
python examples/edge_detection_demo.py

# Template matching demo
python examples/template_matching_demo.py

# Patch detection demo
python examples/patch_detection_demo.py
```

---

## 🤝 Contributing

We welcome contributions! Whether it's:

- 🐛 Bug fixes
- ✨ New features
- 📝 Documentation improvements
- 💡 Ideas and suggestions

Check out our [Contributing Guidelines](CONTRIBUTING.md) to get started.

**New to open source?** Look for issues labeled `good first issue`!

---

## 📜 License

This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.

---

## 💬 Get in Touch

- 🐛 Found a bug? [Open an issue](../../issues/new?template=bug_report.md)
- 💡 Have an idea? [Request a feature](../../issues/new?template=feature_request.md)
- ❓ Questions? [Start a discussion](../../discussions)

---


Made with ❤️ by contributors like you!