Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/sunsided/python-conv2d

2D image convolution example in Python
https://github.com/sunsided/python-conv2d

2d-convolution image-processing python

Last synced: 3 months ago
JSON representation

2D image convolution example in Python

Awesome Lists containing this project

README

        

# 2D Convolutions in Python (OpenCV 2, numpy)

In order to demonstrate 2D kernel-based filtering without relying on library code too much, `convolutions.py` gives some examples to play around with.

```python
image = cv2.imread('clock.jpg', cv2.IMREAD_GRAYSCALE).astype(float) / 255.0

kernel = np.array([[1, 0, -1],
[1, 0, -1],
[1, 0, -1]])

filtered = cv2.filter2D(src=image, kernel=kernel, ddepth=-1)
cv2.imshow('horizontal edges', filtered)
```

In addition, `convolution_manual.py` implements a manual 2D convolution to explain the concept.