Representing Images and Sound
How Computers Store Images
Every digital image is built from a grid of tiny coloured squares called pixels. Each pixel stores a single colour value represented in binary. The more pixels an image contains, the more detail it can show — but the larger the file it produces.
The total number of pixels in an image is given by its image size. A 640 × 480 image contains 307,200 pixels. A 1920 × 1080 (Full HD) image contains 2,073,600 pixels. Zooming in on a low-resolution image reveals visible pixel squares — this is because there are fewer pixels packed into the same display area.
Image file size (bits) = W × H × D, where W is width in pixels, H is height in pixels, and D is colour depth in bits. To convert to bytes, divide by 8.
Colour Depth
Colour depth determines how many different colours are available for each pixel. With 1-bit colour depth, only 2 colours are possible (black and white). With 8-bit depth, 256 colours are possible. With 24-bit depth — often called “true colour” — over 16 million distinct colours can be represented, which appears photorealistic to the human eye.
Increasing the colour depth improves visual quality but increases file size. A 100 × 100 image at 8-bit colour depth requires 80,000 bits (10,000 bytes). The same image at 24-bit colour depth requires 240,000 bits (30,000 bytes) — three times as large.
Problem: A bitmap image is 800 pixels wide and 600 pixels tall. It uses a colour depth of 24 bits per pixel. Calculate the file size in megabytes.
Step 1 — Apply the formula: Size (bits) = W × H × D = 800 × 600 × 24 = 11,520,000 bits.
Step 2 — Convert to bytes: 11,520,000 ÷ 8 = 1,440,000 bytes.
Step 3 — Convert to megabytes (using SI prefix: 1 MB = 1,000,000 bytes): 1,440,000 ÷ 1,000,000 = 1.44 MB.
Common mistake: Forgetting to divide by 8. The formula gives bits — always convert to bytes for the final answer unless the question specifies bits.
Converting Between Bitmaps and Binary
A simple 1-bit bitmap uses just 0s and 1s — 0 for white and 1 for black (or vice versa). Given a grid of binary values you can reconstruct the image pixel by pixel. For example, a 4 × 4 grid with binary row 1100 produces two black pixels followed by two white pixels on that row. In exam questions you may be asked to draw a small pixel image from a binary pattern, or to write out the binary for a given black-and-white image.
The number of colours available at a given colour depth = 2depth. So 4-bit = 24 = 16 colours; 8-bit = 28 = 256 colours; 24-bit = 224 = 16,777,216 colours. Doubling the bit depth squares the number of available colours.
How Sound Is Stored
Sound is an analogue signal — a continuous wave of varying air pressure. Computers cannot store continuous signals directly, so sound must be converted to digital form by taking regular measurements called samples. Each sample captures the amplitude (volume level) of the sound at that moment.
This conversion from analogue to digital is performed by an analogue-to-digital converter (ADC). Playback reverses the process through a digital-to-analogue converter (DAC), turning the stored numbers back into a continuous wave through a speaker.
Sampling Rate and Sample Resolution
Sampling rate is how many samples are captured every second, measured in hertz (Hz). A higher sampling rate captures the original sound wave more faithfully because it takes more measurements. CD-quality audio uses a sampling rate of 44,100 Hz — meaning 44,100 measurements are made every second.
Sample resolution (also called bit depth) is the number of bits used for each sample. A higher sample resolution captures more precise volume levels. CD-quality audio uses a 16-bit sample resolution, giving 65,536 possible amplitude levels per sample. Higher sample resolution produces richer, more detailed sound.
Sound file size (bits) = sampling rate × sample resolution × duration (seconds). To convert to bytes, divide by 8. Always check which unit the question asks for.
Problem: A 60-second piece of music is recorded at CD quality: sampling rate 44,100 Hz, sample resolution 16 bits. Calculate the file size in megabytes.
Step 1 — Apply the formula: Size (bits) = 44,100 × 16 × 60 = 42,336,000 bits.
Step 2 — Convert to bytes: 42,336,000 ÷ 8 = 5,292,000 bytes.
Step 3 — Convert to megabytes (1 MB = 1,000,000 bytes): 5,292,000 ÷ 1,000,000 = 5.292 MB ≈ 5.3 MB.
Note: This is for a single audio channel (mono). Stereo audio would double the file size to roughly 10.6 MB for 60 seconds. This is why CD-quality audio needs compression (MP3) to be practical for streaming.
Quality Versus File Size
Both image and sound files face the same trade-off: higher quality always means larger file size. For images, increasing resolution (more pixels) or colour depth (more bits per pixel) improves quality but uses more storage. For sound, increasing sampling rate or sample resolution captures the audio more accurately but grows the file. In practice, file size is managed through compression — covered in the next lesson.
Metadata is stored alongside the pixel or sample data. For a bitmap image, metadata includes the width, height and colour depth. For a sound file, it includes the sampling rate and sample resolution. Metadata is not counted in the main file size calculation but it is always present in real files.