I want to get the first principal component for an image using the built-in function pca. How can I do that?
I have tried the following code:
[COEFF, SCORE] = pca(image);
SCORE(1:size(SCORE,1),:)=0;
reconstructed_image = SCORE / COEFF + repmat(mean(image,1),size(image,1), 1);
I=reshape(reconstructed_image,[256,256]);
figure
imshow(I,[0 255])
I only get the fist row of the image. Any idea how can I do that correctly?