Grayscale and RGB Images
A pixel holds either one number or three. That is the whole difference between a grayscale image and a colour one — and “how do computers store RGB images?” is a two-mark board question.
1Grayscale images
A grayscale image has each pixel of size 1 byte, holding a single plane of a 2D array of pixels. Its size is defined as the height × width of the image.
2RGB images
All the coloured images around us are made up of three primary colours: Red, Green and Blue. Every colour that exists can be made by combining different intensities of those three.
Press R, G, B below and the three planes slide apart. That stack is the answer to the exam question, drawn.
Every photograph in digital form is made of pixels. Drag sideways to turn the grid and look along it.
Each channel on its own looks like a grayscale image, because a single channel is one number per pixel — which is exactly what grayscale is.
Three sheets of coloured acetate
3What the combinations give
| R, G, B | Colour | Why |
|---|---|---|
| 255, 255, 255 | White | All three at full — the total presence of colour |
| 0, 0, 0 | Black | All three at zero — the total absence of colour |
| 255, 0, 0 | Red | Only the red channel is on |
| Equal values, e.g. 128, 128, 128 | A shade of grey | Vary all three together and you move along the grey scale |
4Side by side
| Grayscale | RGB | |
|---|---|---|
| Values per pixel | One | Three |
| Planes / channels | A single plane | Three: R, G and B |
| Size of one pixel | 1 byte | 3 bytes — one per channel |
| Range of each value | 0 to 255 | 0 to 255, for each channel |
5From the board papers
▶Show the answer
Every RGB image is stored in the form of three different channels — the R channel, the G channel and the B channel. Each channel is a separate plane of pixels, and each pixel value in it varies from 0 to 255.
All three planes combined form the colour image, which means each pixel has a set of three different values that together give that pixel its colour.
▶Show the answer
255, 255, 255 gives white — the total presence of colour.
0, 0, 0 gives black — the total absence of colour.
Keeping all three equal at any value in between gives a shade of grey.
6Check yourself
How many values does each pixel of an RGB image hold?
In a grayscale image, a pixel value of 0 means:
What are the three channels of an RGB image?
How much memory does one pixel of a grayscale image take?