This repository was archived by the owner on Dec 2, 2024. It is now read-only.
forked from IainDaviesMaths/Reproduction-Hancock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlotFigure6.m
69 lines (54 loc) · 1.76 KB
/
PlotFigure6.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
58
59
60
61
62
63
64
65
66
67
68
69
%Plot Figure 6
%Double scale:
%Simulation parameters
side_pixels=128;
num_units=6;
%Save the 15 images into a database
num_image=15;
standard_image_base=SaveStandardImageBase();
%Extract mean grey level from 20000 samples.
meangrey=MeanGreyLevel(side_pixels, standard_image_base, num_image);
%Learn weights
weights=LearningProcess(num_units,side_pixels,standard_image_base,num_image,meangrey);
%Plot principal components
finalimage=zeros(side_pixels,6*side_pixels);
for horiz=1:6
PC=zeros(side_pixels,side_pixels);
for I=1:side_pixels
PC(:,I)=weights(horiz,(I-1)*side_pixels+1:I*side_pixels);
end
%Rescale each PC.
PC=(PC-min(min(PC)))/(max(max(PC))-min(min(PC)));
%Fill in final image with PC.
finalimage(1:side_pixels,(horiz-1)*side_pixels+1:horiz*side_pixels)=PC;
end
subplot(2,1,1); imshow(finalimage)
set(gca,'visible','off')
set(gca,'xtick',[])
%Double scale:
%Simulation parameters
side_pixels=32;
num_units=6;
%Save the 15 images into a database
num_image=15;
standard_image_base=SaveStandardImageBase();
%Extract mean grey level from 20000 samples.
meangrey=MeanGreyLevel(side_pixels, standard_image_base, num_image);
%Learn weights
weights=LearningProcess(num_units,side_pixels,standard_image_base,num_image,meangrey);
%Plot principal components
finalimage=zeros(side_pixels,6*side_pixels);
for horiz=1:6
PC=zeros(side_pixels,side_pixels);
for I=1:side_pixels
PC(:,I)=weights(horiz,(I-1)*side_pixels+1:I*side_pixels);
end
%Rescale each PC.
PC=(PC-min(min(PC)))/(max(max(PC))-min(min(PC)));
%Fill in final image with PC.
finalimage(1:side_pixels,(horiz-1)*side_pixels+1:horiz*side_pixels)=PC;
end
subplot(2,1,2); imshow(finalimage)
set(gca,'visible','off')
set(gca,'xtick',[])
saveas(gcf,'Figure6.png')