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!