Lesson video

In progress...

Loading...

Hello, I'm Dr.

Das.

Welcome to Computing.

I'm so pleased that you have decided to join me for this lesson Today.

In this lesson, we will be looking at lossy and lossless.

Welcome to today's lesson from the unit, data compression.

This lesson is called lossy and lossless compression.

By the end of today's lesson, you'll be able to compare lossy and lossless compression.

Some of the key words that we will be using in today's lesson include lossy.

Lossy, a compression method where data is permanently lost during the process.

Lossless.

Lossless, a compression method where no data is permanently lost during the process.

Quality.

Quality, how good, reliable, or suitable something is for its intended purpose.

This lesson is divided into three parts.

Describe lossy compression, describe lossless compression, and compare lossy and lossless compression.

Let's start by looking at what lossy compression is.

A photographer has taken 925 photos of a wedding event.

Assuming each photo is 25 megabytes, MB, what is the total size of the wedding photos in gigabytes, GB? Let's see how we can work this one out.

First, you calculate the total size of the files in megabytes, so 925 times 25, so 925 wedding photos times 25 megabytes, which is the size of each photo, will give us 23,125 megabytes of data.

This means the total size of the photo files is 23,125 megabytes.

Next, convert the answer into gigabytes using the fact that there are a thousand megabytes in one gigabyte.

So 23,125 divided by 1000 gives you 23.

125 gigabytes.

So the total size of the photo files in gigabytes is 23.

125 gigabytes.

The size of files can vary greatly depending on the type and contents of the file.

A small text file might contain only a few kilobytes of data.

A large high resolution video file might contain hundreds of gigabytes of data.

Data compression is the process of reducing the size of a file.

To compress a file, compression algorithms are used.

Data compression algorithms work by removing unnecessary data or rearranging information more efficiently.

There are a number of advantages to using data compression, such as a reduction in the space needed to store files locally or in the cloud, less bandwidth usage when transferring data on a network, and faster uploading and downloading times to reduce latency.

Algorithms, which are just sequences of steps, are used to reduce the number of bits required for each file.

So if you look at this image here, if the original file has that much information in it, after using a compression algorithm it would have reduced considerably in size, so the final image shows you a rough indication of what the size of the compressed file will be.

These algorithms, these algorithms that are used to change the size of a file from a much larger size to a smaller size, these algorithms are called compression algorithms. Once a file is compressed, it can be saved and moved around in this form.

However, to be accessed again or used in some way, it must be decompressed, so it must be brought back to its original form.

A decompression algorithm is used to recreate a version of the file.

So compressed file after being worked on by a decompression algorithm would look like a file that can be easily accessed.

Notice the change in size before and after the decompression algorithm has been used.

There are two categories of compression algorithms that can be used, lossy compression and lossless compression.

The choice of compression method will depend on factors like need for data accuracy, the acceptable level of quality loss, and the importance of reducing file size.

Lossy compression always results in loss of data as the name suggests.

A decompressed file that uses lossy compression will never be the exact copy of the original.

This is because lossy compression algorithms permanently delete data from the file to aid with compression.

A decompressed file will only be an approximation of the original image.

For example, if you look at this bitmap image, a bitmap image has a map of every single pixel in the image.

Each pixel has its own binary bit pattern to represent an individual colour.

This image was originally a bitmap image with a file size of 1.

53 MB.

The bitmap image can be compressed using a lossy compression algorithm.

A common lossy compression algorithm for images is the JPEG, the J-P-E-G compression algorithm.

This results in the creation of a JPEG image file.

By using JPEG lossy compression, the size of the file is reduced from 1.

53 megabytes to 252 kilobytes.

That's a quite a huge reduction in the size of the file.

The pictures look very similar to the human eye, even though the file size has been greatly reduced.

Right.

Let's do a quick check.

Which algorithm is used to recreate a version of the original file? You've been given three options.

Why don't you pause the video here and have a quick think.

The correct answer is B, decompression.

So decompression algorithms are used to recreate a version of the original file.

Well done.

Another quick check.

Lossy compression methods always permanently remove data from a file.

What do you think? Is the statement true or is it false? Why don't you pause the video again and have a think about it.

Try and work this out.

I'm sure you'll be able to.

The correct answer is true.

Well done.

Because we know that lossy compression methods always remove data from a file.

That is why they are lossy, they are called lossy compression algorithms, and of course, the final image, the final file that is created will have some information that is missing from the original file.

Really well done.

The JPEG lossy compression algorithm takes advantage of the colour similarities between the pixels of an image.

With standard settings, a single colour is recorded for every pack of nine pixels.

This means fewer colour codes need to be stored.

This can reduce the file size by around 90%.

When the image is decompressed, the missing pixels are recreated using the colours that remain.

By taking the colours on either side of a missing pixel, the lost data can be recreated.

It is important to note that many other lossy compression algorithms are used to reduce file size.

For example, MP3 and AAC can be used to reduce the size of audio files.

MP4 and HEVC can be used to reduce the size of video files.

In most cases, the aim of using a lossy compression algorithm is to reduce file size while keeping the file content usable and of good quality.

Right.

This brings us to the end of this section.

Just to make sure that you have understood what we've covered in this section, why don't you attempt this task? Task A asks you to write a paragraph to describe lossy data compression in your own words.

Pause the video here and try and work this out.

I'm sure you'll be able to.

Do look through if you need to, but I'm sure you'll be able to work this one out.

Let's see what the description should be.

Lossy compression is used to reduce the size of a file by permanently deleting some of its data.

Lossy compression reduces the size of files by getting rid of parts that are considered less important or that humans are unlikely to notice.

However, because some parts of the original data file are deleted during compression, it is never possible to get the original file back exactly as it was.

Really well done on attempting this task.

Let's move on.

The next section looks at describing lossless compression.

Lossless compression, as the name suggests, results in no loss of data.

This is particularly important for files where the data must be exactly the same.

Text files need to use lossless compression because it is important that any letters or words are not lost during the compression process.

When a file has been compressed using a lossless compression algorithm, it can be restored back to the original version of the file.

This is because none of the data gets removed in the process of the compression.

Lossless compression is used when accuracy and detail are important.

A common lossless compression file type is PNG.

This stands for Portable Network Graphic.

The PNG file type is used with images that must retain the highest quality during transfer.

It is also often used in the design industry because of its ability to have transparent pixels.

Now, if you look at this image, this image has been compressed into the PNG file type.

By placing a dark background colour behind the image, you can see that the icon is surrounded by transparent pixels.

If the image had been compressed into JPEG format, the icon would be surrounded by white pixels.

This can look unprofessional and badly designed, especially when used in print or digital media.

Now, if you look at this image file, the original file size of this bitmap image before compression was 36.

9 megabytes.

After lossless compression into PNG format, the file size is now 10.

5 megabytes.

This is roughly a third of the original file size.

A PNG file preserves image quality and detail exactly without removing any data during compression.

It is important to note that many other lossless compression algorithms are used to reduce file size.

Zip files use lossless compression to compress multiple files into a single file.

The zip folder can then be decompressed and the original files retrieved exactly as they were before compression was applied.

Text files must also use lossless compression.

Text files use lossless compression, this is because it is important that no data is removed when a text file is compressed.

Every single character matters in a text file and each character must be preserved exactly for the file to remain correct and usable.

Okay, that brings us to a check.

Lossless compression preserves the quality and exact details contained in the original file.

What do you think? Is the statement true or is it false? Pause the video here and have a quick think.

The correct answer is true.

Well done on getting that right.

Another quick check.

Which file format is an example of lossless compression? You've been given three options.

Pause the video again and try and work this out.

I'm sure you'll be able to.

The correct answer is option B, PNG.

PNG is a form of lossless compression.

Well done on getting that right.

You've been doing brilliantly.

Let's move on.

Before we carry on to the next section, why don't you attempt this task just to make sure that you have understood what we've covered in this section? Task B asks you to write a paragraph to describe lossless compression in your own words.

Pause the video here and work this one out.

Look through the previous slides if you need to, but I'm sure you'll be able to come up with the answer.

Lossless compression is used when you want to reduce the size of a file but keep the exact details of the original uncompressed file.

For example, compressing a BMP image into a PNG file preserves the image quality and keeps the detail exactly as it was before compression.

A text file should be compressed with lossless compression because you will need to access every text character in the right order after decompression.

Any file compressed with a lossless method can be decompressed back to its original form with no data loss.

Well done on working through this task.

Let's move on.

This brings us to the final section where you will look at comparing lossy and lossless compression.

Let's start by matching the words to the following file formats.

JPEG is an example of a lossy compression technique.

PNG is the file format that we obtain after a lossless compression.

And BMP is an example of an uncompressed file format.

There are key differences between the features of lossy and lossless compression.

When choosing between lossy and lossless compression, you need to consider a number of factors such as file size, file quality, and original data preservation.

It is usually possible to adjust the amount of compression with both lossy and lossless methods.

However, in general, a lossy compression method compresses files to a much smaller size than a lossless compression method.

So lossy will give you smaller compressed file size, and lossless will give you a larger compressed file size.

It's also important to consider the quality of the file after compression.

If the file needs to be perfectly preserved, lossless compression should be used.

If a slight reduction in quality is acceptable for a smaller file size, lossy compression should be considered.

So lossy may reduce quality, Lossless gives you the original quality, or it preserves the quality of the file that you are compressing.

If maintaining all the data in a file is important, then lossless compression should be chosen.

With lossless compression no information is lost during the compression process.

In contrast with lossy compression, some of the original file information is deleted and lost during the compression process.

Okay, time for a quick check.

Files compressed into a lossless format are generally smaller in size than lossy format.

What do you think? Is this statement true or is it false? Pause the video here and try and work this out.

The correct answer is false.

Why? Because in general, lossy compresses files to a much smaller size than lossless.

Well done.

Another check.

Which of the following statements are correct about a file compressed into a lossy format? You've been given three options.

Pause the video here and try and work this one out.

I'm sure you'll be able to.

The correct answer is option B.

So with a lossy format some original data is deleted to reduce file size.

Really well done.

A table can be used to help compare some features of lossy and lossless compression.

So if you look at this table and to compare lossy and lossless in terms of the amount of data that is left behind, so is data removed in lossy, yes, in lossless, no.

How about the file size? Lossy gives you a smaller file size, lossless gives you a larger file size.

In terms of the quality of the file that you're getting after the compression algorithm is being used, lossy may reduce the quality, lossless preserves the quality.

Is it reversible to original? With lossy, not fully, but with lossless, yes, 100%.

Finally, the example formats, lossy compression example formats are JPEG, MP3, MP4.

So JPEG for images, MP3 for audio files, and MP4 for video files.

Lossless compression example formats are PNG, so for image files, PNG can be used, or zip to combine multiple files together into a single file.

This brings us two task C.

Just to make sure that you have understood what we have covered in this section, why don't you attempt this task? Here Sophia says, "I've taken five high-quality photos of sports day.

The most popular photo will be printed onto a very large canvas and displayed in the school hall.

I'm not sure whether the photo should be compressed using lossy or lossless compression." What do you think? This task has two parts, part one asks you to write a paragraph comparing some of the features of lossy and lossless compression for photos, and part two asks you to suggest a suitable compression format for Sophia.

Pause the video here and try and work these two parts out.

You've been working so hard and doing so well, I'm sure you'll be able to work these out.

Let's look at the answers for each of these parts.

So the first part asked you to write a paragraph comparing some features of lossy and lossless compression for photos.

Lossy compression, like JPEG, permanently removes some image data to make the size much smaller.

This is useful for saving storage space or uploading images online.

The loss in quality is often hard to notice, especially with small images on a screen.

Lossless compression like PNG keeps all the original data, meaning that the image can be restored perfectly without any quality loss.

This is better when image detail matters, such as when storing large high-quality images.

However, lossless files are usually larger than lossy ones.

So, the choice depends on whether you need smaller file sizes or perfect image quality.

Well done, I'm sure you came up with something similar.

Part two, where you had to suggest a suitable compression format for Sophia.

Because the most popular photo will be printed onto a very large canvas and Sophia only has a small amount of photos, you could have suggested that she uses lossless compression.

A format such as PNG in order to reduce the size of the photos.

This would still reduce the size of the files by about a third, but a PNG format has the advantage that the images could be decompressed back to the perfect original photos.

If Sophia compressed the photos using a lossy format such as JPEG, she would permanently lose the quality of the originals.

Also, the loss in image quality might be noticeable on a very large canvas printout.

Well done on attempting this task and well done on completing all three sections.

This brings us to the summary.

Let's summarise what we have learned in this lesson.

Data compression is either lossy or lossless.

Lossy data compression permanently removes some data to reduce file size.

Lossless compression on the other hand, reduces file size without losing any data.

The choice of compression depends on file type, quality needs, and storage limitations.