An Introduction to Detect Edges in Image Using Python OpenCV

In pytho opencv, we can use cv2.Canny() to detect edges from an image. In this tutorial, we will use an example to show you how to detect.

Detect Edges in Image Using cv2.Canny() in Python OpenCV

1.Read an image

import cv2
img = cv2.imread("pyimg.jpg")

2.Use  cv2.Canny() to detect edges in an image

edge_img = cv2.Canny(img,100,200)

cv2.imshow("Detected Edges", edge_img)

cv2.waitKey(0)

Here cv2.Canny() is defined as:

cv2.Canny(image, minVal, maxVal)

Here minVal and maxVal are the minimum and maximum intensity gradient values respectively.

If you want to detect edges from a video, you can read:

Implement Edge Detection Using OpenCV

An Introduction to Detect Edges in Image Using Python OpenCV