Metadata-Version: 2.4
Name: pytorch-filters
Version: 0.1.1
Summary: Image edge detection filters built with PyTorch
License: MIT
Project-URL: Homepage, https://github.com/mason/pytorch-filters
Project-URL: Repository, https://github.com/mason/pytorch-filters
Keywords: pytorch,image processing,edge detection,computer vision
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch
Requires-Dist: numpy
Dynamic: license-file

# Pytorch-Filters

A collection of image edge detection filters built with PyTorch — fully vectorized, GPU-compatible, and easy to drop into any pytorch pipeline.

## Filters

- **Canny** — classic multi-stage edge detector with Gaussian blur, Sobel gradients, non-maximum suppression, and hysteresis
- **DoG** (Difference of Gaussians) — fast approximation of the Laplacian of Gaussian for edge detection
- **XDoG** (Extended Difference of Gaussians) — stylized edge detection with soft thresholding, great for non-photorealistic rendering

## Installation

```bash
pip install pytorch-filters
```

## Quick Start

```python
import torch
import torchvision.transforms.functional as TF
from PIL import Image
from pytorch_filters import canny, difference_of_gaussians, ex_difference_of_gaussians

# Load image as tensor [1, 1, H, W]
img = TF.to_tensor(Image.open("photo.jpg").convert("L")).unsqueeze(0)

edges = canny(img)
dog   = difference_of_gaussians(img, sigma=1.4, k=1.6)
xdog  = ex_difference_of_gaussians(img, sigma=1.0, tau=0.99, phi=100)
```

## Demo

```bash
pip install -r requirements.txt
python demo.py images/demo1.jpg
```

This will display the original image alongside Canny, DoG, and XDoG results side by side.

![demo output](images/output1.png)

## Requirements

- Python 3.10+
- PyTorch 2.0+
- torchvision
- NumPy
