-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_data.m
33 lines (27 loc) · 1.22 KB
/
load_data.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Copyright (c) 2021, Christopher E. Arcadia (CC BY-NC 4.0) %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Load Image Database
% load all images and labels
database = load(option.database_path);
database.path = option.database_path;
database.num.pixels = size(database.X,2);
database.num.images = size(database.X,1);
database.num.classes = length(database.classnames);
database.dimensions = [16,16];
database.name = 'Caltech 101 Silhouettes';
if option.verbose
disp(['Loaded all ' 'images from the ' database.name ' database.'])
disp(['The following classes are available: ' strjoin(database.classnames,', ')])
end
clear path
% function to convert 1-D data to a 2-D image
func.reshaper = @(image_vector) reshape(image_vector,database.dimensions);
% function to compare two data vectors
func.euclidean = @(a,b) sqrt(sum((a-b).^2)); % Euclidean distance
% randomize data to make cross validation simple later
database.shuffle.seed = 5;
rng(database.shuffle.seed);
database.shuffle.perm = randperm(database.num.images);
database.Y = database.Y(database.shuffle.perm);
database.X = database.X(database.shuffle.perm,:);