How can I import all files from a folder in a loop and then work on them?
2 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
khan
on 10 Dec 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.
0 Comments
See Also
Categories
Find more on Import, Export, and Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!