PCA on an image

6 visualizaciones (últimos 30 días)
Laura Bachiler Matallana
Laura Bachiler Matallana el 17 de Jun. de 2019
Respondida: Image Analyst el 23 de Dic. de 2024
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.

Respuestas (2)

Shantanu Dixit
Shantanu Dixit el 23 de Dic. de 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 el 23 de Dic. de 2024
See my attached demo where I compute the principal components of an image.

Categorías

Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by