-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoEnc.m
58 lines (45 loc) · 1.51 KB
/
AutoEnc.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
% the autoencoder code
% nof number of filters
% maximage is maximum number of images
function AutoEnc (result_path, nof, maximage)
numberofparams = 4 ;
X = zeros (numberofparams,maximage*nof); % 5 rows of SNR, CNR, ENL, MMSIM, EPI
for image_id=1:maximage
annparam_filename = [result_path num2str(image_id) '_ann_params.mat'];
load (annparam_filename); % load Para
a = (image_id-1) * nof + 1 ;
b = a + nof - 1 ;
X (1,a:b) = normc (Para(image_id).SNR);
X (2,a:b) = normc (Para(image_id).CNR);
X (3,a:b) = normc (Para(image_id).EPI);
X (4,a:b) = normc (Para(image_id).MSSIM);
%X (5,a:b) = normc (Para(image_id).ENL);
end
%Xnew = X ;
hiddenSize = 1;
% autoenc_SABA = trainAutoencoder(X,hiddenSize, ...
% 'ScaleData',false, ...
% 'DecoderTransferFunction','purelin');
autoenc_SABA = trainAutoencoder(X,hiddenSize );
%Z = encode (autoenc_SABA, Xnew);
%Z = encode (autoenc_SABA, X) ;
% All FOMs
Y = zeros (1,maximage*nof);
for i =1:maximage*nof
for j = 1:numberofparams
Y (1,i) = Y (1,i) + autoenc_SABA.EncoderWeights(j)* X (j,i) ;
end
end
Y = mat2gray (Y);
%only for one filter
Yfilter = zeros (nof,maximage);
for filter = 1: nof
j = 1 ;
for i =filter:27:maximage*nof
Yfilter (filter,j) = Y (1,i);
j = j + 1 ;
end
end
autoencoder_filename = [result_path 'AutoEnc.mat'];
save (autoencoder_filename , 'autoenc_SABA' ,'Y', 'Yfilter' );
end