## 14. Image compression

**Image compression** has been the means of reducing the size of a graphics file for better storage convenience. It is also a useful way of reducing the time requirement of sending large files over the Web. Here we will explore a method in image compression by *Principal Component Analysis* (PCA). This technique utilizes the idea that any image can be represented as a superposition of weighted base images.

Suppose we have the following image and its grayscale conversion:

Figure 1. A sample image (characteristically sharp)and its grayscale equivalent. Courtesy of SuperStock. |

We divide image into blocks of 10×10 dimensions and concatenate them. These sub-blocks are arranged into an *n*x*p* matrix, where *n* is the number of blocks and *p* the number of elements in each block.

We apply PCA on the matrix with the *pca()* function in Scilab. which returns a set of eigenvalues, eigenvectors and principal components.

This produces eigenimages which would be essential elements to the compressed image.

Eigenvalues tell how essential a particular set of eigenvectors is to making up the completeness of the image. Based on these values expressed in percentages we choose the most important eigenvectors and reconstruct the image out of these. Figure 4 shows the resulting images at 86.7%, 93.4%, 95.5%, and 97.5%.

Figure 4. Compressed reconstructions of the image at different numbers of eigenvectors. 1, 3, 5 and 10 respectively. |

We can find out how much of the image has been compressed by counting how much of the eigenvector elements were used in the reconstruction and/or determining the file sizes. Our original image has the dimension 280×340 and is stored at 75.3KB (grayscale). When compressed with only a certain number of eigenvectors (figure above), becomes reduced to 44.2KB, 51.3KB, 53.9KB, and 60.7KB respectively.

When circumstances do not really require high-definition images, it is often best to compress the images into a good size such that it’s quality is not compromised and information is well-kept.

For this activity, I would rate myself 10 for the job well done. 🙂

Credits: Jeff A. and Jonathan A.

———————————————————————————————–—————–————————————

**References:**

[1] Soriano, 2010. Image compression. Applied Physics 186.

[2] Mudrova, Prochazka. , 2005. Principal component analysis in image processing.

[3] TechTarget, 2010. What is image compression?

## Recent Comments