Here are the steps needed to complete this recipe:
- Import the modules:
import cv2import matplotlib.pyplot as plt
- Load the test image:
image = cv2.imread('../data/Lena.png')
- Detect the edges using the Canny algorithm:
edges = cv2.Canny(image, 200, 100)
- Visualize the results:
plt.figure(figsize=(8,5))plt.subplot(121)plt.axis('off')plt.title('original')plt.imshow(image[:,:,[2,1,0]])plt.subplot(122)plt.axis('off')plt.title('edges')plt.imshow(edges, cmap='gray')plt.tight_layout()plt.show()