1 / 26

Data Compression For Images

Data Compression For Images. Data compression or source coding is the process of encoding information using fewer bits (or other information-bearing units) than an unencoded representation would use through use of specific encoding schemes.

Download Presentation

Data Compression For Images

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Compression For Images

  2. Data compression or source coding is the process of encoding information using fewer bits (or other information-bearing units) than an unencoded representation would use through use of specific encoding schemes. • One popular instance of compression with which many computer users are familiar is the ZIP file format, which, as well as providing compression, acts as an archiver, storing many files in a single output file.

  3. As is the case with any form of communication, compressed data communication only works when both the sender and receiver of the information understand the encoding scheme. For example, this text makes sense only if the receiver understands that it is intended to be interpreted as characters representing the English language. Similarly, compressed data can only be understood if the decoding method is known by the receiver.

  4. Why Data Compression? Graphical images in bitmap format take a lot of memory – e.g. For 3 Byte image the size (1024 x 768)pixels x 24 bits-per-pixel = 18,874,368 bits, or 2.4Mbytes. • But 120 Gbyte disks are now readily available!! • So why do we need to compress? • How long did that graphics-intensive web page take to download over your 56kbps modem?

  5. • How many images could your digital camera hold? – Picture messaging? • CD (650Mb) can only hold less than 10 seconds of uncompressed video (and DVD only a few minutes) • We need to make graphical image data as small as possible for many applications

  6. Types of Compression • Pixel packing • RLE (Run-length Encoding) • Dictionary-based methods • JPEG compression • Fractal Image Compression

  7. Some factors to look out for: • Lossy or lossless compression? • What sort of data is a method good at compressing? • What is its compression ratio?

  8. 1. Pixel Packing • Not a standard “data compression technique” but nevertheless a way of not wasting space in pixel data • e.g. – suppose pixels can take grey values from 0-15 – each pixel requires half a byte – but computers prefer to deal with bytes – two pixels per byte doesn’t waste space • Pixel packing is simply ensuring no bits are wasted in the pixel data • (Lossless if assumption true)

  9. 2. Run-length encoding (RLE) • is a very simple form of data compression in which runs of data (that is, sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run. This is most useful on data that contains many such runs: for example, simple graphic images such as icons and line drawings.

  10. For example, consider a screen containing plain black text on a solid white background. There will be many long runs of white pixels in the blank space, and many short runs of black pixels within the text. Let us take a hypothetical single scan line, with B representing a black pixel and W representing white: • WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW

  11. If we apply the run-length encoding (RLE) data compression algorithm to the above hypothetical scan line, we get the following: 12WB12W3B24WB14W • Interpret this as twelve W's, one B, twelve W's, three B's, etc. Another example is this: • AAAAAAAAAAAAAAA would encode as 15A • AAAAAAbbbXXXXXt would encode as 6A3b5X1t So this compression method is good for compressing large expanses of the same color.

  12. RLE compression ratio Consider a small 10 × 11 pixel block taken from image: • Of the 110 pixels in this 10 × 11 pixels sample taken from the image, there are 59 different colors altogether!

  13. • RLE compression ratios not good in general, because there are rarely repeat runs of pixels. Full image: 371 × 247 bitmap , (274911 = 371 × 247 × 3) bytes = 275Kb raw data While it is 91K RLE encoded Compression ratio approx 3:1 in this case

  14. RLE compression ratio • Another example, with a diagram this time Full image: 350 × 264 bitmap 277Kb raw data (277200 = 350 × 264 × 3) bytes 46.5K RLE encoded Compression ratio approx 6:1 in this case

  15. 3. Dictionary Methods • A dictionary, also sometimes known as a substitution coder, is any of a number of lossless data compression algorithms which operate by searching for matches between the text to be compressed and a set of strings contained in a data structure (called the 'dictionary') maintained by the encoder. When the encoder finds such a match, it substitutes a reference to the string's position in the data structure.

  16. • A common way to compress data (pixels, characters, whatever!) is to use a dictionary • The dictionary contains strings of bytes – e.g. particular pixel patterns – not limited to patterns of one color, as with RLE • Data is encoded by replacing each data string that has an entry in the dictionary with its index number in the dictionary. • Shorter to write an index number than a whole string! • Dictionary may be particular to the image, or may be “standard” for particular image types

  17. 3.1 Patterns of Pixels • Poor results with RLE as runs of pixels with same color are very short • But there are repeating patterns with two colors that could be included in a dictionary • Hence, could replace each byte pattern with a pointer to it (or its index number in the dictionary)

  18. 3.2 Huffman and CCITT Compression • Developed for fax machines and document scanners • Uses a predefined dictionary of commonly occurring byte patterns from B&W documents containing large amounts of text in a variety of languages and typical examples of line art • Commonly occurring patterns are given low (short) indices (codes) in the dictionary • Data is encoded by replacing each image string that occurs in the dictionary with its index number • Dictionary is not part of the compressed file.

  19. 3.3 The Lempel-Ziv-Welch Algorithm • The Lempel-Ziv-Welch method is another such dictionary algorithm, in which the dictionary is constructed as the encoding (compression) progresses. – (actually Ziv was the first author on the original papers!) • LZW starts with a dictionary of byte strings: – Entries 0-255 refer to those individual bytes – Entries 256 onwards will be defined as the algorithm progresses • Each time a new code is generated it means a new string of bytes has been found. • New strings are generated by appending a byte (c) to the end of an existing string (w). – see algorithm on next slide

  20. The LZW Algorithm set w = “ ”; while (not EOF) read a character c; if w+c exists in the dictionary w = w+c; else { output the code for w; add w+c to the dictionary; w = c; } endwhile

  21. When Is LZW Useful? • Good for encoding pixel data with a limited palette, and/or repetitive data – line drawings – diagrams – plain text on a plain background • Not good for photographic images – large color range and complex features results in few repeating patterns to include in a dictionary

  22. JPEG • Joint Photographic Experts Group • Designed to compress photographs – color or grayscales – good at compressing “real” scenes – not good for line drawings, diagrams, lettering, cartoons • Designed for human viewing, exploits our inability to see a full range of colors – Lossy algorithm – Not good for computer analysis of data • e.g. computer analysis for medical imaging • Edge finding

  23. 4. JPEG Compression • For full-color images, the best-known lossless compression about 2:1 • For reasonable quality, compression ratios of 10:1 or 20:1 quite feasible for JPEGs – Clive’s picture compressed with a ratio of 15:1 • For poor quality images (thumbnails?), 100:1 possible • Re-encoding loses more information

  24. 5. Fractal Compression • Fractal compression is a lossy compression method used to compress images using fractals. The method is best suited for photographs of natural scenes (trees, mountains, ferns, clouds). The fractal compression technique relies on the fact that in certain images, parts of the image resemble other parts of the same image.

  25. Fractal compression appeared to be a promising technology in the late 1980s, when in some circumstances it appeared to compress much better than JPEG, its main competitor at that time. • However, fractal compression never achieved widespread use. Fractal compression is much, much slower to compress and much slower to decompress than JPEG. Furthermore, its patents were not widely licensed. Also, the improved compression ratio is an illusion.

  26. Fractal compression only has a large advantage over JPEG at low image quality levels, which is usually undesirable. The claim that fractal compressed images, when enlarged beyond their original size, looked better than similarly enlarged JPEG images seems also to have been an irrelevant distinction.

More Related