title: Using eigenvalues and eigenvector to compress an image
body: <p>I want to compress an image using eigenvalues and eigenvector, since I already done it using singular value decomposition, but I do something wrong while trying to compress it using eigenvalues and eigenvectors.</p>
  
  <p>Here is some code to see what I've already tried but something goes wrong while trying to calculate the <code>Z</code> matrix.</p>
  
  <pre><code>  image_matrix = double(imread(image));
    [m n] = size(image_matrix);
    miu = zeros(m, 1);
    A = [];
    for i = 1 : m
      miu(i) = mean(image_matrix(i, :));
      A(i, :) = image_matrix(i, :) - miu(i);
    endfor
  
    Z = A*A'/(n - 1);
    [V S] = eig(Z);
  
    W = V(:, 1 : k);
    Y = W'*A;
    A_k = W*Y + miu;
  </code></pre>
  
  <p><code>W*Y+miu</code> should've give me the approximation of matrix A from the above but it just gives a blank image. The above code receives: a path to an image and a number <code>k</code> such that <code>k</code> is some kind of order of approximation... I call it using <code>('path/to/image', 2)</code> and don't get the expected result. Also I am using this only for <strong>black and white</strong> images.</p>