import cv2 import numpy as np from matplotlib import pyplot as plt # Declaring the output graph's size plt.figure(figsize=(16, 16)) # Convert image to grayscale img_gs = cv2.imread('cat.jpg', cv2.IMREAD_GRAYSCALE) cv2.imwrite('gs.jpg', img_gs) # Apply canny edge detector algorithm on the image to find edges edges = cv2.Canny(img_gs, 100,200) # Plot the original image against the edges plt.subplot(121), plt.imshow(img_gs) plt.title('Original Gray Scale Image') plt.subplot(122), plt.imshow(edges) plt.title('Edge Image') # Display the two images plt.show()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter