How to vectorize multiple images in 3D matrix?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Adam
il 27 Feb 2015
Modificato: Adam
il 27 Feb 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 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Computer Vision with Simulink in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!