What is a Pixel?
A pixel (short for picture element) is the smallest individual dot in a digital image. Zoom in far enough on any photo on your screen and you will see a grid of tiny coloured squares — those are pixels.
Every image has a resolution, which describes how many pixels it contains. A "1920 × 1080" HD display has 1,920 pixels across and 1,080 pixels down, giving a total of 2,073,600 pixels — over two million!
How Colour is Stored
Each pixel stores a colour. The most common system is RGB (Red, Green, Blue): each pixel has three values, one for each colour channel.
Each channel is stored as a number from 0 (none of that colour) to 255 (maximum). Since 256 = 2⁸, each channel needs 1 byte (8 bits), so a full-colour pixel needs 3 bytes (24 bits).
| Colour | Red | Green | Blue |
|---|---|---|---|
| White | 255 | 255 | 255 |
| Black | 0 | 0 | 0 |
| Red | 255 | 0 | 0 |
| Yellow | 255 | 255 | 0 |
| Custom | 100 | 149 | 237 |
24-bit colour (3 bytes per pixel) can represent 256 × 256 × 256 = 16,777,216 different colours. This is more than the human eye can distinguish, which is why most photos look realistic on screen.
Calculating Image File Size
You can estimate the uncompressed size of an image using this formula:
File size = Width × Height × Colour depth (in bytes)
Example: A 200 × 100 pixel image at 24-bit colour:
- 200 × 100 = 20,000 pixels
- 20,000 × 3 bytes = 60,000 bytes ≈ 60 KB
A 12-megapixel photo would be around 36 MB uncompressed — this is why image compression (JPEG, PNG) is so important!
Colour Depth
Colour depth is the number of bits used to store each pixel's colour. Common values:
| Colour Depth | Bits per Pixel | Colours Available |
|---|---|---|
| 1-bit | 1 | 2 (black & white) |
| 8-bit | 8 | 256 |
| 24-bit | 24 | 16.7 million |
| 32-bit | 32 | 16.7 million + transparency |
The extra 8 bits in 32-bit colour is called the alpha channel — it controls transparency. This is used in PNG images, where some pixels can be semi-transparent or fully see-through.
Metadata
Image files also store metadata — extra information about the file such as the camera model, date taken, GPS location, and image dimensions. This adds a small amount of extra data on top of the pixel values.
Practice Problems
Calculate the uncompressed file size in kilobytes of a 640 × 480 pixel image stored at 24-bit colour depth.
Show answer
An image uses 8-bit colour depth. How many different colours can it display, and how does this compare to 24-bit colour?