Edge Detection
Get introduced to different types of edge detection and learn how to detect edges using these techniques.
We'll cover the following...
One of the most frequent uses of OpenCV is the detection of shapes, edges, faces, and various other components in images. In this chapter, we’ll learn about some of those detections.
Detecting edges helps us solve many practical problems. It helps us detect shapes, documents, and various other components of the image. Here, we’ll discuss three different methods of detecting edges—Canny edge detection, Laplacian edge detection, and Sobel edge detection.
First, we need to convert our image to grayscale:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
Canny edge detection
For Canny edge detection, we use the cv2.Canny()
function of the OpenCV library. This function requires three parameters, which are listed below:
-
The first parameter is the input image.
-
The second parameter is the minimum value of the ...