How to vectorize multiple images in 3D matrix?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Adam
2015 年 2 月 27 日
編集済み: Adam
2015 年 2 月 27 日
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 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Computer Vision with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!