We covered canny edge detection in Chapter 4, Computer Vision for Self-Driving Cars. In this section, we will apply canny edge detection to identify the edges in the image. As we learned in Chapter 4, Computer Vision for Self-Driving Cars, an edge is a region in an image where there is a sharp change in intensity or a sharp change in color between adjacent pixels in an image. This change over a series of pixels is known as the gradient. As we already know, the canny function computes the gradient in all directions of a blurred image and will trace the strongest gradient as a series of pixels.
Now, we will implement canny edge detection using the OpenCV library:
- Import the libraries we need:
In[1]: import cv2
In[2]: import numpy as np
- Now, apply canny edge detection using OpenCV—specifically, using cv2.Canny:
In[3]: image = cv2.imread('test_image.jpg')
In[4]: lanelines_image = np.copy(image)
In[5]: gray_conversion= cv2.cvtColor(lanelines_image...