PCA on an image
17 views (last 30 days)
Show older comments
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.
0 Comments
Answers (2)
Shantanu Dixit
on 23 Dec 2024 at 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!
0 Comments
Image Analyst
on 23 Dec 2024 at 18:18
See my attached demo where I compute the principal components of an image.
0 Comments
See Also
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!