Why do pictures get more different pixels when they are compressed?

  • Thread starter Thread starter exigeracer
  • 3 comments
  • 482 views
Messages
5,987
For instance, if you were to make a picture in paint with just blue and red and save it on a lower quality, the two would "bleed" into each other and there would be distortion and other imperfections. This way it has to remember a whole new pile of different random pixels dispersed into a void which would be one solid colour on the highest quality jpg.

Wouldn't it be "easier" for the computer to "remember" just two different pixels and nothing else?
 
Yes it would, but it very much depends of the algorithm of compression. If you save such a picture as a .PNG (portable network graphics), which was made for this kind of things, you'll notice that you'll get a perfectly good looking picture and a very small file.

If you take .JPG, which you are referring to, you'll experience said bleeding. JPG was made for real life pictures and paintings, which obviously look very different. That's why JPG shines at those and fails at artificial images wth hard contrasts. If you take the same level of compression in a real life picture, you probably won't even see the bleeding, or at least very little, simply because the picture is full of small color changes. Additionally, there just will be less bleeding, because there will be less hard contrasts compared to an artificially made image. If you save a real life picture as a .PNG, you'll still get a perfectly goodlooking picture, but much less compression (= a bigger file) than with a JPG, because PNG doesn't work as well there.

The bleeding simply comes from the way JPG works. If you save as a JPG, the picture is divided in small 8 by 8 pixel-blocks (you can actually see those blocks if you apply a very strong compression). Each block then gets analyzed and summarized. If an area is full of one color, the result is small, because the algorthm only has to remember "all blue" (red, white - whatever). If the picture contains a very sharp contrast of two colors however (like the left half is white, and the right half is blue), and you don't have much space to store information, they will get mixed into each other to an extent. That happens because some information will be lost during compression. So in the JPG format, the added bleeding actually isn't more info than before, rather than an artifact of less info, generated by the algorithms that compress the picture. Other lossy compression algorithms will generate different artifacts, said bleeding is a JPG speciality.

That was a very basic description of how things mesh together, I'm sure that the net can give you more detailed explanations on how JPG works. Here's an example:

http://www.ams.org/featurecolumn/archive/image-compression.html
 
Also, MSPaint was (and still is) terrible at compressing anything into JPG or GIF since 1995.

I remember artfully making things in Paint (I had no other software) and cursing a storm over how terrible they would look after saving in something other than BMP.
 
Back