- [Craig] In this video, we explored the need for and types of compression.
There's a link here to Topic 1.5 System software,
where we consider utility software, with compression utilities being one example.
(uplifting piano jingle)
Compression essentially reduces the size of a file so it takes up less space on a storage device.
A typical use is your mobile phone
because you'll want to maximise the number of photos, videos and applications that can be stored on your device
in a limited amount of solid-state storage.
Compressing the images means more data and, therefore, more photos can be stored on your phone.
In addition, smaller file sizes are quicker to download and stream over networks such as the internet,
so this makes services for streaming music and video possible.
Often, compressed files must be uncompressed or extracted before they can be read.
In this video, we'll largely be focusing on images as an example but the principles equally apply to sound and, therefore, video as well.
In a previous video, we understood that the number of colours increased the file size
because the number of bits per pixel increased.
An obvious way of making the file size smaller is to store a lower number of colours
or perhaps to store bigger areas of pixels as one colour.
Both of these methods will affect the quality of the image stored and, therefore, this is known as lossy compression.
Algorithms such as JPEG and GIF, although very different, work a little like the two ways described.
With photographs and especially video, a little loss of quality might not be too noticeable and,
therefore, it is considered an acceptable compromise of quality versus file size and download time.
Here, we can see two images and it would be hard to tell that one is an original file and the other is compressed,
but it has a significantly lower file size.
Another approach is not to lose any data at all.
This is known as lossless compression, and it uses completely different algorithms.
For example, in our original image of a butterfly, we can see that there are large areas of white pixels.
Instead of storing every pixel with the same binary pattern, we could encode our data differently,
perhaps by storing the binary for the colour white
and then the number of white pixels in a row before the colour changes.
Encoding data in this way would reduce the file size
but would only be effective on images with large areas of continuous similar colours.
That makes it suitable for cartoons and clip arts
but ineffective with full colour photographs where there are few blocks of repeating colours.
It's important to realise that the type of data will also determine what types of compression can be used.
For example, with executable program files, we cannot afford to lose a single command in the program,
and therefore, only lossless compression will work - this is also true of documents.
It is really only with pictures, sound and video where lossy compression is applicable,
but it does usually give us the highest return in the file size reductions.
So, let's recap - compression reduces the number of bits in a file.
It makes the storage capacity of the file lower; it makes data transfer of the file quicker.
It's useful because more data can be stored on a storage device and transferred in a smaller amount of time.
There are two types of compression.
Lossy compression, where some of the data is lost and cannot be recovered.
This greatly reduces the file size, it reduces the quality of the image or sound
and is suitable for images, sound and video,
but it cannot be used on text and executable files.
Then we have lossless compression.
None of the data is lost; it is encoded completely differently.
You can, however, turn back to the original format, and it can therefore be used for all types of data.
It's usually less effective than lossy compression at reducing the file size,
and it's most suitable for documents and executable files.
(uplifting piano jingle)