How to vectorize multiple images in 3D matrix?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone,
I have a 3D matrix of MxNx16 images loaded in matlab. I am trying to transform each image inside that 3D matrix in a vector using (:). But I am unable to write a for loop that can do that for all images. I want my 3D matrix to contain all 16 images, but each of them transformed from MxN matrix to vector(:).
I tried to do it like for a single image but I only get the vector of all images.
Example.
STACKMat = logical(STACK(:)); % This is for a single image
Can anyone help me? Thanks in advance.
0 commentaires
Réponse acceptée
Adam
le 27 Fév 2015
Modifié(e) : Adam
le 27 Fév 2015
myImages = cat( 3, ones(10), 2*ones(10), 3*ones(10), 4*ones(10) );
imSize = size( myImages, 1 ) * size( myImages, 2 );
myImagesVec = reshape( myImages, imSize, size( myImages, 3 ) );
should give you what you want. Obviously replacing my made-up 'images' with your own and naming variables sensibly!
If you want them all converted to logical then obviously you can apply that at any point without affecting the reshape.
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!