Compression Techniques

When a file is saved it has to be compressed so when the file is opened the data is received. Compression techniques are methods to reduce the size of a file so it's small enough to be stored on a disk or network. There are two main categories of compression techniques; lossy and lossless. They both use different methods but have the same aim- to remove unnecessary data of a file so it is small enough to be stored. They also make no or little difference to the original file.

Lossy compression is a method where data that isn't needed is removed permanently; it discards information that won't be seen anyway. For example, if there is an image file that has the same pixels repeated, it will discard some of them as they won't be necessary if there are others that are the same.
It is best used for media files that will work even if some of the data isn't there. These media files include audio, video, image and screen design graphics.
The advantage of lossy compression is that it is complex so things like bitmap images will have better results because it will arrange all those parts together.
The removed data is not noticeable so it doesn't ruin the file. This is because it's only data that is repeated anyway.
The file size is reduced so you won't have used up lots of space when storing it. "A typical lossless compression can be expected to cut file sizes down to three quarters or two thirds of the original." (http://www.jiscdigitalmedia.ac.uk/guide/file-formats-and-compression/#compression)
The disadvantage of lossy compression is the fact that it doesn't keep all the information because it's permanently removed. Therefore, the original data is not received and you can't get that original data back. This could result in problems like image files having poor quality.
Once it has been compressed, it carries on being compressed every time it is re-opened and closed.
Flowchart showing lossy compression
Source from http://www.sqa.org.uk/e-learning/BitVect01CD/page_86.htm
Lossless compression is a method like lossy, apart from the fact it doesn't permanently remove the data. It removes repeated data until the file is re-opened again so the file size is smaller.
It mainly uses formats like GIF, TIFF, RLE and PNG. For example, web or multimedia files would be in a GIF format.
It is usually used for graphics, spread sheets, texts and software otherwise text would be missing if it had completely removed the data like lossy compression would.
The advantage of lossless compression is that it maintains the quality of all the files because the original data is always re-opened.
The disadvantage is that it doesn't reduce file size as much as lossy compression does because it still has most of the data there. This means it wouldn't be as good for photos or illustrations as lossy compression would be because it still keeps all the data of the images so it will still be a large file size.
Graphic representing compression and decompression
Source from http://www.sqa.org.uk/e-learning/BitVect01CD/page_84.htm
I used lossy compression by creating a drawing on Paint and saving it as a '.JPEG' file (which is a lossy compression file format).
I then re-saved the same drawing as a '.PNG' file (which is a lossless compression file).

When I looked at the file sizes, I could see that the '.PNG' file was much larger than the '.JPEG' file which proves that lossless compression doesn't reduce the file size as much as lossy compression.



No comments:

Post a Comment