Created
November 7, 2020 16:52
-
-
Save erinkhoo/70abf7abcebeb57d1f5f5f076fa5fc13 to your computer and use it in GitHub Desktop.
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 laplacian(sigma,image): | |
""" | |
sigma: Parameter controlling Gaussian blur | |
image: input greyscale image n x m | |
conv_laplacian: output image n x m to be returned, | |
result of convolution of image with laplacian of Gaussian | |
""" | |
# 1 dimension gaussian kernels (Integration scale) | |
K1,K2 = gauss_kernels(sigma) | |
# The below code is adopted from the Lession 1 slide 11 | |
K1_derv_x = np.expand_dims(K1,axis=0) | |
K1_derv_y = np.transpose(K1_derv_x) | |
K2_derv_x = np.expand_dims(K2,axis=0) | |
K2_derv_y = np.transpose(K2_derv_x) | |
Gx = signal.convolve2d(image, K1_derv_x, mode='same') | |
GxLx = signal.convolve2d(Gx, K2_derv_x, mode='same') | |
Gy = signal.convolve2d(image, K1_derv_y, mode='same') | |
GyLy = signal.convolve2d(Gy, K2_derv_y, mode='same') | |
summed = GxLx+GyLy | |
conv_laplacian = (summed - np.min(summed)) / (np.max(summed) - np.min(summed)) | |
return conv_laplacian |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment