-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrefparams_vecgsm.m
52 lines (41 loc) · 1.38 KB
/
refparams_vecgsm.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
function [ssarr, l_arr, cu_arr]=refparams_vecgsm(org,subands,M)
%This function computes the parameters of the reference image. This is
%called by vifvec.m.
for i=1:length(subands);
sub=subands(i);
y=org{sub};
sizey=floor(size(y)./M)*M; % crop to exact multiple size
y=y(1:sizey(1),1:sizey(2));
% Collect MxM blocks. Rearrange each block into an
% M^2 dimensional vector and collect all such vectors.
% Collece ALL possible MXM blocks (even those overlapping) from the subband
temp=[];
for j=1:M
for k=1:M
temp=cat(1,temp,reshape(y(k:end-(M-k), j:end-(M-j)),1,[]));
end
end
% estimate mean and covariance
mcu=mean(temp')';
cu=((temp-repmat(mcu,1,size(temp,2)))*(temp-repmat(mcu,1,size(temp,2)))')./size(temp,2); % covariance matrix for U
% Collect MxM blocks as above. Use ONLY non-overlapping blocks to
% calculate the S field
temp=[];
for j=1:M
for k=1:M
temp=cat(1,temp,reshape(y(k:M:end, j:M:end),1,[]));
end
end
% Calculate the S field
ss=(inv(cu)*temp);
ss=sum(ss.*temp)./(M*M);
ss=reshape(ss,sizey/M);
% Eigen-decomposition
[v,d]=eig(cu);
l_arr(sub,:)=diag(d)';
% rearrange for output
ssarr{sub}=ss;
temp=0;
d=diag(d);
cu_arr{sub}=cu;
end