We learned in Chapter 4, Computer Vision for Self-Driving Cars, that a three-channel color image has red, green, and blue channels (each pixel being a combination of these three channel values). A grayscale image has only one channel for each pixel (with 0 being black and 255 being white). Naturally, processing a single-channel image is faster than processing a three-channel color image, and it is less computationally expensive, too.
Also, in this chapter, we will develop an edge-detection algorithm. The edge-detection algorithm's main goal is to identify the boundaries of the objects within an image. Later in this chapter, we will be detecting edges to find a region in an image with a sharp change in the pixels.Â
Now, as a first step, we will convert the image into grayscale:
- Import the following libraries, which we need to convert the image into grayscale:
In[1]: import cv2
In[2]: import numpy as np
- Read in and...