2

I want to reduce the dimensions of 2D-Images. I have image patches of size 100x50 and I want to reduce the dimension of these patches.

Do I need to first convert the patch(100x50) into a vector(5000x1) and then apply PCA to reduce the dimension or can I directly apply PCA for dimension reduction on the patch(100x50) and reduce the dimension to let's say 2x50?

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
Frq Khan
  • 175
  • 2
  • 17
  • As it was written initially it was not clear whether you want to resize your image or apply PCA from the title. I adjusted the title to reflect the question in the question text. – NoDataDumpNoContribution Feb 06 '15 at 10:25

3 Answers3

3

You can directly apply a 2D-PCA. At least it exists and should perform better (reduction-wise) than the 1D-PCA.

A very highly cited research paper from 2004 on this: Yang, J. et al., 2004. Two-Dimensional PCA: A New Approach to Appearance-Based Face Representation and Recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence, 26(1), pp.131–137. Source

Unfortunately I do not know of a Matlab implementation.

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
  • I did this implementation `noofdim=4 [r,c] = size(img); %Calculate cov matrix and the PCA matrixes m = mean(img')'; S = ((img - m*ones(1,c)) * (img - m*ones(1,c))'); [Coeff latent]= eig(S); [latent, ind] = sort(diag(latent), 'descend'); M1 = Coeff(:,ind(1:noofdim)); latent1 = latent(1:noofdim);` – Frq Khan Feb 06 '15 at 10:27
  • @FrqKhan Sorry, I have not enough time now to check. – NoDataDumpNoContribution Feb 06 '15 at 12:34
1

Dimension reduction is R^n -> R^m where n>m so based on your text I get the impression you mean this instead:

  1. resolution resizing

    • changing target resolution
  2. data reduction

    • eliminating insignificant data

For image resizing or data reduction there are many ways to do it like:

  1. linear/bilinear/cubic/... filtering

    • are suited for visual data resizing (not for data reduction)
  2. frequency domain DFFT/DCT/DST based data reduction

    • can be used to changing resolution without significant data loss
    • by converting to frequency domain
    • (optional) removing noise or insignificant data (like JPEG compresion)
    • converting back to spatial domain in desired resolution
    • also can be used to data reduction when you stay on frequency domain
    • and use just significant frequencies (high amplitudes ..)
  3. PCA

    • can not be used for predetermined target resolution because
    • it extracts significant data which size is dependent on the content

So the answer really depends on what exactly you need to achieve and for what purpose

Spektre
  • 49,595
  • 11
  • 110
  • 380
0

PCA takes as input a point in a vector space and projects it onto a subspace. Expressed this way, then it is easy to remember that you need to resize your patch to a vector.

Using Matlab, calling your patch X, you can do this easily by calling X(:), you don't have to mess with reshape.

sansuiso
  • 9,259
  • 1
  • 40
  • 58