I intend to use PCA for image compression. But I don't know how many PC's can be used for the maximum energy of image to be retained with maximum compression? I faced the same problem in SVD also.
You may try to plot the principal component eigenvalues for the analyzed spectrum-image arranged in a decreasing order (depicted in logarithmic scale). The threshold between eigenvalues associated signal and those associated with noise is not easy to determine. Only if there is one drastic drop in the eigenvalue distribution... or you can simply try to use the rank of the covariance matrix to find the number of principal components...
Energy is a lossy term, but interpreting it in the sense of eigenvalue accumulation, a higher compression rate will unavoidably be compromising the energy. So, as PCA compression is lossy, the maximum compression depends on the tolerance of energy loss your application needs can allow.
if you use the SVD, the singular values are arranged in the diagonal matrix S in descending order. As the sum of the square singular values represents the image energy content, yuo can discard the last singular values so that the ratio sum(s(i,i)^2) from k and N is a small fraction of the whole energy. In this case, you can drop also columns of the U and V matrix from k to N. This reduces the information to be coded to reproduce the lossy image.
Intuitively, I think you should try to establish a functional which relates the compression ratio (or bitrate for video compression) you need with the number of PC's. Furthermore, I agree to Rodrigo Cilla's suggestion of using Bayesian PCA to construct such a relation.
A low bit-rate hybrid DWT-SVD image-coding system (HDWTSVD) for monochromatic images by humberto ochoa and k.r. rao
In my particular experience SVD is good for packing energy in a few coefficiente as Cataldo pointed out. However, as you need to encode two differente matrices the bit rate cannot be low enough
Please remember that for compression/decompression you somehow need to encode the eigenvectors send to the decoder. Basically n-1 coefficients for the first vecor, n-2 for the second. The price of encoding the basis vectors should be taking into account in your distorsion metric.
1) using the sum of the eigenvalues, for example, we can find the number of the PC in which, the sum of the selected eigenvalues is 80% of the trace of the eigenvalues.
or
2) plot the curve in which the x-axis is the number of PCs, and y-axis is the energy or something you are interested. And then you can select the number of PCs by yourself.
To select the optimal set of Eigen vectors, you should compromise with the tradeoff b/w energy loss and data size. Choose a fitness function which characterizes this tradeoff and using Genetic Algorithms based on this fitness function you can select optimal set of components. You can find lot of literature in this respect.
it's completely up to you to find appropriate number of eigenvalues. but it has been shown that
1 - {Sum(landa(i)) | i from 1 to K} / {Sum(landa(i))| i from 1 to N,
could be a perfect metric to choose optimal number of eigenvalues. where K is the number of selected eigenvalues and N is the total number of them. its obvious that when all of the eigenvalues are selected the value of mentioned metric will be zero that means that the reconstruction error is exactly equal to zero but most of the time, by selecting K eigenvalues out of N ( K < < N) , the reconstruction error could be close enough to the zero.
7th Jul, 2012
Sebastiano Panichella
Zurich University of Applied Sciences
in SVD and also with the PCA, you must study the conformation of the information
contained in the image that you want compress. In particular, in the case of the SVD you must study how is the distribution of the eigenvalues, indeed some study compute for example the average value of the and descard component that have eigenvalues lower than mean value. But in other contexts, as for example the Information Retrieval, often the choise is descard the half of the components. My suggestion is that you can discard the last singular values studing these two directions. Good work :-) p.s. I agree with Cataldo Guaragnella, that wrote a previous comment...
8th Aug, 2012
HaraGopal Vajjha Venkata
Osmania Medical College
Accumulate the sum of squares connected
With each PC till the required % of error only
Remains
Prof Haragopal
1 Recommendation
10th Oct, 2012
Eric David Moyer
Wright State University
One question to ask yourself: why are you using PCA for image compression? For a very large class of applications, a discrete wavelet transform followed by quantization and entropy coding will give better results in terms of bits needed to preserve the most important image information. It is also common to do a DWT first before PCA to concentrate the energy even farther.
Of course, this is very dependent on your application. If you need a linear transform or are seeking orthogonal components for another reason, PCA could be a good choice. But you should think about why you are choosing it.
2 Recommendations
10th Oct, 2012
Gholamreza Anbarjafari
University of Tartu
I have put a MATLAB code in MATHWORKS which you can download it and there you can limit the number of PCA coefficients. http://www.mathworks.com/matlabcentral/fileexchange/22496-pca-based-face-recognition
1 Recommendation
10th Oct, 2012
D. Regan
Geethanjali Institute of Science and Technology
Thanks to Mr. Moyer...But generally wavelets show poor performance for ridges like non smooth features of image..That's why i thought to consider PCA...Am i right ?
10th Oct, 2012
Eric David Moyer
Wright State University
All lossy compression methods will have trouble with features with a high information content. I've spent some time playing with PCA compression and it, too, has trouble with high-frequency areas (like ridges). What I have read, though, is that DCT and DWT introduce errors at those problematic portions that are less perceptible to the human visual system than the errors produced by straightforward PCA at the same number of bits.
I am attaching PCA reconstructions of Lena (1-8 PC's, 8x8 boxes) for your enjoyment. Looking at the difference images, you can see that the errors are concentrated at the edges in the image and that there are also consistent errors in the textured areas of the image (like the top portion of the hat, for instance).
1 Recommendation
10th Oct, 2012
Eric David Moyer
Wright State University
Here is the attachment.
To avoid being misunderstood, let me stress that PCA has many desirable properties for image compression. I am looking at it for an application now. However, it is better to know why a particular compression method works for your application than to just choose blindly.
lena_pca_rosette_demo.jpg2.48 MB
1 Recommendation
11th Nov, 2012
Manny Ko
Regan, it is just the opposite. Wavelets are better at handling discontinuities (ridges). PCA do not handle edges well at all.
11th Nov, 2012
Carlos Manta Oliveira
Universidade NOVA de Lisboa
Do not forget that you need to select representative images for the training dataset. In these kind of algorithms the performance is very dependente of the training phase.
3rd Mar, 2013
Manny Ko
PCA implicitly assumes a Gaussian prior. To really handle edges well, you might want to look at curvelets/bandlets/ridgelets and that class of approaches.
3rd Mar, 2013
Laurent Duval
IFP Energies nouvelles
Your question is "How many PC's can be used for the maximum energy of image to be retained with maximum compression?" This question you ask is fundamental, and i regret it has no (straightforward) answer. You are looking at a function that links compression ratio (x) and quality (y). With a little twist (since you are using PCA, i suppose you are not looking at lossless compression), let us say that at full quality, (y=1) you have "no compression", beyond the best lossless coder, that is x=0. And at null quality (y=0) you have full compression (x=1). So the curve goes from (0,1) to (1,0). What is the optimum point of the curve? Even if you assume that the curve is decreasing, continuous, there is no way you can pick some best point on the curve, unless you specify some other measure of merit. Indeed, you want to have "two maxima" at the same time for two measures (compression ratio and quality) that do not share the same physical units. This has no absolute solution.
Besides, do not forget that when keeping a few principal components, you are not at true compression yet. You have to encode principal vectors, somehow. Following Manny Ko https://www.researchgate.net/profile/Manny_Ko/ multiscale methods (star-lets) have been generally shown more efficient that eigen methods (PCA, SVD) for natural images. If you are interesting in methods related to curvelets/bandlets/ridgelets, i would suggest you have a look at the following tutorial paper on 2D wavelets: http://www.laurent-duval.eu/Articles/Jacques_L_2011_j-sp_panorama-panorama-wavelet-multiscale-geometric-representations.pdf
Last, i'd add "SVD PCA KLT CCA and All That" http://www.ece.rutgers.edu/~orfanidi/ece525/svd.pdf a very nice self contained tutorial with applications in signal and image processing (including compression)
You can done this work by reducing the number of eigen value
1 Recommendation
3rd Mar, 2013
Umit Guz
Isik University
Look at my paper on image compression. There are some information on this.
3rd Mar, 2013
Kannan Shanmugam
American International Group
The total variance in the data is defined as the sum of the variances of the individual components. So decide the total number of principal components according to cumulative variance ‘‘explained’’ by them