Colour and Channels
Colour is not one number per pixel, it is three, stacked on top of each other and constantly disagreeing. Split a photo into its red, green, and blue channels and find out which one was quietly doing almost all of the work.
Worth reading first: Images as Numbers
You think of a coloured pixel as one thing — a dot of sky-blue, a dot of leaf-green. It is not one thing. It is three separate numbers, recorded independently, that happen to sit on top of each other and get displayed as a single dot. Pull them apart and one of the three turns out to be doing almost all of the work.
One pixel, three numbers
The previous lesson said a grayscale pixel is one integer from 0 to 255. A colour pixel is the same idea, tripled: one integer for how much red light it holds, one for green, one for blue, each independently between 0 and 255.
A clear midday sky is roughly R = 135, G = 206, B = 235— heavy on blue, as you would expect, but also more green than red, which is why a sky rendered with only its blue channel looks nothing like a sky. Zero out any one of those three numbers and the colour changes completely; there is no single “important” channel until you ask a specific question about a specific image.
Why grayscale is a choice, not a loss
It is tempting to think of converting a colour photo to grayscale as throwing information away, the way deleting two-thirds of a file would. It is closer to a deliberate calculation than a deletion: a common formula is 0.299R + 0.587G + 0.114B, not a plain average of the three.
Green gets nearly five times the weight of blue because human vision is far more sensitive to green light — your eye has more receptors tuned to that part of the spectrum than to red or blue. A grayscale conversion that used equal weights would produce a technically valid image that looked wrong to every person who looked at it, because it would not match how brightness actually registers for a human observer.
Channels that are not colour at all
Nothing about the word “channel” requires it to carry colour. A channel is just another grid of numbers, the same shape as the image, stacked alongside red, green and blue.
Alpha
A fourth channel recording transparency — 0 for fully see-through, 255 for fully opaque. It changes nothing about colour and everything about what shows through.
Depth
Sensors like LiDAR or a structured-light camera record distance from the lens per pixel, not brightness. A depth channel can sit right alongside an RGB image of the same scene.
Infrared
Satellite and night-vision imagery often carry a channel for light outside what your eyes can see at all, used precisely because it reveals things visible colour does not.
The order of channels is not universal
Even once you have settled on red, green and blue, the order they are stored in is a convention, not a law — and it is not the same convention everywhere.
OpenCV loads images as BGR, not RGB, by default. Read a photo with cv2.imread and the first channel in the array is blue, not red. Hand that array to a library that assumes RGB — Matplotlib, most plotting and machine-learning code — without converting it, and nothing crashes. Nothing throws an error at all. The image simply displays with red and blue silently swapped: skin turns a washed-out blue, a blue sky turns orange.
Key takeaways
- A colour pixel is not one value, it is three independent numbers for red, green and blue stacked on the same spot.
- Converting to grayscale is a weighted calculation, not a loss of information for free — green typically gets close to five times the weight of blue because human vision is far more sensitive to it.
- A channel does not have to carry colour: alpha carries transparency, depth carries distance, infrared carries light outside human vision.
- Channel order is a convention rather than a universal rule, and OpenCV's default of BGR instead of RGB is the concrete example that trips people up.
- Mixing up channel order does not error — it silently swaps red and blue in the displayed image, which is what makes the bug easy to miss.
Quick check
Answer these to unlock the next chapter — 3 of 4 to pass. You can retake it anytime.
Answer every question to check.
Make a free account to read on
Every chapter is free — an account is how your progress, XP, and streak follow you from your laptop to your phone, and how you show up on the leaderboard. No payment, no trial.