python opencv canny

发布时间 2023-03-28 16:13:47作者: 西北逍遥

python opencv canny

 

import cv2

# Load the image
img = cv2.imread('path/to/image.jpg')

# Convert the image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Apply the Canny algorithm to detect edges
edges = cv2.Canny(gray, 100, 200)

# Display the edges
cv2.imshow('Edges', edges)
cv2.waitKey(0)
cv2.destroyAllWindows()

 

 

#################