Professional Documents
Culture Documents
20th Sept
20th Sept
1.3 Compression
Lossy compression
NOTE: Refer to the note on image file size calculation to see how reducing the number of colours works as
lossy compression.
Lossless compression
• Here we reduce the file size by encoding or representing the data in an alternative manner. We do
not remove any data.
B[8]
B[3]W[3]B[2]
W[2]K[2]B[4]
WK[5]B[2]
K[8]
• In the above example, the colours of the bitmap image are represented as:
◦ B = Blue
◦ W = White
◦ K = Black
• Instead of storing the actual pixels, we represent them as encoded values with the number of
iterations.
• For example, on line 4, it shows that we have 1 white, 5 blacks and 2 blues.
• This method of lossless compression is known as Run Length Encoding (RLE).
• Since nothing is removed during compression, we are able to recreate the original image.
• Thus lossless compression can be applied to any data such as documents, program code and images.
• In the past (around 35 years ago) lossless encoding was popular with facsimile (fax) transmissions.
This was extremely beneficial given that phone lines used to have very low bandwidth
(transmission speeds).
NOTE: RLE is one of the many different lossless compression methods. There are other, more efficient
algorithms for compression. Eg: Huffman encoding.