Monday, October 4, 2010

My Special Project (Recognition of Hand Written Digits Through PCA)

The Principal Components Analysis (PCA) algorithm has been very useful in many applications such as image compression and decreasing the dimensionality of high-dimensional datasets.  The PCA is a statistical implementation of finding the eigenvectors which represent the dataset.  These eigenvectors are arranged according to the variance of the data in a specific dataset.

Thursday, September 23, 2010

Entry 20: Image Compression

In previous times, every bit of storage seems so significant , but because of recent technological developments, storage capacity has been developed to quite large sizes that even a megabyte seems so useless already.

Even though the "phenomenon" of less storage size appreciation and the prices of storage media are decreasing, compression techniques to minimize the storage size of files are still being used and developed.

In this activity, we come to realize a basic method of compressing an image file through the discrimination of some of the image's details without so much information loss brought to the compressed image.

The method used in this activity is called PCA or the Principal Components Analysis.  It is based on the concept of identifying the eigenvectors of the image with the highest information contribution based on the eigenvalue of the diagonalized covariance matrix of the  n-dimensional "observations".  This results to a minimized number of information stored in the resulting compressed image, thus, the image size is smaller than the original.

For this activity, I chose the image in Fig. 1 to be my test image to be compressed.

Figure 1:  Original image to be compressed.

We first sampled the image such that size of each subimage is 10x10.  From the ensemble of these subimages, we computed the PCA using the pca() function in scilab.

One of the results after computing the PCA is the eigenvectors of the image.  The eigenvector of the image used here is shown in Fig. 2,

Figure 2:  Eigenvectors for the image.

After the eigenvectors were computed, we identified the eigenvectors with high explained variance to be used on the compression.  In the plot below (Fig. 3), we can see the variance explained by each eigenvectors.

Figure 3:  Scree plot.  Blue) Percent of variance explained by each eigenvector; Red) Cumulative sum of the variance explained of the eigenvectors.


We utilized different number of eigenvectors to achieve certain compression levels.  Some compressed images at different compression levels are shown in Fig. 4,

Figure 4:  Samples of compressed images using PCA. (from top to bottom) 92%, 95%, 97%, 99% and 100% compressed images.  The number of eigenimages required to compress the image to these compression levels are (from top to bottom) 1, 2, 4, 13 and 100 eigenimages, respectively.

For the compression, the number of stored information is decreased depending on the number of eigenimages utilized.  It is nice to know that the highest eigenvector explains almost 92% of the entire image.  This implies that even if small number of eigenimages were used in the reconstruction, the quality of the result will not deteriorate much.

In this activity I would rate myself 10/10.

Source:
    Activity Sheet for Activity 14 - Dr. Maricor Soriano

Entry 19: Color Image Segmentation

Images contain many information that can be retrieved through image processing.  Some of the information can be used to discriminate certain regions (regions of interest - ROI) as the important regions and put other regions not containing the specified region to a null value forcing other points to be a part of the background.

In this activity, we perform the method of color image segmentation to identify in the entire image the regions with the same information with the reference patch.  For this to be done, normalization of the color channels was performed given by the equation below.

 
We studied the two types of color image segmentation techniques, the parametric and the non-parametric color segmentation.  The parametric segmentation method utilizes the Gaussian distribution wherein the probability of the image value depends on the reference patch.  The mean of each color channel was used to be the abscissa with the highest probability.  The Gaussian distribution used in the parametric technique is stated below,
 

the spread and mean parameters of the distribution comes from the standard deviation and the mean value of the reference patch, respectively.

We used the technique of color image segmentation to the image below (My Toy Car :D) shown in Fig. 1,

Figure 1:  Image to be segmented
It is important to realize that we utilizes the Normalized Chromaticity Space in representing the location of the values to be calculated from the patch.  Also, this chromaticity space will help us visualize quantitatively what colors are present in the image.  A sample normalized chromaticity graph is shown below in Fig. 2,

Figure 2:  Sample Normalized Chromaticity Space

To continue with the parametric image segmentation, we chose a patch in the ROI to represent the entire region.  The patch chosen appear to have a large color component of yellow Fig. 3.


Figure 3:  Reference color patch for color image segmentation.

After doing the algorithm of taking the Gaussian probabilities and multiplying the results with each other, we get a parametrically segmented version of Fig. 1 as shown in Fig. 4.

Figure 4:  Segmented image through parametric color image segmentation.

Our next task is to segment the original image using the non-parametric approach.  In this technique, it requires the knowledge of the histogram of the normalized chromaticity space for the entire image and the patch representing the ROI.

For the image to be segmented, we calculated the 2D normalized chromaticity space histogram representing the entire image.  The computed histogram is shown in Fig. 4 along with the normalized chromaticity space representing the entire color spectrum.

Figure 4:  Left) The normalized chromaticity histogram representing the image, Right) the normalized chromaticty space fot the entire color spectrum.

We also computed the normalized chromaticity histogram for the patch chosen to represent the ROI.  In Fig. 5, we superimposed the computed normalized chromaticity histogram of the ROI to the normalized chromaticity space representing the entire color spectrum to properly visualize the color component representing the ROI.

Figure 5:  Superimposed normalized chromaticity histogram of the chosen representative region for the ROI with the normalized chromaticity space of the entire color spectrum.

It can be observed in Fig. 5 that the representative color of the ROI is near the yellow-orange region of the normalized chromaticity space of the entire spectrum.

We performed histogram backprojection which will yield the non-paramtrically segmented image.  The resulting non-parametrically segmented image is shown in Fig. 6.

Figure 6:  Resulting non-parametrically segmented image.

It is so handy to the techniques performed above to identify regions of interest.  Many applications of these methods can be made such as tracing the trajectory of certain material.

In this activity I want to give myself a 10/10 because of my efforts and enthusiasm in doing the activity.  I learned much in this activity which is  the most important thing for me.

Source:
    Activity Sheet for Activity 13 - Dr. Maricor Soriano