How does image compression work?

Shalmanese

Platinum Member
Sep 29, 2000
2,157
0
0
well, basically, instead of saying black, black, black, black, black...

you can just say then next 100 pixels are black and save a lot of space. Obviously thats pretty simplified :)
 

Burnsy

Member
Dec 30, 2001
90
0
0
It really depends on the type of compression you're talking about.

Lossless image compression is the method described above by shalmanese

Lossy image compression is the same except some data is thrown away. There is a loss in quality(most times it is not noticeable) so that the file sizes can be smaller.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81


<< well, basically, instead of saying black, black, black, black, black...

you can just say then next 100 pixels are black and save a lot of space. Obviously thats pretty simplified :)
>>


PCXs and GIFs do this. you dont see PCXs around much any more though. its called run-length encoding. it works very well for stuff like logos or simple graphics. It usually works very very poorly for photos. JPGs are "lossy" - there is a quality loss, but if you do it right, the image still comes out looking good. I don't know how exactly JPGs do their magic.
 

crypticlogin

Diamond Member
Feb 6, 2001
4,047
0
0
The best place for information is almost always the consortium or body created to oversee the standard, e.g. the JPEG consortium page. From there, there's a bunch of links to FAQs, source code, and who shot JFK.

Well, maybe not the last part but section [74] of this compression FAQ gives a really brief overview of what's involved with compression in JPEG. That FAQ series also contains some info about other compression schemes.
 

StandardCell

Senior member
Sep 2, 2001
312
0
0
Just to add to what's already been said, there are two main types of lossy compression. One, like JPEG and MPEG-1/2, is based on something called the Inverse Cosine transform. Cosine transforms break an image down into small blocks (e.g. 5x5 pixels), and basically creates a concise mapping of the color and shapes contained in that block (and, in the case of motion, stores the intermediate changes between reference frames). The small blocks are apparent when there is noise in the signal of a picture or video signal - it gets blocky and multicolored. The other, which JPEG-2000 and MPEG-4 use, is Wavelet transforms. A wavelet is a complex function that basically mimics the type of shapes and colors through a mapping. Different wavelets are better at compressing different types of video and audio.