-
Notifications
You must be signed in to change notification settings - Fork 0
/
alignImages.m
32 lines (26 loc) · 885 Bytes
/
alignImages.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
function T = alignImages(TrainDatabasePath)
% PICKING FILES
TrainFiles = dir(TrainDatabasePath);
Train_Number = 0;
% CALCULATING NUMBER OF IMAGES, EXCLUDING OTHER AUTOMATICALLY GENERATED SYSTEM FILES
for i = 1:size(TrainFiles,1)
if not(strcmp(TrainFiles(i).name,'.')|strcmp(TrainFiles(i).name,'..')|strcmp(TrainFiles(i).name,'Thumbs.db'))
Train_Number = Train_Number + 1;
end
end
% SORTED RETURN MATRIX
T = [];
for i = 1 : Train_Number
% CREATING FILE PATH
str = int2str(i);
str = strcat('\',str,'.jpg');
str = strcat(TrainDatabasePath,str);
% READING IMAGES AND CONVERTING TO GRAY-SCALED IMAGES
img = imread(str);
img = rgb2gray(img);
[irow, icol] = size(img);
% RESHAPING 2D IMAGE VECTORS TO 1D IMAGE VECTORS
temp = reshape(img', irow*icol, 1);
% ADDING NEW IMAGE
T = [T temp];
end