Image Compression


 
  Another way to reduce the storage required for an image is to compress the image. Rather than store the red, green, and blue values separately for each pixel in an image, a sort of shorthand notation can be used.  For example, suppose that the block of 8 x 8 pixels in the upper left corner of an image are all same shade of blue sky. Then instead of repeating the 24 bits that define the shade of blue for each of the 64 pixels in the block, a code meaning "all pixels in this block" might be stored with the value of blue that is to be repeated.  that would be a perfect representation of that block. However, if one or two of the pixels were a little off, software could decide that making them all the same would be good enough for some purpose. That would make the file smaller at some expense of quality.

More elaborate compression schemes can do much better than just substituting a single value for a whole block of pixels. More complicated schemes fit the shading variations inside the block while still saving storage over storing each pixel exactly. The most common method for compress is named JPEG [jay-peg] after the Joint Photographic Experts Group that standardized it. The file format extension for files so compressed is JPG.  Most digital cameras automatically compress images using the JPG format so that more pictures will fit on the memory stick in the camera. Digital cameras often have settings for both the resolution of the image and the amount of compression. Low resolution and low image quality allows the largest number of images to be stored. Large memory sticks are inexpensive, so there is not much penalty in using the largest resolution and best image quality for ordinary circumstances.

When editing images on a computer and saving them for web posting or other purposes, the question arises again as to the resolution and compression quality to use.  Every time a jpg file is opened, edited, and saved the compression process will lose a little bit of information. Since disk space on a personal computer is rarely a major limitation, it's best to always store the full original resolution and to use a high quality jpg setting. The 10 level in Photoshop is very high quality, but still provides significant savings of disk space. The highest setting on the camera is probably less than that, so you can do a number of edits without going much below the original quality.

Here is an image (taken in Hilo, Hawaii -- typical of a lousy day in paradise) saved at the highest JPG quality level, level 12:

Tree scene, jpg level 12

This image has a great deal of fine detail, which makes it difficult to compress efficiently. It requires 301 kb of storage.  Here is the image again, stored at levels 10 and 4 respectively:

Tree scene, saved as JPG level 10dotTree scene, saved as JPG level 4

The level 10 image (left)  require 194 kb and the level 4 image (right) 97 kb. If deterioration in the level 4 image is leaping out at you, congratulations. Pressing on with more compression, this blow up shows deterioration in Level 1 compression compared with level 12

Compare jpg level 12 to level 1

Note that the colors get muddy along with sharpness degrading. However, memory is not so dear that we are likely to even try so much compression.

Here is a scene with much less detail, so it compresses more efficiently.  Saved at level 12, the file is 171 kb.  

Sky scene, saved as JPG level 12

Saving at level 1 reduces the file size to 35 kb, but now you can easily see the errors caused by the compression. Note edges of blocks appearing.in the sky. 

Sky scene, JPG level 1

The bottom line is that for web and e-mail purposes, compression at the medium quality level (around 7) will be fine. If you see blocks, you have overdone it.

copyright QuickShotArtist.com