Skip to content

sunsided/python-conv2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

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.

About

2D image convolution example in Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages