Created
November 25, 2015 15:50
-
-
Save LeeKamentsky/cff0b04d91ecda904eba to your computer and use it in GitHub Desktop.
Kirsch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rotate(direction, index): | |
return direction[-index:] + direction[:-index] | |
def make_kernel(convolution_mask): | |
k = list(convolution_mask) | |
k.insert(4, 0) | |
return np.array(k).reshape(3, 3) | |
def kirsch(img): | |
convolution_mask = [5, -3, -3, -3, -3, -3, 5, 5] | |
output = np.zeros(img.shape) | |
for _ in range(8): | |
c = convolve(img, make_kernel(convolution_mask)) | |
output = np.maximum(output, c) | |
convolution_mask = rotate(convolution_mask, 1) | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment