Presentation is loading. Please wait.

Presentation is loading. Please wait.

Topic 3: Data Compression.

Similar presentations


Presentation on theme: "Topic 3: Data Compression."— Presentation transcript:

1 Topic 3: Data Compression

2 Example: Full HD Image (1920x1080), with a 32-bit colour depth
Compression Saving high-quality data in their raw format can be quite memory costly Saving an image with lots of pixels/high colour depth Saving an audio file with a high bitrate So, we need to work out a way of reducing memory size, but keeping most of the data’s quality Example: Full HD Image (1920x1080), with a 32-bit colour depth Memory Size: 8.294MB

3 Compression This is where compression comes in
Compression tries to reduce memory size while keeping data quality There are lots of compression techniques, but they fall into two categories Lossy: some quality is lost Lossless: no quality is lost

4 Compression Lossless Compression
Maintains data quality in its entirety So no data is lost at all Can still reduce overall memory size Though doesn’t have the biggest impact

5 Compression Lossless Compression
Best used on data that we want to maintain entirely Especially if the data is used on a computer Computers can use pictures to train themselves to detect objects and people! For something like this, lossless compression would work best (as the computer will need all the original data).

6 Compression Lossless Compression
There are a few lossless compression techniques Run-Length Encoding: Used in PDFs Huffman Coding: Used for lots of things (including PNGs) Lempel-Ziv-Welch: Used for GIFs You only need to know Run-Length Encoding, not the others

7 Compression Lossy Compression Will reduce or destroy data quality
Meaning data can be lost Reduces overall memory size quite a lot Far better at it than lossless compression

8 Compression Lossy Compression Best used for any user-consumed data
Images people will look at Audio that people will listen to Humans don’t tend to pick up on fine detail loss that lossy compression can result in It’s often preferred to use lossy compression on images, audio, and video as humans won’t see the loss in detail, and the gain in decreased memory size is very worth it

9 Compression Lossy Compression
There are a few lossy compression techniques as well MP3: Used in MP3 files (audio) JPEG: Used in JPG files (images) MPEG-4: Used in MP4 files (video) Lossy compression techniques tend to be tied to file formats

10 Storing an image with the following colours:
Run-Length Encoding There are different versions of Run-Length Encoding Simplest method does the following Storing an image with the following colours: rrrrbbgg bbbggggg rrrrrrrr We can compress that to: (4, r) (2, b) (2, g) (3, b) (5, g) (8, r)

11 Storing an image with the following colours:
Run-Length Encoding For every series of repeating values, we Write the number of repeats first Then write the value that is being repeated Storing an image with the following colours: rrrrbbgg bbbggggg rrrrrrrr We can compress that to: (4, r) (2, b) (2, g) (3, b) (5, g) (8, r)

12 Storing an image with the following colours:
Run-Length Encoding If a colour takes 3 bytes, we can compress: 10 repeating colours (30 bytes) Into 1 number (1 byte) and 1 colour (3 bytes) Storing an image with the following colours: rrrrbbgg bbbggggg rrrrrrrr We can compress that to: (4, r) (2, b) (2, g) (3, b) (5, g) (8, r)

13 Perform the Run-Length Compression technique on the following strings
aaaaaaaaaabbbbbbbbbbccccccbbbbb bbbbbbbbbbbccccccaaaacccaaacccccc bbbcccccbbbbaaaaaaccccbbbbaaacccc ANSWERS From top-left to bottom-right: (10, a) (10, b) (6, c) (5, b) (11, b) (6, c) (4, a) (3, c) (3, a) (6, c) (3, b) (5, c) (4, b) (6, a) (4, c) (4, b) (3, a) (4, c)

14


Download ppt "Topic 3: Data Compression."

Similar presentations


Ads by Google