Compression PDF
Document Details
![SpotlessZircon8041](https://quizgecko.com/images/avatars/avatar-11.webp)
Uploaded by SpotlessZircon8041
Tags
Summary
This document covers various compression techniques. It details lossy and lossless compression methods, and their applications in different scenarios, including compressing images, audio files, and text files. A number of examples are shown along with explanation.
Full Transcript
# Compression ## 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 compressed file // compressed files will download faster - A higher bandwidth would be needed to transmit the uncompressed file...
# Compression ## 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 compressed file // compressed files will download faster - A higher bandwidth would be needed to transmit the uncompressed file ## 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 the program will not work. **Question:** A 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. - **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. | Colour | Code | |---|---| | Black | 1A | | White | 3B | ## 3B9 1A3 3B3 1A2 3B1 1A2 3B2 1A1 3B3 1A1 3B2 1A2 3B1 1A2 3B3 1A3 3B9 ## Explaination: - Looks for runs of consecutive pixels of the same colour - 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) ## JPEG - lossy Compression - Removes the parts of image which are not noticeable to human eye - **Crop:** removes pixels => lossy compression - **RLE:** stores color code and count of repetition => lossless compression. - **JPEG:** removes part of images which are ignored by human eye => lossy compression. - **Fewer Colors:** uses fewer bits per pixel => lossy compression ## Describe lossy methods that can be used to compress The image - **Reduces Bit depth:** - reduces the number of bits per pixel which means each pixel has fewer bits. - **Reduce number of colors:** - fewer colors means fewer bits needed to store each color. - **Reduce image resolution:** - fewer pixels per unit measurement means less binary to store. ## How a vector image can be compressed? - By using .svg (Scalable vector graphic) which are defined in XML text files which allows them to be compressed ## How a sound can be compressed? - MP3 uses technology known as audio compression - Sound file can be compressed by using the perceptual music shaping algorithm ## Perceptual Music shaping removes certain sounds - (lossy Compression) - Frequencies that are outside the human hearing range (20 Hz to 20000 Hz) - If two sounds are played at the same time, only the louder one can be heard. - By the ear, so the softer sound is removed. ## Describe lossy methods that can be used to compress a sound? (Not from Marking Scheme) - **Reduce Sampling resolution:** - reduces the number of bits per sample which means each sample has fewer bits. - **Reduce Sampling rate:** - reduces the number of samples per unit time which means less bits to store. - **Perceptual Music Shaping:** - removing parts of sound which are not noticeable to human ear ## (c) When storing music tracks in a computer, the MP3 format is often used. This reduces file size by about 90%. Explain how the music quality is apparently retained. - MP3 is a lossy compressed format - uses psycho-acoustic modelling - and perceptual music shaping - removes sounds that the human ear can't hear - only keeps sounds human ear can hear better than others - discards softer sound if two sounds played together. ## How a text file can be compressed? - **RLE** - a a a a a a a a b b bb bb bbcccccc - ASCII a - 97 b - 98 c - 99 - 05 97 08 98 06 99