Lossless Compression
In this lesson, you will get a brief introduction to lossless compression techniques.
Lossless compression
Unlike lossy compression, lossless compression does not delete or distort any information. There are a few common lossless compression algorithms applied to text and images. Let’s look at them one by one.
The run-length coding technique
The run-length coding technique can be applied to images and text files. It adds a few extra bits in the metadata of the original file that provide information about a group of data with the same value. For example, an image with 13 neighbouring pixels “5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5” could be conveniently represented as “5, 13”.
Figure 2 shows a grayscale image of 320 320 pixels. Observe that the neighbouring pixels in most cases have the same grayscale values. So let’s talk about the first row pixels, where the first 135 pixels have the same value. Originally, the image required 24 135 = 3240 bits to store the first 135 pixels. After applying the run-length coding technique, we provided one byte to represent the number of pixels ...