Algorithms :: Imaging :: Jpg and Gif compression |
|||
| By: collegeBoy |
Date: 28/07/2003 00:00:00 |
Points: 50 | Status: Answered Quality : Excellent |
|
I need an overview of how jpg and gif compression work. |
|||
| By: VGR | Date: 28/07/2003 06:39:00 | Type : Answer |
|
| here's your overview : <A HREF="http://www.widearea.co.uk/designer/compress.html">http://www.widearea.co.uk/designer/compress.html</a> GIF, which stands for Graphics Interchange Format, is a lossless method of compression. All that means is that when the program that creates a GIF squashes the original image down it takes care not to lose any data. It uses a simple substitution method of compression. If the algorithm comes across several parts of the image that are the same, say a sequence of digits like this, 1 2 3 4 5, 1 2 3 4 5, 1 2 3 4 5, it makes the number 1 stand for the sequence 1 2 3 4 5 so that you could render the same sequence 1 1 1, obviously saving a lot of space. It stores the key to this (1 = 1 2 3 4 5) in a hash table, which is attached to the image so that the decoding program can unscramble it. The maximum compression available with a GIF therefore depends on the amount of repetition there is in an image. A flat colour will compress well - sometimes even down to one tenth of the original file size - while a complex, non-repetitive image will fare worse, perhaps only saving 20% or so. There are problems with GIFs. One is that they are limited to a palette of 256 colours or less. Compuserve, which created the GIF, did at one point say it would attempt to produce a 24-bit version of the GIF, but then along came problem number two: Unisys. Unisys discovered that it owned some patents to key parts of the GIF compression technology, and has started demanding fees from every company whose software uses the (freely available) GIF code. This has somewhat stifled development. There is a 24-bit, license-free GIFalike called the PNG format, but this has yet to take off. JPEG JPEG, on the other hand, is a lossy compression method. In other words, to save space it just throws away parts of an image. Obviously you can't just go around discarding any old piece of information so what the JPEG algorithm does is first divide the image into squares (you can see these squares on badly-compressed JPEGs). Then it uses a piece of mathematics called Discrete Cosine Transformation to turn the square of data into a set of curves, some small, some big, that go together to make up the image. This is where the lossy bit comes in: depending on how much you want to compress the image the algorithm throws away the less significant part of the data (the smaller curves) which adds less to the overall "shape" of the image. This means that, unlike GIF, you get a say in how much you want to compress an image by. However the lossy compression method can generate artifacts - unwanted effects such as false colour and blockiness - if not used carefully. |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








