MATLAB Answers

adding data to a cell array without loosing the order

3 views (last 30 days)
vania todorova
vania todorova on 27 Jul 2021
Commented: vania todorova on 27 Jul 2021
I have images in a imagedatastore that i want to add to a cell array but i need them to stay in the same order as they are frames from a vid really . how do i do that? i tried this but it does not keep the order . i have 24000 images that i want in stacks of 5. so it needs to have 4800 rows and 5 columns
C{(4800),5} = [];
for i = 1:length(ds.Files)
img = readimage(ds,i);
C{i}=img(i) ;
end
  4 Comments
vania todorova
vania todorova on 27 Jul 2021
a good part of the answer wuld be i m not that familiar with matlab.the goal is to create a stack of 5 frames. all the images in the subfolders are frames from a vid and i need them in a group of 5 for block matching .i thought that a cell array be easier in they are in a row of 5 together to just pull from each column. maybe i can just feed i+5 from the imagedatastore directly ? how do i read more about how to utalize the image datastore? i see the images are printing but honestly having hard time understand how does it work

Sign in to comment.

Accepted Answer

KSSV
KSSV on 27 Jul 2021
Edited: KSSV on 27 Jul 2021
idx = 1:24000;
id = reshape(idx,5,[])' ;
[m,n] = size(id) ;
C = cell(m,n) ;
for i = 1:m
for j = 1:n
C{i,j} = readimage(ds,id(i,j));
end
end
  5 Comments
vania todorova
vania todorova on 27 Jul 2021
ya it is! no , no issues as i have a pretty powerfull pc. now trying to figure out how to pull a column out of the array to feed for each frame .. thank you again!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!