PCA on an image

8 vues (au cours des 30 derniers jours)
Laura Bachiler Matallana
Laura Bachiler Matallana le 17 Juin 2019
Hi there,
I'm trying to apply PCA on an single image and i'am using the same porgram that i used to apply PCA to a grupo of images that are part of the data basis of a neuronal network that i am creating. The thing is that i need to apply PCA to a single image to be that image the input to the neuronal network that i created but it doesnt work.
Anyone has any idea of how can I apply PCA to an image of 50x50 saved as vector of 2500 to have an image of 90?
Thanks a lot.

Réponses (2)

Shantanu Dixit
Shantanu Dixit le 23 Déc 2024
Hi Laura,
If PCA has already been computed on a group of images, the principal components (eigenvectors) can be reused. The single image can be projected onto these precomputed components to get the reduced representation.
% Assume `coeff` are the eigenvectors precomputed on training images
% Single image (reshape from 50x50 to 1x2500)
image = rand(50, 50); % Example image
image_vector = reshape(image, 1, []);
% Project onto first 90 principal components
reduced_image = image_centered * coeff(:, 1:90);
% Process further to the neural network as required
Hope this helps!

Image Analyst
Image Analyst le 23 Déc 2024
See my attached demo where I compute the principal components of an image.

Catégories

En savoir plus sur Dimensionality Reduction and Feature Extraction dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by