MATLAB: Read and edit image frames saved in a fodler

multiple images

Below is the code i used but it is only changing one image and i want them all changed and saved in a sepereate folder
thanks
close all; clear all; clc;
dname_open = ('C:frames'); dname_save = ('C:frames_edit');
test = 0;
top_file = [dname_open '001.png']; ls_top_file = ls(top_file); c = cellstr(ls_top_file); cc = c(3:length(c)); S = size(cc); a = 1;
while a <= S(1) close all
imagename = ('file_name');
file2read = [dname_open '/' '001.png'] ;
index = 0;
I = imread(file2read);
for T=188 index=index+1; j=(rgb2gray(I));
k=zeros(size(j));
m=find(j>T);
k(m)=1;
figure(1); subplot(1,1,index);
pcolor(k); shading interp;
set(gca,'YDir','reverse');
saveas (gca, [dname_save '/' 'z_' imagename ], 'png');
end
end

Best Answer

See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F In the loop, use sprintf() and fullfile() to create both input and output filenames.