Skip to content

Instantly share code, notes, and snippets.

@NikaTsanka
Created July 9, 2017 18:52
Show Gist options
  • Save NikaTsanka/496425bc19eb9db2f8ffc665754fea1d to your computer and use it in GitHub Desktop.
Save NikaTsanka/496425bc19eb9db2f8ffc665754fea1d to your computer and use it in GitHub Desktop.
Laplacian Operator
import cv2
import matplotlib.pyplot as plt
# Open the image
img = cv2.imread('shapes.jpg')
# Apply gray scale
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Apply gaussian blur
blur_img = cv2.GaussianBlur(gray_img, (3, 3), 0)
# Positive Laplacian Operator
laplacian = cv2.Laplacian(blur_img, cv2.CV_64F)
plt.figure()
plt.title('Shapes')
plt.imsave('shapes-lap.png', laplacian, cmap='gray', format='png')
plt.imshow(laplacian, cmap='gray')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment