-
Notifications
You must be signed in to change notification settings - Fork 0
/
getimages.m
39 lines (33 loc) · 1.13 KB
/
getimages.m
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
33
34
35
36
37
38
39
% Specify the folder where the files live.
imageArray= zeros(236,3,128,128);
expected = zeros(1,236)
a=1
myFolder = '/home/msg/Matlab/DeepLearning/images2/';
for i=1:3
tempdir = [myFolder num2str(i,'%d') '/resized/']
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isdir(tempdir)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', tempdir);
uiwait(warndlg(errorMessage));
return;
end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(tempdir, '*.jpg'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(tempdir, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
temp = imread(fullFileName);
imshow(temp)
for j=1:3
imageArray(a,j,:,:) = reshape(temp(:,:,j),1,128,128);
end
expected(1,a)=i
a= a+1
% imshow(imageArray); % Display image.
% drawnow; % Force display to update immediately.
end
end