Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
read images in all folder?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!