Learn something new every day
More Info... by email
Image processing compression involves reducing the amount of space an image occupies when written to a physical file or when being held in memory. The general concept behind most compression algorithms is that images have repeating patterns or similar parts that can be specially encoded and then symbolically referenced, avoiding the need to explicitly rewrite an already encoded pattern. There are two broad categories in image processing compression, namely lossless and lossy compression types. In lossless compression, the image and all its pixels and color information are stored in a way so it can be perfectly reconstructed. Lossy compression involves either manipulating some parts of the image to make it easier to compress or using algorithms that can occasionally cause some pixel information not to be accurately encoded.
The difference in image processing compression rates between lossless and lossy algorithms can be dramatic. Lossless compression usually achieves a much higher compression percentage, at the cost of the image being slightly degraded each time it is re-compressed. The properties of an actual image also can affect the amount of compression that can occur. An image that has many disparate, differently colored pixels in random alignments will not benefit much from being compressed and might actually cause an increase in the file size with certain file formats. Images that have large areas of flat color, or a limited number of colors, can benefit the most from compression.
A common form of lossless image processing compression is known as run-length encoding. This method uses the idea that pixels of the same color will be repeated in horizontal lines within an image. Instead of storing each consecutive pixel separately, run-length encoding counts the number of pixels that are the same and instead stores only the number of pixels and color of those pixels. Depending on the image, this can be very efficient. For images that have many sets of identical colors that run only for two or three pixels, however, the algorithm can actually increase the size of the image file because of the encoding overhead, which is roughly the size of three pixels.
One of the most used image processing compression algorithms is a lossy method known as transform encoding. Instead of dealing with single pixels, this method takes blocks of pixels, averages them and then reduces the overall number of colors in an image to just the ones that either have the highest contrast or the highest frequency. The result is a file that can be significantly smaller than other formats, but that also might suffer severe degradation if the image blocks that are processed are too large.