adding data to a cell array without loosing the order

2 ビュー (過去 30 日間)
vania todorova
vania todorova 2021 年 7 月 27 日
コメント済み: vania todorova 2021 年 7 月 27 日
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 件のコメント
Stephen23
Stephen23 2021 年 7 月 27 日
Why are you using imagedatastore if you just want to store all of the image data in a cell array?
The whole point of an imagedatastore is that it is a special class which is a collection of image files that does not load them all into memory. As far as I can tell, your current approach does not utilize the imagedatastore at all.
Note that unless you are working with tiny images, importing all 24000 of them into memory at once is going to require quite a bit of memory: does your computer have sufficient memory to store all images at once and perform whatever operations you want on them?
Most likely you need to re-think your approach (hint: use the imagedatastore instead of a cell array).
vania todorova
vania todorova 2021 年 7 月 27 日
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

サインインしてコメントする。

採用された回答

KSSV
KSSV 2021 年 7 月 27 日
編集済み: KSSV 2021 年 7 月 27 日
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 件のコメント
KSSV
KSSV 2021 年 7 月 27 日
The order is maintained, you need not to worry. I suspect there might be memory issues if you read all the images.
vania todorova
vania todorova 2021 年 7 月 27 日
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!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by