Loading...
Implement a function to convert an RGB pixel to grayscale using the luminosity method, which is a widely used technique in Computer Vision. This method involves calculating a weighted average of the RGB values to produce a grayscale value that approximates human perception.
The human eye perceives colors differently, with varying sensitivities to red, green, and blue light, which is why we use weighted averaging to convert RGB to grayscale. The weights used in this method reflect the sensitivity of the human eye to different colors, with green contributing most to perceived luminance.
To perform this conversion, follow these steps:
This technique is widely used in image processing applications.
rgb_to_gray([255, 0, 0])
54
0.2126×255 + 0.7152×0 + 0.0722×0 ≈ 54