OpenCV – Edge Detection

Edge Detection is an image processing technique to find boundaries of objects in the image.

In this tutorial, we shall learn to find edges slot88 of focused objects in an image using Canny Edge Detection Technique.

Syntax – cv2.Canny()

The syntax of OpenCV Canny Edge Detection function is

edges = cv2.Canny('/path/to/img', minVal, maxVal, apertureSize, L2gradient)

where

ParameterDescription
/path/to/img  (Mandatory)File Path of the image
minVal   (Mandatory)Minimum intensity gradient
maxVal   (Mandatory)Maximum intensity gradient
apertureSize (Optional)
L2gradient (Optional) (Default Value : false)If true, Canny() uses a much more computationally expensive equation to detect edges, which provides more accuracy at the cost of resources.
ADVERTISEMENT

Example 1 – OpenCV Edge Detection

In this example, we python.png (an RGB image) as a slot GREY scale image. Then Canny() function is used to detect edges for the image.

edge-detection.py

import cv2

img = cv2.imread('/home/img/python.png')
edges = cv2.Canny(img,100,200)

cv2.imshow("Edge Detected Image", edges)

cv2.waitKey(0) # waits until a key is pressed
cv2.destroyAllWindows() # destroys the window showing image

Input Image

Output Image

OpenCV Edge Detection

Conclusion

In this OpenCV Python TutorialImage Edge Detection, we slot gacor have learnt to find edges of objects in the specified image, using Canny Detection Algorithm.