Compression Techniques PDF

Summary

This document details various types of compression techniques, including lossless and lossy compression. It explains why compression is important and provides scenarios where different types of compression might be used, such as compressing images for emails or source code. It also gives an example of RLE (Run Length Encoding).

Full Transcript

# Compression - Reduction of file size ## Why do we need to compress a file? - The data files are very large. - It would take a long time to send the non compressed file. - Compressed files will download faster. - A higher bandwidth would be needed to transmit the uncompressed file. - bandwidth =...

# Compression - Reduction of file size ## Why do we need to compress a file? - The data files are very large. - It would take a long time to send the non compressed file. - Compressed files will download faster. - A higher bandwidth would be needed to transmit the uncompressed file. - bandwidth = rate of data transfer. ## Types of Compression ### Lossless File Compression: - In this technique the data is not lost, and the compressed file can be decompressed as the original. ### Lossy File Compression: - In this technique the data is lost and the decompressed file is not same as the original. ## Application of Lossy and Lossless - **Lossy**: accuracy of data is not important, smaller file size needed, Lossy reduces file size more than Lossless - **Lossless**: accuracy of data is important ## Scenario Based Questions ### Question: Abdullah wants to compress the source code. Identify the most appropriate compression technique he should use. **Lossless** - In this technique data is not lost. - Any lost data will mean that program will not work. ### Question: Photograph is to be emailed to a friend. **Lossy** - All the data is not required. - The number of colors can be reduced without the user noticing. - Email requires a significantly smaller file size. - Takes a shorter time to transmit. **OR** **Lossless** - A high quality image may be needed. - All of the data is needed and cannot afford to lose any data. ## How an bitmap image can be compressed? ### RLE (Run Length Encoding) - Lossless compression **6) A black and white bitmap image is shown.** - **Color** | **Code** - Black | 1A - White | 3B - 3B9 | 1A3 | 3B3 | 1A2 | 3B1 | 1A2 - 3B2 | 1A1 | 3B3 | 1A1 | 3B2 | 1A2 - 3B1 | 1A2 | 3B3 | 1A3 | 3B9 **Explanation:** - Looks for runs of consecutive pixel of the same color. - Store the color value once and the number of times it occurs. - Lossless method of compression. - Reference to the given image (depends on the question).

Use Quizgecko on...
Browser
Browser