Created
July 9, 2017 18:52
-
-
Save NikaTsanka/496425bc19eb9db2f8ffc665754fea1d to your computer and use it in GitHub Desktop.
Laplacian Operator
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
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