Skip to content

Instantly share code, notes, and snippets.

@grasses
Created November 19, 2019 11:45
Show Gist options
  • Save grasses/2d039588ba382d75423f5b667b247462 to your computer and use it in GitHub Desktop.
Save grasses/2d039588ba382d75423f5b667b247462 to your computer and use it in GitHub Desktop.
High-Pass Filter
import numpy as np, scipy
def high_pass_filter(image):
kernel_5x5 = (1.0/12) * np.array([
[-1, 2, -2, 2, -1],
[2, -6, 8, -6, 2],
[-2, 8, -12, 8, -2],
[2, -6, 8, -6, 2],
[-1, 2, -2, 2, -1]
], dtype=np.float32)
return scipy.ndimage.convolve(image, kernel_5x5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment