Information representation
Compression: lossy, lossless and RLE
What you need to be able to do
- 1.3Explain the need for compression and give examples of its use.
- 1.3Describe lossy and lossless compression and justify using one in a given situation.
- 1.3Explain how a text file, a bitmap image, a vector graphic and a sound file can be compressed, including run-length encoding (RLE).
You need: how text, bitmaps, vectors and sound are stored (pages 3-6 of this chapter). This page ties them together.
Why compress?
Compression reduces the file size. On its own that earns little; every mark comes from the consequence in the context given:
| Smaller file means… | so (the context) |
|---|---|
| less storage space used | more files fit on the device / the web server / the user's storage; the email account's limit is not exceeded |
| faster to upload / download / transmit | the customer waits less; a teacher receives the attachment sooner |
| less bandwidth used | other transmissions on the network are not slowed; users with low bandwidth can still take part |
| less data allowance used | cheaper for users on a mobile data plan |
| less buffering when streaming | a video call / live stream plays smoothly, people are not behind in the conversation |
| fits a maximum attachment size | email providers often limit attachment size |
Lossy and lossless compression
| Lossless | Lossy | |
|---|---|---|
| What happens | the file is re-encoded more efficiently; no data is lost | some data is permanently removed (usually detail people won't notice) |
| Decompressed file | identical to the original: it can be re-created exactly | not the same as the original: the removed data can't be got back |
| Size reduction | smaller | much smaller (a larger reduction than lossless) |
| Use it for | text, program code, spreadsheets, databases; images where every pixel matters (e.g. medical scans, line art) | photographs, music, video, streaming: anything where a small loss of quality is not noticed |
| Examples | RLE; ZIP; PNG; FLAC | JPEG; MP3; MP4 / most streaming video |
Text must be lossless
No data can be lost: removing even one character changes the meaning; the file would be corrupted / not make sense / not open. Program code would no longer run.
Photos and video: usually lossy
The data removed is not noticed by the human eye (small changes of shade, fine detail), and the file becomes much smaller - important for real-time streaming where bandwidth is limited.
When lossless wins for media
When quality matters more than size: high-quality originals that will be edited again, or a fast dedicated connection that doesn't need the reduction.
No mark for the choice alone
“Tick lossy or lossless and justify” usually gives no mark for the tick: all the marks are for the justification, which must fit the situation.
Run-length encoding (RLE)
RLE on text
- Read from the start. Count how many times the same character appears in a row (consecutively).
- Write the count, then the character.
- Start counting again at the next different character.
| Original (12 characters) | RLE |
|---|---|
| AAAABBBCCDAA | 4A3B2C1D2A (10 characters) |
Note that the final “AA” is a new run: RLE only joins identical values that are next to each other.
RLE on a bitmap
Each pixel's colour code is the value. A row of 20 pixels, W = white, B = black:
| Pixels | RLE (count, colour) |
|---|---|
| WWWWWWWW BBB WWWWWWWWW | 8W 3B 9W: 3 pairs instead of 20 colour codes |
Decoding
Read each pair as “this many of this value”: 3F2 = F2 F2 F2. In hex-coded images the count comes first and the colour is the last two hex digits: “11D” = one pixel of colour 1D.
When RLE does not help
RLE stores a value and a count for every run. If the data has few repeated runs, every run has length 1, so each value gains a count and the file gets bigger: Red Green Blue → Red 1 Green 1 Blue 1 (June 2023). Photographs, with many slightly different colours next to each other, often compress badly with RLE; simple graphics with large areas of one colour compress well.
1 Encode text
Compress “TTTTTOOOOP” with RLE.
AskedRLE stringKnowruns: 5 T, 4 O, 1 PRoutecount + character per run
- 5T4O1P: 10 characters → 6
2 Decode
Decode the RLE “3E5F2E”.
AskedoriginalKnowpairs (count, value)Routeexpand each pair
- 3E → EEE, 5F → FFFFF, 2E → EE
- EEEFFFFFEE
3 RLE makes it worse
Compress “ABCDABCD” with RLE. What happens?
Askedresult + effectKnowno two neighbours are equalRouteevery run has length 1
- 1A1B1C1D1A1B1C1D: 16 characters instead of 8
- The file doubles: RLE is not suitable for data without runs
4 A pixel row in hex codes
8-bit colour codes: 0F 0F 0F 0F A2 A2 0F. Write the RLE.
AskedRLEKnowruns of identical codesRoutecount before each code
- 40F 2A2 10F
How each kind of file is compressed
| File type | Lossless methods | Lossy methods |
|---|---|---|
| Text | RLE: repeated sequences of the same character replaced by one copy + a count; (dictionary methods: repeated words / patterns replaced by short codes) | not used: no data can be lost |
| Bitmap image | RLE: runs of consecutive identical pixels stored as colour + count | reduce the colour (bit) depth → fewer bits per pixel; reduce the colour palette → fewer colours, fewer bits each; reduce the image resolution → fewer pixels; remove detail / changes of shade the human eye can't see (JPEG) |
| Vector graphic | general lossless compression of the drawing list (repeated commands / values stored once); remove redundant data (hidden objects, duplicate properties) | simplify shapes: fewer points on curves, store coordinates with less precision |
| Sound | RLE of repeated sample values (e.g. silence); record the changes between samples instead of the actual values; reduce the amplitude range stored to only the range used → fewer bits per sample | reduce the sampling rate → fewer samples per second; reduce the sampling resolution → fewer bits per sample; remove sounds outside the range of human hearing (and quiet sounds masked by louder ones: perceptual coding, MP3) |
Vector graphics compress much less than bitmaps: the drawing list has little redundant data to remove (November 2021 scheme).
Choosing lossy or lossless: case by case
1 Live video call
A video conference uses real-time bit streaming. Lossy or lossless? Justify.
Askedchoice + reasonsKnowreal time; limited bandwidthRoutesmallest file wins
- Lossy: reduces the file size more than lossless
- so significantly less bandwidth is needed and buffering is reduced
- data that can't be seen is removed (e.g. lower video resolution / audio sample rate), so quality loss is not noticed
2 A program's source code emailed
A program file is compressed before being emailed. Lossy or lossless?
Askedchoice + reasonKnowcode must runRouteno data loss allowed
- Lossless: every character is needed; losing any would corrupt the file / stop the program working
3 Photos on a website
Holiday photos are uploaded to a web server for customers to view. Lossy or lossless?
Askedchoice + reasonsKnowviewing only; many downloadsRoutemuch smaller files
- Lossy: much smaller files → faster for customers to download, less storage on the server, less bandwidth
- the detail removed is not noticed by the human eye
4 A medical scan
X-ray images are stored for doctors to examine. Lossy or lossless?
Askedchoice + reasonKnowevery detail may matterRouteaccuracy beats size
- Lossless: the original must be re-created exactly; a removed detail could change a diagnosis
5 Reducing the sampling rate
A sound file is compressed by reducing its sampling rate. Is this lossy or lossless?
Askedtype + reasonKnowsamples are discardedRoutecan the original come back?
- Lossy: there are fewer samples per second, so data is permanently lost / the original sound cannot be re-created
Mark-scheme focus
Lossless compression of a text file; why lossy must not be used (4 marks)
![(iii) Describe how lossless compression can be used to reduce the file size of a text file. [2] (iv) Explain why lossy compression should not be used on a text file. [2]](/notes-content/9618/information-representation/img/9618_s22_13_q01_aiiiaiv.png)
- (iii) Run-length encoding can be used B1; identifies groups of repeated characters … replaces them with one copy of the character and the number of times it occurs B1
- (iv) None of the original data can be lost / deleted B1; the text file would be corrupted // cannot be opened B1
- (iii) describing image compression (pixels) for a text file
- (iv) one point only, written twice in different words
The June 2022 report: most said the file would be corrupted but missed the second mark. Two marks = two distinct points: no data may be lost, AND what happens if it is.
From: 9618/13/M/J/22 Q1(a)(iii), (iv)
Why RLE may not reduce the size of a bitmap, with an example (3 marks)
![(c)(ii) An image can be compressed using run-length encoding (RLE). Explain the reasons why RLE may not reduce the file size of a bitmap image. Give one example in your answer. [3]](/notes-content/9618/information-representation/img/9618_s23_11_q01_cii.png)
- RLE stores a colour and the number of times it occurs consecutively B1
- An image may not have many sequences of the same colour B1
- It would need to store each colour and then the count 1, which adds data B1 (max 2 for the explanation)
- Example: Red-Green-Blue would become Red 1 Green 1 Blue 1 B1
- An example with characters (“ABC → 1A1B1C”) when the question is about a bitmap
- “RLE doesn't work on photos” with no reason
The example must be about colours / pixels: the June 2023 report noted examples using characters instead of colours.
From: 9618/11/M/J/23 Q1(c)(ii)
Why lossy compression is often suitable for a bitmap image (2 marks)
![(b) The colour of each pixel in a bitmapped image is represented by 8 bits. (iii) A bitmap image can be compressed using lossy compression. Explain the reasons why lossy compression is often suitable for a bitmap image. [2]](/notes-content/9618/information-representation/img/9618_w24_13_q06_biii.png)
- The change may not be noticeable // data removed is usually not noticed by the human eye B1
- … for example, changes in shade / detail B1
- It produces a larger decrease in file size compared to lossless B1 (max 2)
- “It makes the file smaller” (true of all compression)
- “The quality stays the same” (it doesn't - it just isn't noticed)
The reason lossy suits images is human perception plus a bigger reduction; “smaller” alone doesn't separate lossy from lossless.
Why compress a sound file for email; how lossless compression works on sound (4 marks)
![(b) Bobby wants to email the sound file to his school email address. He compresses the file before sending the email. (i) Explain the reasons why Bobby compresses the sound file. [2] (ii) Bobby uses lossless compression. Describe how lossless compression can compress the sound file. [2]](/notes-content/9618/information-representation/img/9618_w21_11_q07_b.png)
- (i) Reduces the file size B1; faster to transmit / download // original file too large for email storage / attachment B1
- (ii) e.g. RLE: where consecutive sounds are the same, record the value and the number of times it repeats B1 B1 // reduce the amplitude range to only the range used, so fewer bits per sample // record the changes instead of the actual sounds
- (i) “Easier to transmit” (the report wanted speed)
- (ii) generic lossless descriptions with text or image examples
(ii) must be about sound: the report said answers were generic and seldom referred to the sound file.
From: 9618/11/O/N/21 Q7(b)
- Compression appears in most papers, usually attached to an image, sound or text question: 2-7 marks.
- Most asked: benefits of compressing in a context (2-3), lossy vs lossless choice + justification (1-3), describe RLE for text or an image (2-3).
- Lost marks: generic answers that ignore the file type or the context; one-word reasons (“smaller”, “easier”).
Worked examples
Example 1 · RLE on one row of pixels (Paper 1, 2 marks) ★ Easy
![(d) The first row of pixels in the image from part (b) is shown: B B B B B B B B B B (ten blue pixels). Explain how this row of pixels can be compressed using lossless compression. [2]](/notes-content/9618/information-representation/img/9618_s22_12_q01_d.png)
Ten identical pixels in a row: the perfect case for RLE. The second mark is for applying it to this row.
- this row of pixelsuse the row: 10 × B
- losslessRLE
- (d)name + apply
- BBBBBBBBBB
- Compress
- MethodRLE
- Applycolour B, count 10
What would a generic answer miss?
The report: answers that didn't explain how the method applies to the row given lost the second mark.
5 Now solve it have a go on paper first, then open the worked solution
- Use run-length encoding B1
- Record the colour Blue and the number of times it occurs, 10 B1
10 colour codes become one colour + one count ✓.
Example 2 · Completing an RLE table, then text and lossless (Paper 1, 4 marks) ★★ Medium
![(c) A second bitmap image is stored using a colour depth of 8 bits per pixel. It is compressed using RLE. (i) Complete the table of uncompressed and RLE compressed values (hex colour codes): EA F1 F1 F2 F2 F2 EA ↔ 1EA 2F1 3F2 1EA (given); … ↔ 2AB 2FF 11D 167; 32 32 80 81 81 ↔ … [2] (ii) RLE is an example of lossless compression. Explain why lossless compression is more appropriate than lossy compression for a text file. [2]](/notes-content/9618/information-representation/img/9618_w22_12_q08_c.png)
The first row shows the format: count, then the 2-digit hex colour. Row 2 is decoding; row 3 is encoding.
- first row completedcopy its format exactly
- each colour = hex valuecolour codes are 2 hex digits; anything before them is the count
- (c)(i)two cells
- (c)(ii)why lossless for text
- 2AB 2FF 11D 167decode
- 32 32 80 81 81encode
- Row 2decode
- Split2|AB, 2|FF, 1|1D, 1|67
- Trapwriting FF once
- Row 3encode
- Runstwo 32s, one 80, two 81s
- Trap80 instead of 180
How is “11D” split?
Count 1, colour 1D: the colour is always the last two hex digits.
5 Now solve it have a go on paper first, then open the worked solution
- (i) Row 2: AB AB FF FF 1D 67 B1
- Row 3: 232 180 281 B1
- (ii) All the data is required // no data can be lost B1 … otherwise the text file will be corrupted / not make sense B1
Re-encode row 2 to check: AB AB → 2AB, FF FF → 2FF, 1D → 11D, 67 → 167 ✓. The report saw “only one FF” and “80 instead of 180”.
Example 3 · Live streaming a concert: choose and justify (Paper 1, 3 marks) ★★ Medium
![(a) A real-time video of a music concert needs to be streamed to subscribers. Tick one box to identify the most appropriate type of compression (lossy or lossless) and justify your answer. [3]](/notes-content/9618/information-representation/img/9618_w23_12_q06_a.png)
Three marks, all for the justification. Real-time streaming = the data must keep arriving as fast as it is watched.
- real-timeno time to wait: buffering ruins it
- subscribersmany viewers, many devices
- justifyreasons linked to streaming
- (a)choice + justification
- Lossy?
- Sizemuch smaller → less bandwidth
- Viewerloss not noticed; less buffering
- Devicesphones don't need full resolution
Could lossless be justified?
Yes, the scheme also credits it (e.g. viewers don't want any loss; high-bandwidth devices). Lossy is the stronger case.
5 Now solve it have a go on paper first, then open the worked solution
- Lossy (ticked)
- Loss of quality will not be noticed B1
- Needs to be viewed in real time, so less bandwidth needed if the file size is smaller B1
- Smaller file sizes reduce buffering so the video plays more smoothly // viewers on different devices may not need high resolution B1
Every point links the choice to real-time streaming ✓.
Example 4 · Two lossy methods for a photograph (Paper 1, 4 marks) ★★★ Hard
Riya takes a photograph using a digital camera. The photograph is stored as a bitmap image.
- (b)(ii)Riya needs to email the photograph. She compresses the photograph before sending it using an email.[4]
Describe two lossy methods that Riya can use to compress the image.
Method 1 …… Method 2 ……
Why it is hard: the November 2021 report: answers “frequently described lossy compression and the effects of the compression on the image, not methods of lossy compression”.
“Describe two methods”: 2 marks each = the method + how it reduces the data. Effects on the picture don't score.
- lossy methodsways of removing data from a bitmap
- describemethod + why fewer bits
- (b)(ii)two methods, each explained
- Methods
- Bit depthfewer bits per pixel
- Palettefewer colours, fewer bits each
- Resolutionfewer pixels
- Trap“use JPEG”
Is “remove colours the eye can't see” a method?
Not as a description: the report wanted how it compresses the image.
5 Now solve it have a go on paper first, then open the worked solution
- Method 1: reduce the bit (colour) depth B1 … reduces the number of bits per pixel, so each pixel needs fewer bits B1
- Method 2: reduce the image resolution B1 … fewer pixels, so less binary to store B1
- (also credited: reduce the colour palette … fewer colours mean fewer bits are needed to store each colour)
Both methods say what is reduced and why the data shrinks ✓.
Summary
- Compression reduces file size → less storage, faster transfer, less bandwidth / buffering: always tie it to the context.
- Lossless: no data lost, original re-created exactly (text, code). Lossy: data permanently removed, much smaller (photos, audio, video, streaming).
- RLE: runs of consecutive identical values → value + count. Great for long runs, makes data without runs bigger.
- Image lossy: lower depth / palette / resolution. Sound lossy: lower rate / resolution, remove inaudible sounds.
| If you see… | do this |
|---|---|
| “explain why … compressed” in a context | smaller → faster / less storage / bandwidth, for the people in the question |
| “lossy or lossless?” + justify | no mark for the choice: give reasons that fit the situation |
| “describe RLE” for an image | consecutive identical pixels → colour + count |
| “describe RLE” for text | repeated characters → one copy + count |
| an RLE table | copy the given row's format; count then value |
| “describe a lossy method” | what is reduced + why it means fewer bits |
Can I do this?
- I can explain the benefits of compression in a given context.
- I can describe lossy and lossless compression and say why text must be lossless.
- I can justify lossy or lossless for a given situation.
- I can encode and decode RLE for text and images, and explain when it doesn't help.
- I can describe how text, bitmap, vector and sound files can be compressed (lossy and lossless).
Anything unticked: revise that section first. All ticked: take the quiz.
Quiz
The multiple-choice and guided questions need JavaScript. The concept checks and exam practice below work without it.
Concept checks
Answer each one in your head first, then open it.
1Why can lossless compression make a file smaller without losing anything?Show answer
Most files contain redundancy - repeated patterns. Lossless methods store the repeats more cleverly (e.g. once with a count) and can rebuild them exactly.
2Why does compressing an already-compressed JPEG with ZIP barely help?Show answer
The JPEG has already removed most of the redundancy; there is little repetition left for a lossless method to exploit.
3Is reducing the sampling rate compression, or just a different recording?Show answer
Both: it is a lossy way of reducing the size of an existing recording, because samples are thrown away and can't be recovered.
4Why do vector graphics compress so little?Show answer
Their drawing lists are already compact, with little redundant data to remove.
Exam-style practice
New questions, not used above. Do them on paper, then mark your work against the official mark scheme.
![(b) The image is compressed using lossless compression. Identify one method of lossless compression that can be used to compress the image and describe how the method will reduce the file size. [3]](/notes-content/9618/information-representation/img/9618_s21_11_q01_b.png)
Show the mark scheme
| Part | Answer / working | Marks | Guidance |
|---|---|---|---|
| (b) | Run-length encoding | B1 | |
| Replace sequences of the same colour pixel … | B1 | must be consecutive / adjacent pixels | |
| … with colour code and number of identical pixels | B1 | ||
| Total: 3 marks | |||
Examiner tip The June 2021 report: descriptions did not always make it clear that the identical pixels were adjacent, and some described text instead of the image.
![(b) The student compresses the file (a program saved as a text file) before it is emailed to their teacher as an attachment. (i) Explain the benefits to the teacher of the attachment being a compressed file. [3] (ii) Describe one lossless method of compressing a text file. [3]](/notes-content/9618/information-representation/img/9618_w24_11_q04_b.png)
Show the mark scheme
| Part | Answer / working | Marks | Guidance |
|---|---|---|---|
| (b)(i) | Less of the teacher's storage space is used … so more student work can be stored | B1 | |
| Transmission time is reduced … so the teacher does not have to wait as long for it to arrive | B1 | ||
| Bandwidth usage is reduced … so other transmissions are not adversely affected // less data allowance used | B1 | max 3, benefits to the teacher | |
| (b)(ii) | Run-Length Encoding // RLE | B1 | |
| Repeated sequences of the same characters are replaced by … | B1 | ||
| … a single copy of the character and a count of the number of characters | B1 | ||
| Total: 6 marks | |||
![Programmers take part in live video conferences using real-time bit streaming; the video is compressed before it is transmitted. (b)(i) Explain the reasons why a video is compressed before it is transmitted using real-time bit streaming. [4] (ii) Identify whether the lossy or lossless compression method is more appropriate for real-time bit streaming. Justify your answer. [3]](/notes-content/9618/information-representation/img/9618_s25_11_q02_b.png)
Show the mark scheme
| Part | Answer / working | Marks | Guidance |
|---|---|---|---|
| (b)(i) | Video is data-intensive | B1 | |
| The file size needs reducing in order to … | B1 | ||
| … reduce the amount of bandwidth used … and reduce buffering | B1 | ||
| This means people are not behind in the conversation // people with lower bandwidth can still take part | B1 | max 4 | |
| (b)(ii) | No mark for the choice; lossy is most appropriate | ||
| Reduces file size more than lossless … so significantly less bandwidth / data is needed | B1 | ||
| … so buffering is reduced even more than with lossless | B1 | ||
| Data can be removed which cannot be seen, reducing quality without impacting the experience (e.g. lower video resolution / audio sample rate) | B1 | max 3 | |
| Total: 7 marks | |||
![(a) A sound file is compressed by reducing the sampling rate. State whether this is lossless or lossy compression. Justify your choice. [1]](/notes-content/9618/information-representation/img/9618_w25_12_q06_a.png)
Show the mark scheme
| Part | Answer / working | Marks | Guidance |
|---|---|---|---|
| (a) | Lossy: there will be fewer samples per second, so data will be permanently lost // the original sound cannot be re-created | B1 | type and justification both needed |
| Total: 1 mark | |||
![(c) Explain why a bitmap image is often compressed before it is attached to an email. [2]](/notes-content/9618/information-representation/img/9618_w23_11_q01_c.png)
Show the mark scheme
| Part | Answer / working | Marks | Guidance |
|---|---|---|---|
| (c) | Reduced bandwidth usage when transmitting the message // reduced transmission time to the email server | B1 | |
| Reduced storage space on the email server // email accounts often have a maximum size for an attachment | B1 | max 2 | |
| Total: 2 marks | |||
Your progress on this note is saved when JavaScript is on.