error trying to read files
Mostrar comentarios más antiguos
Hi
I'm struggling with the current code i'm translated from idl, basically I've got a list of darkfield images named dark1,dark2,dark3,dark4,dark5. and a list of flatfield images named flat1,flat2,flat3,flat4,flat5 i'm trying to create a loop on the darkfield images and flatfield images and calculate their average using the code below. i get an error when the code starts a loop for k = 1:ndark
filesAndFolders = dir(workdir);
filesInDir = filesAndFolders(~([filesAndFolders.isdir])); % Returns only the files in the directory
j=1;
for i=1:length(filesInDir)
if(strfind(filesInDir(i).name,'flat'))
flatlist{j} = filesInDir(i).name;
j=j+1;
end
end
nflat = numel(flatlist);
%darklist = file_search(workdir,'dark*')
j=1;
for i=1:length(filesInDir)
if(strfind(filesInDir(i).name,'dark'))
darklist{j} = filesInDir(i).name;
j=j+1;
end
end
ndark = numel(darklist);
dark = zeros(ysize,xsize);
flat = zeros(ysize,xsize);
for k = 1:ndark
imtemp = imread(darklist{k});
dark = dark+double(imtemp)./ndark;
% ;Average dark images
end
for k = 1:nflat
imtemp = imread(flatlist{k});
flat = flat+double(imtemp)./nflat;
%;Average flat image
end
flatsub = flat-dark;
flatsub(find(flatsub <= 0)) = 1;
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!