How can I import all files from a folder in a loop and then work on them?

2 visualizaciones (últimos 30 días)
Peter L.
Peter L. el 10 de Dic. de 2015
Respondida: khan el 10 de Dic. de 2015
I have about 3000 .raw images in a folder.
I need to open them all and convert in to matrix form and then do mean and standard deviation
to convert 1 image I have a function that works like this:
img1=openraw ('C\path\folder\img00001.raw')
how can I make it so that the loop will open all of them? I cannot see a way to make the path of the image part of the loop so that for example:
starting point: C\path\folder\img00001.raw
loop 1: C\path\folder\img00002.raw
loop2: C\path\folder\img00003.raw
etc etc.
please help
thanks!

Respuestas (1)

khan
khan el 10 de Dic. de 2015
F = dir('C\path\folder\*.raw');
for ii = 1:length(F)
imagesAll(:,:,ii) = openraw(F(ii).name);
end
But you have to be careful in image size. If they are not equal than you have to make them equal. Otherwise the matrix will give you an error.

Categorías

Más información sobre Import, Export, and Conversion 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!

Translated by