How to convert images to vectors
9 次查看(过去 30 天)
显示 更早的评论
How can I convert my images with size 120 160 1 888 to vectors ?
where 120* 160 is the size of each gray scale image, 1 is the number of channels, 888 is the number of images
so the output will be matrix and each column in the matrix is an image, I should end up with 888 vectors each vector is image
0 个评论
采纳的回答
Dyuman Joshi
2023-10-17
From what I have understood -
%Random input
in = rand(120,160,1,888);
s = size(in);
%Convert the input to a cell vector
out = mat2cell(in,s(1),s(2),s(3),ones(1,s(4)));
size(out)
%Modify the size of the output
out = squeeze(out)
6 个评论
Walter Roberson
2023-10-17
in = rand(120,160,1,888);
s = size(in);
out = cell2mat(squeeze(cellfun(@(P) P(:), num2cell(in, 2),'uniform', 0)));
whos out
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!