python opencv canny

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()

 

 

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

posted @ 2023-03-28 16:09  西北逍遥  阅读(13)  评论(0编辑  收藏  举报