PCA on an image

17 Ansichten (letzte 30 Tage)
Laura Bachiler Matallana
Laura Bachiler Matallana am 17 Jun. 2019
Beantwortet: Image Analyst am 23 Dez. 2024 um 18:18
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.

Antworten (2)

Shantanu Dixit
Shantanu Dixit am 23 Dez. 2024 um 17:21
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 am 23 Dez. 2024 um 18:18
See my attached demo where I compute the principal components of an image.

Kategorien

Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by