-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdivine_feature_extract.m
92 lines (68 loc) · 2.24 KB
/
divine_feature_extract.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function f = divine_feature_extract(im)
% Function to extract features given an image
%% Constants
num_or = 6;
num_scales = 2;
gam = 0.2:0.001:10;
r_gam = gamma(1./gam).*gamma(3./gam)./(gamma(2./gam)).^2;
%% Wavelet Transform + Div. Norm.
if(size(im,3)~=1)
im = (double(rgb2gray(im)));
end
[pyr pind] = buildSFpyr(im,num_scales,num_or-1);
[subband size_band] = norm_sender_normalized(pyr,pind,num_scales,num_or,1,1,3,3,50);
f = [];
%% Marginal Statistics
h_horz_curr = [];
for ii = 1:length(subband)
t = subband{ii};
mu_horz = mean(t);
sigma_sq_horz(ii) = mean((t-mu_horz).^2);
E_horz = mean(abs(t-mu_horz));
rho_horz = sigma_sq_horz(ii)/E_horz^2;
[min_difference, array_position] = min(abs(rho_horz - r_gam));
gam_horz(ii) = gam(array_position);
end
f = [f sigma_sq_horz gam_horz]; % ind. subband stats f1-f24
%% Joint Statistics
clear sigma_sq_horz gam_horz
for ii = 1:length(subband)/2
t = [subband{ii}; subband{ii+num_or}];
mu_horz = mean(t);
sigma_sq_horz(ii) = mean((t-mu_horz).^2);
E_horz = mean(abs(t-mu_horz));
rho_horz = sigma_sq_horz(ii)/E_horz^2;
[min_difference, array_position] = min(abs(rho_horz - r_gam));
gam_horz(ii) = gam(array_position);
end
f = [f gam_horz];
t = cell2mat(subband');
mu = mean(t);
sigma_sq = mean((t-mu_horz).^2);
E_horz = mean(abs(t-mu_horz));
rho_horz = sigma_sq/E_horz^2;
[min_difference, array_position] = min(abs(rho_horz - r_gam));
gam_horz = gam(array_position);
f = [f gam_horz];
%% Hp-BP correlations
hp_band = pyrband(pyr,pind,1);
for ii = 1:length(subband)
curr_band = pyrband(pyr,pind,ii+1);
[ssim_val(ii), ssim_map, cs_val(ii)] = ssim_index_new(imresize(curr_band,size(hp_band)),hp_band);
end
f = [f cs_val];
%% Spatial Correlation
b = [];
for i = 1:length(subband)/2
b = [b find_spatial_hist_fast(reshape(subband{i},(size_band(i,:))))];
end
f = [f b];
%% Orientation feature...
l = 1; clear ssim_val cs_val
for i = 1:length(subband)/2
for j = i+1:length(subband)/2
[ssim_val(l), ssim_map, cs_val(l)] = ssim_index_new(reshape(subband{i},size_band(i,:)),reshape(subband{j},size_band(j,:)));
l = l + 1;
end
end
f = [f cs_val];