MATLAB: How to read multiple image from a folder and create histogram for each image and save them ?

create histogram for each image

srcFiles = dir('C:\Users\sony\Desktop\matlabprog\ORL Face Database\s1\*.pgm');
for i = 1 : 10
filename = strcat('C:\Users\sony\Desktop\matlabprog\ORL Face Database\s1\',srcFiles(i).name);
if exist(filename, 'file') == 0
continue
end
Image = imread(filename);
Img = im2bw(Image);
figure(),imshow(Img);
end

Best Answer

srcFiles = dir('C:\Users\sony\Desktop\matlabprog\ORL Face Database\s1\*.pgm');
N = 10 ;
iwant = cell(N,1) ;
for i = 1 : N
filename = strcat('C:\Users\sony\Desktop\matlabprog\ORL Face Database\s1\',srcFiles(i).name);
if exist(filename, 'file') == 0
continue
end
Image = imread(filename);
Img = im2bw(Image);
figure(),imshow(Img);
%%Take histogram
iwant{i} = imhist(I) ;
end