Data compression is a term used to describe reducing the size of a file whilst keeping it in a usable format. There would be little point in making a file smaller if we could no longer use it, so different algorithms have been developed to allow us to make efficient use of space on our digital devices.
Compression techniques can be categorised into two methods:
Lossy – data is removed from the original file to reduce its size.
Lossless – data is not removed from the original file, or can be restored in full.
Lossy compression can be applied to files where losing data may not be detected, or if it is, the file is still usable. This generally means that images, video, and sound use lossy compression techniques (but not always!).
When you are watching a streamed video, you will often be given the choice of watching in HD or SD. Whilst we know the Standard Definition video is of inferior quality, it does have the benefits of being a much smaller file so it will work on slower connections. Even though the file is of a lower quality (due to lossy compression), it remains usable.
JPEG image files use a lossy compression technique where the number of colours in the image are reduced to just those within the human spectrum of vision. Often, the number of colours is reduced to far less without a visible difference. In the case of JPEG files, the removal of colours is balanced by replacing the standard RGB (red green blue) colours with luma (brightness & contrast) & chroma (red – blue colour).
Lossless compression is employed when we need to reduce the size of the file without losing any data. This may be because removing data would make the file unusable as is the case for text files or program code, or to allow us to uncompress the file back to it’s original state for editing.
Zipped files make use of lossless compression, allowing the files & folders to be uncompressed after sending without losing data. Compressing data, can be acheived using a variety of algorithms, one being Huffman Encoding which reduces the number of characters and makes efficient use of bit patterns.
Another technique that can be applied to both text and images is known as Run Length Encoding. In RLE, pixels or characters that are the same are encoded as a run instead of idividually. For example:
Uncompressed Text: HAAAHAAAHAAA
RLE: H1 A3 H1 A3 H1 A3
Try this for yourself be using the RLE generator below:
Type in some text with duplicate value, work out your RLE & check your result!
Find this page helpful? Share the love on your social media mentioning @TeachAllAboutIT and we’ll enter you in our monthly draw to win a gift voucher for any product on the site!
Looking For More?
Huffman Encoding is only required for students studying the AQA syllabus. This is a large part of the Data Compression area of the topic.
The Huffman Encoding & Data Compression Scribbl.it Notes provide a structured way for students to revise topic areas covered in class in a visual way. Encourage students to colour in areas of importance, add doodles and colour, then add more detail to the notes page being as creative as possible.
There are known benefits to using Scribbl.it Notes (whether structured like these, or independently created):
- Increased Attention
- Reduction of stress levels
- Increased memory for content
- Deeper learning
Scroll to the bottom to download
Hover over the flashcard to reveal the answer!