COMPUTER SCIENCE CAFÉ
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY

1.3.4 | LOSSY AND LOSSLESS COMPRESSION

Topics from the Cambridge IGCSE (9-1) Computer Science 0984 syllabus 2023 - 2025.
OBJECTIVES
1.3.4 Understand how files are compressed using lossy and lossless compression methods
ALSO IN THIS TOPIC
1.1.1 NUMBER SYSTEMS
1.1.2 NUMBER SYSTEMS
1.1.3 NUMBER SYSTEMS 
1.1.4 NUMBER SYSTEMS
 ​1.1.5 NUMBER SYSTEMS
1.1.6 NUMBER SYSTEMS
1.2.1 TEXT, SOUND AND IMAGES
​​1.2.2 TEXT, SOUND AND IMAGES
​1.2.3 TEXT, SOUND AND IMAGES
​1.3.1 STORAGE AND COMPRESSION
​​1.3.2 STORAGE AND COMPRESSION
1.3.3 STORAGE AND COMPRESSION
YOU ARE HERE | ​​​​1.3.4 STORAGE AND COMPRESSION
TOPIC 1 KEY TERMINOLOGY
TOPIC 1 ANSWERS
TOPIC 1 TEACHER RESOURCES (CIE)

Picture
LOSSY COMPRESSION
The key element of Lossy compression is that the file will lose quality when it is compressed. The lose of quality is not important for many files and in many cases we do not even notice the reduction in quality. Some key points on Lossy compression are:

✓ Lossy compression reduces the file size by removing some of the data, because of this an exact match of the original data cannot be recreated. Quality is lost.
✓ Lossy compression uses an algorithm that looks to remove detail that is barely noticeable, for example if pixels next to each other in an image are almost the same colour then the Lossy algorithm will give them the same value to reduce the bytes needed to store the detail.
✓ Lossy compression is often used on files such as images and sound files such as MP3s and JPGs
✓ Lossy compression is often not a good option for files such as text documents
​✓ Lossy compression can make files sizes smaller that is possible with Lossless compression
LOSSLESS COMPRESSION
The key element to lossless compression is the no quality is lost during the process of compression. Lossless compression is used when it is important to maintain the original quality. Some key points of Lossless compression are:

✓ Lossless compression will not remove any quality from the file, the compressed version will be the same as the original when uncompressed.
✓ Lossless compression uses an algorithm that looks for repeat data, this can be groups and categorised and a token be given for where each group will be used in the reconstruction
✓ Lossless compression is often used on files such as text files and images such as DOCXs, GIFs and PNGs
​✓ Lossless compression is often not a good option for audio files and high colour images

✓ Lossless compression is more limited than Lossy compression with how small the file size can be made
VIDEO BY: CRASH COURSE
COMPRESSION METHODS
Run Length Encoding (RLE)
​Run Length Encoding is a method of compression that looks for repeating patterns and then encodes them into one item of data of a specified length.
Picture
Take the top row of the image, it has 8 white pixels and then the second row 1 white pixel, 2 red pixels, 2 white and so on. An uncompressed representation of the image would represent each pixel individually for example the binary for the row, if this was an 8 bit image then the top row has 8 pixels with 8 bits used to represent the colour of each pixel meaning it take 8pixels x 8bits = 64bit to represent the 8 white pixels. With run length encoding we can simply encode this as 8 white pixels in a row 8W this would mean 8 bits would be used to represent the length of the pattern and 8 bits to represent the colour meaning using run-length encoding the top row could be compressed from 64 bits to just 16 bits.

Huffman Encoding
Huffman Encoding is often used in Lossless compression and it uses a greedy algorithm to create an encoding system that uses a binary tree principle to allocate each item a unique code, ensuring that the most frequently occurring item gets the smallest code.

"learning is a journey, enjoy" 
​
​
Doing a frequency analysis on the quote above we can see that the most frequently occurring letter is 'n' and also the 'space', which appear 4 times each, followed be 'e' appearing 3 times. Continuing this frequency analysis we can put each letter in a chart in order of frequency.

​We can then use a tree to illustrate and allocate each letter a binary code, the letters that occur the most frequent will go at the top of the tree and the code allocated for these letters will require less Bits to encode than those occurring further down the tree.
Picture
Looking at the allocation of encoding in this method we can see that each letter in the quote was allocated the following binary representations, this can then be used as the key to recovering the compressed file with zero loss to the original quality. ​
Picture
1: What is the main difference between lossy and lossless compression?
a) Lossy compression retains all original data
b) Lossless compression reduces file size by permanently discarding data
c) Lossy compression reduces file size by discarding some data that can be reconstructed
d) Lossless compression makes no changes to the original data

2: Which of the following is an example of lossless compression?
a) JPEG
b) MP3
c) ZIP
d) MPEG

3: Which of the following compression methods is best suited for compressing text documents?
a) Lossy compression
b) Lossless compression
c) Run-length encoding
d) Huffman coding

4: What is run-length encoding?
a) A type of lossy compression that discards some data
b) A type of lossless compression that compresses repeating sequences of data
c) A type of compression that only works on images
d) A type of encryption that scrambles data to prevent unauthorized access

5: Which of the following is an example of lossy compression?
a) PNG
b) TIFF
c) WAV
d) MP4

6: How does lossy compression achieve smaller file sizes?
a) By discarding some data that can be reconstructed
b) By compressing repeating sequences of data
c) By encrypting the data
d) By using an algorithm to reorder the data

7: Which of the following is an advantage of lossless compression over lossy compression?
a) Smaller file sizes
b) Retains all original data
c) Less processing power required
d) Better suited for compressing multimedia files

8: Which compression method is most commonly used for compressing digital images?
a) Lossy compression
b) Lossless compression
c) Run-length encoding
d) Huffman coding
Picture
ALSO IN THIS TOPIC
1.1.1 NUMBER SYSTEMS | Why Computers use Binary
1.1.2 NUMBER SYSTEMS | Binary, Hex and converting between number systems 
1.1.3 NUMBER SYSTEMS | Benefits of Hex
1.1.4 NUMBER SYSTEMS | Binary Addition and Overflow
1.1.5 NUMBER SYSTEMS | Binary Shifts
1.1.6 NUMBER SYSTEMS | Negative Number Representation, Two's Complement
1.2.1 TEXT, SOUND AND IMAGES | How Computers Represent Text
1.2.2 TEXT, SOUND AND IMAGES | How Computers Represent Sound
1.2.3 TEXT, SOUND AND IMAGES | How Computers Represent Images
1.3.1 STORAGE AND COMPRESSION | How Data Storage is Measured
​1.3.2 STORAGE AND COMPRESSION | Calculating Image and Sound File Size
​1.3.3 STORAGE AND COMPRESSION | Purpose of Data Compression
​1.3.4 STORAGE AND COMPRESSION | Lossy and Lossless, how files are compressed
TOPIC 1 KEY TERMINOLOGY
TOPIC 1 ANSWERS
TOPIC 1 TEACHER RESOURCES (CIE)
Picture
NEXT PAGE | BINARY AND HEX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
PART 1 | 1.1.1 WHY COMPUTER USE BINARY 
PART 2 | 1.1.2 BINARY, HEX AND CONVERTING BETWEEN NUMBER SYSTEMS 
PART 3 | 1.1.3 BENIFITS OF HEX 
PART 4 | 1.1.4 BINARY ADDITION AND OVERFLOW 
PART 5 | 1.1.5 NUMBER SYSTEMS 
PART 6 | 1.1.6 NUMBER SYSTEMS 
PART 7 | 1.2.1 TEXT, SOUND AND IMAGES 
PART 8 | 1.2.2 TEXT, SOUND AND IMAGES 
PART 9 | 1.2.3 TEXT, SOUND AND IMAGES 
PART 10 | 1.3.1 STORAGE AND COMPRESSION ​
PART 11 | 1.3.2 STORAGE AND COMPRESSION
PART 12 | 1.3.3 STORAGE AND COMPRESSION 

PART 13 | 1.3.4 STORAGE AND COMPRESSION | YOU ARE HERE
PART 14 | END OF TOPIC REVIEW

TOPIC 1 KEY TERMINOLOGY
REVISION FLIP CARDS
TOPIC 1 ANSWERS
TOPIC 1 TEACHER RESOURCES (CIE)
Picture
SUGGESTIONS
We would love to hear from you
SUBSCRIBE 
To enjoy more benefits
We hope you find this site useful. If you notice any errors or would like to contribute material then please contact us.