Compression
Why use compression?
Originally to save space when saving files to a disk.
In today's modern world compression is now done to reduce data sent over a network which needs
to be done for many reasons.
Lossy Compression
Lossy compression works by removing non-essential pieces of information.
The result as shown here is a blocky and untidy image. However, our ability to identify the subject of
the image is not impeded.
The only downside is the quality.
Lossless compression
Records patterns in data rather than data itself. Using these patterns and instructions on how to use
them the computer can reverse the procedure.
Run Length Encoding (Lossless)
Run length encoding relies on reducing repeating block of the same data to the item of data and a
number representing the number of items of that data
AAABBBBBBBBAAA – could be represented as A3B8A3
As long as the space needed to encode the repetition number is less than that of the original data
the compressed file will be smaller.
Runs of pixels of similar colour are often used as examples of this
We might need 3 bytes to store the exact colour blue.... and therefore if we stored 5 of these we
would have 15 bytes of info. If instead of this the 3 colour bytes were always followed by a length
byte we could compress the blue pixels down to 4 bytes of data.
Dictionary based compression
A dictionary is built that maps sequences of strings in the text onto values ;
the (sequences of) strings in the text are then replaced by the corresponding values in the
dictionary;
Why use compression?
Originally to save space when saving files to a disk.
In today's modern world compression is now done to reduce data sent over a network which needs
to be done for many reasons.
Lossy Compression
Lossy compression works by removing non-essential pieces of information.
The result as shown here is a blocky and untidy image. However, our ability to identify the subject of
the image is not impeded.
The only downside is the quality.
Lossless compression
Records patterns in data rather than data itself. Using these patterns and instructions on how to use
them the computer can reverse the procedure.
Run Length Encoding (Lossless)
Run length encoding relies on reducing repeating block of the same data to the item of data and a
number representing the number of items of that data
AAABBBBBBBBAAA – could be represented as A3B8A3
As long as the space needed to encode the repetition number is less than that of the original data
the compressed file will be smaller.
Runs of pixels of similar colour are often used as examples of this
We might need 3 bytes to store the exact colour blue.... and therefore if we stored 5 of these we
would have 15 bytes of info. If instead of this the 3 colour bytes were always followed by a length
byte we could compress the blue pixels down to 4 bytes of data.
Dictionary based compression
A dictionary is built that maps sequences of strings in the text onto values ;
the (sequences of) strings in the text are then replaced by the corresponding values in the
dictionary;