Flattening a colour image to one channel seems like it should be an average of red, green and blue. It isn't — the eye is far more sensitive to green than to blue, so a plain average makes blues look unnaturally bright and greens unnaturally dull.
The standard luminance weights match human sensitivity instead:
Task: write to_grayscale(rgb) returning a 2D grid of brightness values, each rounded to 4 decimal places.
rgb is a grid of pixels, where each pixel is a three-item list [R, G, B].Notice the weights sum to exactly 1.0. That's what keeps the brightness range intact: pure white [255, 255, 255] comes out as exactly 255, and pure black as 0. Weights summing to anything else would darken or brighten the whole image.
And look at what the individual channels produce. Pure red lands around 76, pure green around 150, pure blue around 29 — a factor of five between the brightest and darkest of the three primaries, all at full intensity. That's the perceptual difference a naive average throws away, and it's why converting a colourful chart to greyscale with the wrong formula can make distinct colours collapse into the same shade.