Lossy? Lossless? 256 colors? This is confusing!

Frequently Asked Questions regarding XnView (including Answers)

Moderators: XnTriq, helmut, xnview

User avatar
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Lossy? Lossless? 256 colors? This is confusing!

Post by Drahken »

This is to provide some answers about lossy vs lossles, color reduction, and dithering.

Some formats, such as JPG, JNG, and lossy JP2 are "lossy". This means that they throw away some data every time you save the image. How much they throw away depends on the quality setting you choose. Usually this lost data isn't visible to the human eye, but it is visible on certain images, and can become visible if you re-save the same image in a lossy format too often.

Some formats such as BMP, Truecolor PNG, Lossless JP2, and TIFF are absolutely lossless. This means that every bit of data that was in the original image will always be there, unless you edit it out yourself. The drawback is the massive filesizes.

Some formats such as GIF and Indexed PNGs are lossless, but have limited colors. This means that if your image contains more than 256 colors, it will be converted to 256 colors or less when you save it. However, this conversion only occurs once, and no other data is lost. You can open and re-save the images as many times as you like, and no other data will ever be lost.

Now, you can let the rogram reduce the colors when you save a GIF, or you can reduce the colors before saving. (If you're saving a PNG, you have to reduce the colors before saving, or it'll save as a truecolor PNG.) I strongly suggest reducing the colors yourself before saving the image. Why? Because it gives you more control, provides more options, and lets you see what the image will look like when it's done. (If you let the program do it when saving, you won't know how crappy the image looks until you open it later.) Also, if you don't like how the image looks with the reduced colors, you can adjust the contrast, saturation, and other things to try to improve it.
When reducing colors, you have 2 basic options: adaptive or dither. Adaptive replaces a color with a similar color, dithering uses 2 or more colors in a pattern of dots in order to simulate the original color. Adaptive is usually the better option, since dithering introduces very visible dots.

Here are some sample images:
This is a lossless, truecolor version of the image

This is the same image reduced to 256 colors, adaptive:

This is the image reduced to 256 colors, dithered:

This is a high quality, lossy JPG version of the image. Note the blurry little artifacts around the edges where elmer meets the green background. This is what the JPG format does with sharp edges and large sections of solid color:

This is a low quality JPG of the same image, this is to illustrate the type of data loss produced by lossy formats:

An important thing to note about reducing colors is that not all programs produce identical results. Many programs only provide 1 dithering filter, but one program I have (Image Analyzer) gives you a choice of several
Burkes Dithering ... Floyde-Steinberge Dithering ... High IGS Dithering ... Low IGS Dithering ... Irfan Dithering (floyde/steinberge, but produces different results) ... Xnview Dithering ... Iame Analyzer Adaptive ... Irfan Adaptive ... Xnview Adaptive

Be sure to check out my related FAQS: What format should I use? ... Common image formats ... Lossy vs lossless vs color reduction

If you have a an improvement suggestion for this (or any of my other FAQs), or an additional question you think should be added, feel free to message me.