필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Peter L.
Peter L. 2015년 12월 10일
답변: khan 2015년 12월 10일
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!

답변 (1개)

khan
khan 2015년 12월 10일
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.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by