Now we will find the road markings in an RGB image:Â
- First, import the matplotlib (mpimg and pyplot), numpy, and openCV libraries:
In[1]: import matplotlib.image as mpimg
In[2]: import matplotlib.pyplot as plt
In[3]: import numpy as np
In[4]: import cv2
- Read the image as follows:
In[5]: image_color = mpimg.imread('image.jpg')
We have read the image, and this is what it looks like:
Fig 4.15: Sample image
- Now we will check the shape of the image, which is (280, 660, 3):
In[6]: image_color.shape
Out[6]: (280, 660, 3)
- Next, we will detect the white lines. We can play with the values in line 8 in the following code to get sharper images. We can set the values of channel-1 to less than 209, *channel 2 to less than 200, and *channel 3 to less than 200. Different images require different values to get sharper images. We will look at the following code:
In[7]: image_copy = np.copy(image_color)
# Any value that is not white
In[8...