-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinitial_script.m
More file actions
78 lines (66 loc) · 2.62 KB
/
initial_script.m
File metadata and controls
78 lines (66 loc) · 2.62 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
tic;
% Initial script to form the dataset used across the project
clear;
clc;
% Load the NIST dataset
nistdataset = prnist([0:9], [1:2:1000]); %load 500 objects from each class
nistdataset_small = prnist([0:9], [1:100:1000]);
% Load deskew dataset
load('deskew_data');
%%%% PREPROCESSING PART %%%%
% make a bounding box so that all images have same box and resize the
% images to 16x16 pixels
preproc = im_box([],10,1)*im_rotate*im_box([],0)*im_gauss(2)*im_resize([], [16 16]);
preproc_basic = im_box([],0,1)*im_resize([], [16 16]);
preproc_dataset = nistdataset*preproc;
preproc_dataset_basic = nistdataset*preproc_basic;
preproc_dataset_basic_small = nistdataset_small*preproc_basic;
% Pixel representation
% the first representation after converting to prdataset is pixels
% representation
dataset_pixel = prdataset(preproc_dataset);
dataset_pixel_deskew = dataset_deskew;
dataset_pixel_deskew_small = dataset_deskew_small;
dataset_pixel_basic = prdataset(preproc_dataset_basic);
dataset_pixel_basic_small = prdataset(preproc_dataset_basic_small);
% Features representation
% Scenario 1
% extract all features of the image
dataset_features = im_features(dataset_pixel_basic,'all');
% extract profiles of the image
dataset_profiles = im_profile(dataset_pixel_basic,16,16);
% Scenario 2
% extract all features of the image
dataset_features_small = im_features(dataset_pixel_basic_small,'all');
% extract profiles of the image
dataset_profiles_small = im_profile(dataset_pixel_basic_small,16,16);
% Dissimilarity representation
% use small representation of 5% of the whole dataset
% the dissimilarity is based on pixels
% Scenario 1
reps = gendat(dataset_pixel_basic, 0.05);
d_cb = proxm(reps,'c');
d_euc = proxm(reps,'d',2);
dp_cb = dataset_pixel_basic*d_cb;
dp_euc = dataset_pixel_basic*d_euc;
% Scenario 2
reps_small = gendat(dataset_pixel_basic_small, 0.05);
d_cb_small = proxm(reps_small,'c');
d_euc_small = proxm(reps_small,'d',2);
dp_cb_small = dataset_pixel_basic_small*d_cb_small;
dp_euc_small = dataset_pixel_basic_small*d_euc_small;
% Scenario 2 - reps - deskew
reps_small_dk = gendat(dataset_deskew_small, 0.05);
d_cb_small_dk = proxm(reps_small_dk,'c');
d_euc_small_dk = proxm(reps_small_dk,'d',2);
dp_cb_small_dk = dataset_deskew_small*d_cb_small_dk;
dp_euc_small_dk = dataset_deskew_small*d_euc_small_dk;
% separate the dataset into training and test set
[trn_f tst_f] = gendat(dataset_features,0.5);
[trn_p tst_p] = gendat(dataset_profiles,0.5);
[trn_pix tst_pix] = gendat(dataset_pixel,0.5);
[trn_pix_bas tst_pix_bas] = gendat(dataset_pixel_basic,0.5);
running_time = toc;
%%%% END PREPROCESSING %%%%
running_time = toc
%running_time +/- 164.0019