Skip to main content
Be Bitwise

Images & Sound

Data Representation · Data & Hashing track

3 min read

In this module

Everything Is Numbers

You've seen how computers encode text and numeric values. Same principle extends to every kind of media — images, audio, video. At the bottom, it's always patterns of bits read through some agreed-upon format.

Pixels and Color

A digital image is a grid of tiny dots called pixels. Each pixel stores a colour value, most commonly under the RGB model: one number each for red, green, and blue intensity. With 8 bits per channel, every channel ranges from 0 (none of that colour) to 255 (cranked all the way up).

ColorRGB
Black000
White255255255
Red25500
Yellow2552550

A 24-bit pixel uses 3 bytes. A modest 1920x1080 image packs over 2 million pixels, eating roughly 6 megabytes of raw data — which is why we have PNG and JPEG.

Bitmap

A bitmap is an image stored as a literal grid of pixel values, without compression. The file size is directly proportional to the number of pixels and the bits per pixel. Compressed formats reduce size by exploiting patterns and removing information the human eye is unlikely to notice.

Sampling Sound

Sound in the physical world is a continuous wave of air pressure. To digitise it, a computer takes samples — snapshots of the wave's amplitude at regular intervals. The sample rate counts how many snapshots happen per second (CD audio: 44,100). The bit depth says how many bits describe each one (CD audio uses 16 bits, giving 65,536 possible amplitude levels).

Higher sample rates capture higher frequencies: by the Nyquist-Shannon sampling theorem, a sample rate can only represent frequencies below half of itself, so CD audio's 44,100 Hz tops out just under 22,050 Hz, a little above the limit of human hearing. Greater bit depth captures quieter details. The same precision-versus-resource trade-off you saw with integer widths and floating-point formats, just dressed up in audio clothing.

The Unifying Idea

Text, integers, floating-point numbers, colours, sound waves — none of these "exist" inside the computer in any human-recognisable form. They're all binary numbers, given meaning by whatever software reads them. A byte with value 65 might be the letter A, a red intensity value, or part of an audio sample — context decides. Internalise that and you've grasped something genuinely strange about computation: data has no inherent meaning without an interpretation layer.

You can watch the interpretation layer at work in the first 44 bytes of a WAV file holding one second of CD-quality stereo. The bytes 44 ac 00 00 are just four numbers until the format says they're a little-endian sample rate. Click the fields:

First 44 bytes of a WAV file

0000RIFF4...WAVEfmt
0010........D.......
0020....data....

Click a coloured byte or a field name to decode it