adding data to a cell array without loosing the order
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
vania todorova
el 27 de Jul. de 2021
Comentada: vania todorova
el 27 de Jul. de 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 comentarios
Stephen23
el 27 de Jul. de 2021
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).
Respuesta aceptada
KSSV
el 27 de Jul. de 2021
Editada: KSSV
el 27 de Jul. de 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 comentarios
KSSV
el 27 de Jul. de 2021
The order is maintained, you need not to worry. I suspect there might be memory issues if you read all the images.
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Object Programming en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!