import cv2
Load an image from file
img = cv2.imread("example.jpg")
Convert the image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
Apply a Gaussian blur to the image to reduce noise
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
Use the Canny edge detection algorithm to find edges in the image
edges = cv2.Canny(blurred, 100, 200)
Display the original and processed images
cv2.imshow("Original", img) cv2.imshow("Edges", edges) cv2.waitKey(0) cv2.destroyAllWindows()
Log in or sign up for Devpost to join the conversation.