-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.m
61 lines (61 loc) · 1.65 KB
/
demo.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
clc; clear;
close;
load principleVectors; % projection Matrix
load feat_mu; % the mean of test features;
lfiDir = dir('./rosemary/*.bmp');
sai_num = length(lfiDir);
patchSize = 4;
for k = 1:sai_num
saiColor = imread([lfiDir(k).folder,'/',lfiDir(k).name]);
saiGray = double(rgb2gray(saiColor));
if mod(k,9) == 0
aa = floor(k/9);
bb = 9;
else
aa = floor(k/9)+1;
bb = mod(k,9);
end
LF4D(aa,bb,:,:) = saiGray;
end
%calculate sub-aperture graident image array
[u,v,s,t] = size(LF4D);
for uu = 1:u-1
for vv = 1:v-1
%horzontal
Gx = squeeze(LF4D(uu,vv,:,:))-squeeze(LF4D(uu,vv+1,:,:));
%vertical
Gy = squeeze(LF4D(uu,vv,:,:))-squeeze(LF4D(uu+1,vv,:,:));
%GMMap
GMmap = sqrt(Gx.^2+Gy.^2);
LF4DMap(uu,vv,:,:) = GMmap;
end
end
u = u-1;
v = v-1;
s = (floor(s/8))*8;
t = (floor(t/8))*8;
num = 0;
% generate 4D-DCT coefficients
for uu = 1:4:u
for vv = 1:4:v
for ss = 1:4:s
for tt = 1:4:t
num = num + 1;
DC4DCT = DCT4D(LF4DMap(uu:uu+3,vv:vv+3,ss:ss+3,tt:tt+3));
oneCubeDCTCoff = get_DCT_vector(DC4DCT);
interCoff(:,num) = oneCubeDCTCoff;
end
end
end
end
interCoffNum = size(interCoff,1);
% calculate features at the same position of all blocks
for nn = 1:interCoffNum
interEnergy(nn) = getEnergy(interCoff(nn,:));
interWbl(nn) = wbl_shape(interCoff(nn,:));
end
[bandEnergy,oriEnergy] = get_band_ori_energy(interEnergy,patchSize);
interWbl = interWbl(2:end);
% PCA
reducedFeat = (interWbl - feat_mu) * principleVectors;
feat = [reducedFeat(:,1:40), bandEnergy, oriEnergy];