Why does compressing an image or GIF create noise in previously-solid areas? Surely that requires MORE information to be stored?

924 views

Why does compressing an image or GIF create noise in previously-solid areas? Surely that requires MORE information to be stored?

In: Technology

5 Answers

Anonymous 0 Comments

GIFs aren’t really designed for photos. The noise added is because of the conversion to 256 colours. And you’re right. It does often require more information be stored. The format is best for hand drawn images.

JPEG is a little different. It doesn’t store pixels directly. It stores 8×8 squares, made up of patterns [like these](https://upload.wikimedia.org/wikipedia/commons/2/24/DCT-8×8.png) added together. Generally real world images only need a few of them and the least important ones are removed to keep the image size down, but because most of them look like noise.

Anonymous 0 Comments

GIFs are limited to 256 colours. This was a common thing back in the day to save space and because many PC monitors ran in 8 bit colour mode – start with a table of colours (called the palette) then each pixel is only a single byte even before you compressed it. Many image formats were palette based or at least supported it.

But if your source image has more colours than 256 then you have a problem. Standard solution method is called dithering, where you replace a solid chunk of a colour which isn’t available with a mixture of colours you do. This results in the noise. If you see a dark brown with slightly light brown noise, then the original colour was actually darkish brown slightly lighter than the main colour. Suffice to say, Gif is a bad choice for photo-realistic images.

The good news is gifs are mostly phased out from the internet. Their only real advantage is both transparency and animation in the same image, but with web videos covering animation needs these days gif is dying.

Anonymous 0 Comments

It doesn’t in actual GIFs, or PNG. Those use a kind of compression that works best on areas of a solid color. If there’s 5 white pixels in a row, rather than writing “white,white,white,white,white” you write “5 x white”. It’s also a lossless kind of compression, where the resulting image is identical to the uncompressed one.

The problem is that areas of a single color are actually pretty much nonexistent in things like photographs, and this kind of compression doesn’t work for them. So JPEG uses a different method entirely. How it works is actually quite complex and I don’t think I can make it justice in a comment, but there’s a [very good video series](https://www.youtube.com/watch?v=LFXN9PiOGtY&list=PLzH6n4zXuckoAod3z31QEST1ZaizBuNHh)
on that. Video encoding also follows similar principles.

Anonymous 0 Comments

I believe it partly has to do with the color depth. Every image has a certain set of colors it uses.

Unless the image was created on a computer, it is very very unlikely that an area really is a solid color.

Think of these areas like a color gradient. Eg. going from red to blue. Now obviously, in the center, you’d have many pixels that are purple, because of the color mixing. So to reduce the overall amount of information that needs to be stored in the file, you just use the two colors – red and blue – and for blending them together, just use a checker pattern and vary the density of the colors fields/pixels.
Like this: xxxxxoxxxxooxxxoooxxooooxooooo

Overall it looks noisier, but the amount of colors is drastically reduced.

Anonymous 0 Comments

Actually, JPEG compression creates artifacts because it uses patterns to recreate the image. By encoding less data the algorithm is forced to use less accurate patterns to represent the missing information. The noise is part of the algoritm, not the data.

GIF color reduction (quantization) reduces data by approximating colors to a smaller palette. This can have the effect that the colors do not look like what they originally were, and not blending in with surrounding pixels due to the color component distances. This, to our attuned brains, makes the images look “noisy”. But in fact we instead have reduced color data.