Created
November 13, 2021 13:35
-
-
Save samyumobi/5b83ca3b667960869da23c1650e93e68 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from google.colab.patches import cv2_imshow | |
| ## load new image and convert to gray scale | |
| f2 = sys.argv[1] | |
| img2 = cv2.imread('/iPhone_camera_1615895489376.webp',cv2.IMREAD_GRAYSCALE) | |
| ## ht, width of image | |
| h, w = img2.shape | |
| ## horizontal edge detection | |
| sobel_h = cv2.Sobel(img2, cv2.CV_64F, 1, 0, ksize = 5) | |
| ## Vertical edge detection | |
| sobel_v = cv2.Sobel(img2, cv2.CV_64F, 0, 1, ksize = 5) | |
| ## Detect all edges in all directions using Laplacian edge detector | |
| lap = cv2.Laplacian(img2, cv2.CV_64F) | |
| ## Clean edges with least noise using canny edge detector | |
| can = cv2.Canny(img2,50,250) | |
| ## Display all the images | |
| # 'Original' | |
| cv2_imshow(img2) | |
| # 'Sobel horizontal' | |
| cv2_imshow(sobel_h) | |
| # 'Sobel vertical' | |
| cv2_imshow(sobel_v) | |
| # 'Laplacian' | |
| cv2_imshow(lap) | |
| # 'Canny', | |
| cv2_imshow(can) | |
| cv2.waitKey() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment