Representing Images and Sound
Numbers All the Way Down
Text becomes numbers through a simple agreement — one code per character. But a photograph? A song? These feel continuous, flowing, analogue. The trick for both is the same, and it is one of the great ideas in computing: chop the smooth thing into tiny pieces, and measure each piece as a number.
Images: A Grid of Coloured Squares
Zoom deep into any digital photo and the truth appears: it is a grid of tiny squares, each square exactly one colour. Each square is a pixel (from picture element).
Storing an image means storing two things:
- The grid size — the resolution, written width × height. A 1920 × 1080 image has about 2 million pixels; a modern phone camera captures 12 million or more.
- Each pixel's colour — as numbers, of course.
How can a colour be numbers? Screens make colour by mixing three lights: red, green, and blue (RGB). Each is set between 0 (off) and 255 (full):
| R | G | B | Colour |
|---|---|---|---|
| 255 | 0 | 0 | red |
| 255 | 255 | 0 | yellow (red + green light) |
| 0 | 0 | 0 | black |
| 255 | 255 | 255 | white |
Why 0–255? Because each value is stored in one byte — 8 bits, giving 2⁸ = 256 levels, straight out of binary numbers. Three bytes per pixel gives 256³ ≈ 16.7 million possible colours — more than your eye can distinguish. The number of bits used per pixel is called the colour depth.
Now the arithmetic that explains your full phone storage: 12 million pixels × 3 bytes = about 36 MB per photo, uncompressed. (Compression — below — is why actual files are smaller.)
More pixels = more detail = bigger file. Fewer pixels = blockiness when you zoom, the famous pixelation. Every camera setting screen is offering you this same trade-off.
Sound: Measuring a Wave, Very Fast
Sound is a wave — a smooth wiggle of air pressure. To digitise a wiggle, sample it:
- Measure the height of the wave
- Wait a tiny fraction of a second
- Measure again — and again, thousands of times per second
- Store the long list of measurements as numbers
wave: ~~/\~~\_/~~/\~~
samples: ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ → 52, 78, 91, 74, 40, 22, 35, 61…
Two settings decide the quality:
- Sample rate — measurements per second. CD quality uses 44,100 per second, fast enough to capture every pitch human ears can hear. Too few samples and the recreated wave misses the wiggles — the audio sounds dull and distorted.
- Bit depth — how precisely each measurement is stored (16 bits gives 65,536 possible levels).
Play the numbers back through a speaker at the same rate, and the wave — and the music — returns. One minute of CD-quality stereo is about 10 MB of raw numbers.
The Eternal Trade-Off, and the Compression Trick
Both stories end at the same tension — quality costs storage:
| Better quality | Price |
|---|---|
| More pixels (resolution) | bigger image file |
| More colours (colour depth) | bigger image file |
| More samples per second | bigger sound file |
Compression fights back. Clever algorithms shrink files by exploiting patterns — a run of 500 identical blue sky pixels needn't be stored 500 times ("500 × blue" will do). That kind is lossless: nothing is lost. Formats like JPEG and MP3 go further: they are lossy, permanently discarding detail human eyes and ears barely notice. That is how a 36 MB photo becomes a 3 MB JPEG that looks identical — and it is why heavily compressed images grow fuzzy artefacts. Every image and song that crosses the internet has been through this machinery.
One Idea to Rule Them All
Text: one number per character. Images: three numbers per pixel. Sound: thousands of numbers per second. Video: just images plus sound, numbers by the billion. The whole digital world rests on a single move — find a way to turn it into numbers — and on abstraction to stack the layers so you never have to see them.
Worked Example — Calculating a Video's Raw Size
Video is images plus sound, sampled many times per second — and working out its raw size shows exactly why video compression matters more than any other kind. A single frame at a modest 1280×720 resolution has 921,600 pixels; at 3 bytes per pixel (RGB), that's about 2.7 MB per frame. Standard video plays 30 frames per second, so one second of raw, uncompressed video is:
2.7 MB per frame × 30 frames per second = 81 MB per second
A single uncompressed minute would be roughly 4.9 GB — before even adding the sound. Streaming that over an ordinary home internet connection would be essentially impossible; even a very fast connection would struggle to keep up in real time. Yet video streams smoothly every day, which means real video is compressed by a factor of 50 to 100 or more compared with these raw numbers — mostly by exploiting the fact that consecutive frames barely differ from each other, storing only the changes between frames rather than each frame's pixels from scratch. This single calculation explains something that might otherwise seem mysterious: why video compression specifically, more than any other kind of data compression, was one of the technologies that had to mature before streaming video became a normal part of everyday life.
Key Words
- Pixel — one square of an image grid, holding a single colour
- Resolution — an image's pixel dimensions (width × height)
- RGB / colour depth — colour as red-green-blue values; the bits used per pixel
- Sampling / sample rate — measuring a sound wave at rapid intervals; how many measurements per second
- Compression (lossless / lossy) — shrinking files by exploiting patterns, or by discarding barely-noticed detail