3.1.1

Compression

Test yourself

Types of Compression

Representing audio, images, and especially video take up a lot of secondary storage space. Compression helps to reduce the size of these files so that we can store more data.

Illustrative background for Lossy compressionIllustrative background for Lossy compression ?? "content

Lossy compression

  • An algorithm is applied to remove unnecessary detail from the original file.
  • Some data is permanently lost, but enough remains so that the file is still useful and there is barely a noticeable difference.
  • Lossy compression results in dramatic file size reduction.
Illustrative background for Lossless compressionIllustrative background for Lossless compression ?? "content

Lossless compression

  • None of the original data is lost.
  • An algorithm can be used to perfectly restore the original file when needed.
  • This is especially useful for executable files, where all of the data is necessary.
  • Lossless compression causes file size to reduce moderately.

Run Length Encoding

One compression algorithm you need to learn is run length encoding (RLE).

Illustrative background for Run length encodingIllustrative background for Run length encoding ?? "content

Run length encoding

  • Run length encoding (RLE) is a form of lossless compression that replaces repeating sequences of 0s and 1s with more efficient representations.
  • Each repeating string will be replaced by a code which represents the character and the amount of times it is to be repeated.
Illustrative background for In imagesIllustrative background for In images ?? "content

In images

  • In images, adjacent pixels are likely to be similar colours but slightly different.
  • Image compression algorithms often group these pixels together, and give them an 'average' colour.
  • The RLE algorithm can then run on the new image.
  • This technique then becomes lossy.

Dictionary Coding

Dictionary coding is used to store text in a lossless format.

Illustrative background for Dictionary codingIllustrative background for Dictionary coding ?? "content

Dictionary coding

  • The coder scans through a body of text.
  • Each word is replaced by the binary number of the word in a dictionary.
  • Each time it finds a new word which is not in its dictionary, it will add it to the dictionary and give it a binary number.
  • The word in the actual text is replaced with the binary number.
Illustrative background for Benefits of dictionary codingIllustrative background for Benefits of dictionary coding ?? "content

Benefits of dictionary coding

  • Dictionary coding is a type of compression. It takes less bits to store a 2 digit binary number than we can a 10 letter word.
  • No data is lost, so the coding is lossless.
  • The encoder may not always build its own dictionary. A pre-existing dictionary may be used to encode the text.

Jump to other topics

1Components of a Computer

2Software & Software Development

3Exchanging Data

4Data Types, Data Structures & Algorithms

5Legal, Moral, Cultural & Ethical Issues

6Elements of Computational Thinking

6.1Thinking Abstractly

6.2Thinking Procedurally

6.3Thinking Logically

7Problem Solving & Programming

8Algorithms

Go student ad image

Unlock your full potential with GoStudent tutoring

  • Affordable 1:1 tutoring from the comfort of your home

  • Tutors are matched to your specific learning needs

  • 30+ school subjects covered

Book a free trial lesson