1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
function pushbutton1_callback
somefolder = '~/Images/';
filelist = dir(somefolder);
images = [];
%// the first two in filelist are . and ..
count = 1;
for i=3:size(filelist,1)
%// filelist is not a folder
if filelist(i).isdir ~= true
fname = filelist(i).name;
%// if file extension is jpg
if strcmp( fname(size(fname,2)-3:size(fname,2)) ,'.jpg' ) == 1
tmp = imread([somefolder fname]);
%// convert it to grayscale image if tmp is a color
%// image/picture
if size(tmp,3) == 3
tmp = rgb2gray(tmp);
%//resize of image
%tmp = imresize(tmp,[320 240],'bilinear');
%// put it into images buffer
images(:,:,count) = tmp;
count = count +1;
%images = [images tmp];
disp([fname ' loaded']);
end
end
end
end |
Partager