Characters, images, sound and compression
How text, pictures and sound are stored as binary, working out file sizes, and lossy and lossless compression.
Watch the lesson
Every point below, worked through in one video, and each point links straight to its own part.
Learn
Characters, images, sound and compression, explained point by point
Everything the GCSE specification expects you to be able to do, and how to actually do it - the same lesson a signed-in student studies from.
Explain how characters are stored using a character set such as ASCII or Unicode
A character set gives every character its own binary code. ASCII uses 7 bits, enough for 128 characters: the English letters, digits and punctuation. OCR treats ASCII as 8 bits, giving 256. Unicode uses more bits per character, so it can hold many thousands, covering the world’s alphabets and emoji, at the cost of bigger files. The codes run in order, so if A is 65 then C is 67. The size of a text file is the number of characters multiplied by the bits per character. Edexcel examines 7-bit ASCII and does not ask about Unicode.
Explain how an image is stored as pixels, and what colour depth and resolution change
A bitmap image is a grid of pixels, and each pixel’s colour is stored as a binary number. Colour depth is the number of bits used for each pixel: 1 bit gives 2 colours, 8 bits give 256. Resolution is the number of pixels, which AQA calls the image size, given as width by height. Raising either one improves the picture and makes the file bigger. OCR also asks about metadata, the extra information stored with the image, such as its height, width and colour depth, without which the file could not be drawn.
Calculate the file size of an image
File size in bits = width in pixels × height in pixels × colour depth. An image 100 pixels wide and 80 high with a colour depth of 4 bits needs 100 × 80 × 4 = 32 000 bits. Divide by 8 for bytes: 4000 bytes, which is 4 kilobytes if your board counts in thousands. Show each step, since the method earns marks even when the arithmetic slips. AQA may also ask you to turn a small black and white grid into its binary code, row by row, and back again.
Explain how sound is sampled and stored, and what changes the quality
Sound is an analogue wave. To store it, the computer measures the height of the wave at regular intervals. Each measurement is a sample. The sample rate is the number of samples taken each second, in hertz. The bit depth, which AQA calls the sample resolution, is the number of bits used to store each sample. A higher sample rate or a greater bit depth follows the original wave more closely, so the recording sounds better and the file is bigger. Eduqas asks about the sample rate only.
Calculate the file size of a sound recording
File size in bits = sample rate × bit depth × length in seconds. A 10 second recording at 8000 samples a second with 16 bits per sample needs 8000 × 16 × 10 = 1 280 000 bits, which is 160 000 bytes. Watch the units of time: a recording given in minutes has to be turned into seconds first. If a question gives the file size and asks for the length, rearrange the same formula.
Explain why files are compressed, and compare lossy and lossless compression
A compressed file takes less storage and is quicker to send, which matters for streaming and for web pages. Lossy compression removes data for good, such as sounds people can barely hear, so the file is much smaller but can never be restored to the original. It suits photos, music and video. Lossless compression finds a shorter way to write the same data, and the original can be rebuilt exactly, so it is the only choice for text and program files. Eduqas also asks for a compression ratio: the original size divided by the compressed size. AQA asks why data is compressed and for the two methods below, without using the words lossy and lossless.
Compress data using run-length encodingAQA only
Run-length encoding (RLE) replaces a run of repeated values with a count and the value. The row of pixels WWWWWBBW becomes 5W 2B 1W. It works well on images with large blocks of one colour and badly where the values keep changing, when the encoded version can be longer than the original. It is lossless: the pairs rebuild the row exactly. Only AQA asks you to carry it out.
Read a Huffman tree and work out how many bits it savesAQA only
Huffman coding gives the most common characters the shortest codes. The codes come from a tree: start at the top, write 0 for each left branch and 1 for each right branch, and stop at the character. To find the size of a message, multiply how often each character appears by the length of its code and add the results. Compare that with 7 bits per character in ASCII to find the saving. Only AQA examines Huffman coding, and it asks you to interpret a tree, not to build one.
Characters, images, sound and compression key terms
The words the specification and the mark schemes use, each defined the way an examiner wants it.
- Character set
- The list of characters a computer can represent, each with its own binary code.
- ASCII
- A character set that uses 7 bits per character to represent 128 characters, including the English alphabet.
- Unicode
- A character set that uses more bits per character than ASCII so that it can represent the characters of all languages.
- Pixel
- A single point of colour in a bitmap image: the smallest element of the picture.
- Colour depth
- The number of bits used to store the colour of each pixel.
- Resolution
- The number of pixels in an image, given as its width by its height.
- Metadata
- Additional data stored with a file that describes it, such as the height, width and colour depth of an image.
- Sample rate
- The number of samples of a sound wave taken each second, measured in hertz.
- Bit depth
- The number of bits used to store each sample of a sound.
- Lossy compression
- Compression that permanently removes some data, so the original file cannot be restored exactly.
- Lossless compression
- Compression that reduces file size without losing any data, so the original can be rebuilt exactly.
- Run-length encoding
- A lossless method that stores each run of repeated values as the value and the number of times it repeats.
Common mistakes in Characters, images, sound and compression
The slips that cost marks year after year, and what to do instead.
Leaving a file size in bits when the question asks for bytes
The formulas give bits. Divide by 8 for bytes, then by your board’s 1000 or 1024 for each larger unit.
Mixing up colour depth and resolution
Colour depth is bits per pixel and decides how many colours are possible. Resolution is how many pixels there are.
Saying lossy compression is always the wrong choice
Lossy suits photos, music and video, where a small loss is not noticed. It is wrong for text and programs, where every bit matters.
Stating that a higher sample rate improves quality without saying why
More samples each second follow the original wave more closely. Add that the file gets bigger as a result.
Using minutes in the sound file size formula
The sample rate is per second, so turn the length into seconds before multiplying.
Practice
Try a Characters, images, sound and compression question
A GCSE-style original question from this topic. Have a go before you open the working - deciding on an answer first is what makes the working stick.
Answer: 20,000
200 × 100 × 8 = 160 000 bits, and 160 000 ÷ 8 = 20 000 bytes.
- Pixels: 200 × 100 = 20 000.
- Bits: 20 000 × 8 = 160 000.
- Bytes: 160 000 ÷ 8 = 20 000.
