February 2020
Intermediate to advanced
372 pages
9h 26m
English
Throughout this book, we have performed grayscale conversions using code such as the following:
gray_img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2GRAY)
Perhaps a question is long overdue: how exactly does this function map BGR values to grayscale values? The answer is that each output pixel's grayscale value is a weighted average of the corresponding input pixel's B, G, and R values, as follows:
gray = (0.114 * blue) + (0.587 * green) + (0.299 * red)
These weights are widely used. They come from a telecommunications industry standard called CCIR 601, which was issued in 1982. They are loosely consistent with a characteristic of human vision; when we see a brightly lit scene, our eyes are most sensitive to yellowish-green ...