필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

read images in all folder?

조회 수: 3 (최근 30일)
YJ
YJ 2014년 10월 2일
마감: YJ 2014년 10월 2일
I want to make a loop that reads all the images in all of folders:
3 Folder: each folder has 50 files
folder name:
  • xd_0_loop=0001
  • xd_0_loop=0002
  • xd_0_loop=0003
in each folder I have 50 image files
file name:
  • B0001
  • B0002
  • B0003
So
folder "xd_0_loop=0001" has file name " B0001 , B0002, B0003 ....... B0050."
and
folder "xd_0_loop=0002" has file name " B0001 , B0002, B0003 ....... B0050."
and so on.
I can load all files in one folder, with the code I made, (shown below)
clc;
clear;
back_path = 'F:\Thesis data\sample\datachris\xd_0_loop=0001\'; %locate the data set
back_files = dir([back_path '*.im7']); % load im7 files
n_back=length(back_files); %number of images
n_im=length(back_files); % number of images
A1 = readimx([back_path back_files(1).name]);%read all im7 files in back_path, readimx is special function act similar to imread
All_back_data = zeros(A1.Nx,A1.Ny*A1.Nf,n_im);
for i = 1:n_im
temp = readimx([back_path back_files(i).name]);
All_back_data(:,:,i) = double(temp.Data); %double precision
end
%compute mean image%
Back_m = zeros(size(All_back_data,1), size(All_back_data,2));
for i = 1:size(Back_m,1)
for j = 1:size(Back_m,2)
Back_m(i,j) = mean(All_back_data(i,j,:));
end
end
The code will generate one mean image of 50 files (B0001~B0050), and I need to do this for other folders, Instead of putting exact same code with different file number, I wonder is there a way to loop the file folder name.

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by