-
Notifications
You must be signed in to change notification settings - Fork 3
/
compute_Dir_Spec_From_MWSG.m
59 lines (46 loc) · 1.54 KB
/
compute_Dir_Spec_From_MWSG.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
function [x_D1,x_D2,x_D3,x_D4,DAll]=compute_Dir_Spec_From_MWSG(Spect,len)
%%
% Calculate four directional spectrogram and summed up
% directional spectrogram calculated on a mentioned patch of len
% Where
% Spect : spectrogram
% x_D1 : spectrogram which is replaced by values in the patch of
% length len at angle 0 degrees
% x_D2 : spectrogram which is replaced by values in the patch of
% length len at angle 45 degrees
% x_D3 : spectrogram which is replaced by values in the patch of
% length len at angle 90 degrees
% x_D4 : spectrogram which is replaced by values in the patch of
% length len at angle 135 degrees
M=Spect;
[nrows,ncols]=size(M);
l=round(len/2);m=floor(len/2);
Mnew=zeros(nrows+2*m,ncols+2*m);
Mnew(1:m,m+1:ncols+m)=M(1:m,:);
Mnew(nrows+m+1:nrows+2*m,m+1:ncols+m)=M(nrows-m+1:nrows,:);
Mnew(m+1:nrows+m,1:m)=M(:,1:m);
Mnew(m+1:nrows+m,ncols+m+1:ncols+2*m)=M(:,ncols-m+1:ncols);
Mnew(m+1:nrows+m,m+1:ncols+m)=M;
P=Mnew;
D0=P;D90=P;D135=P;D45=P;
[M,N]=size(P);
P2=fliplr(P);
for i=round(len/2):M-floor(len/2)
for j=round(len/2):N-floor(len/2)
widt=floor(len/2);
D0(i,j)= sum(P(i-widt:i+widt,j));
D90(i,j)=sum(P(i,j-widt:j+widt));
temp1=diag(P,j-i);
k=min(i,j);
D135(i,j)=sum(temp1(k-widt:k+widt));
temp2=diag(P2,(N-(j-1)-i));
k1=min(N-j+1,i);
D45(i,j)=sum(temp2(k1-widt:k1+widt));
end
end
x_D1=D0(l:M-m,l:N-m);
x_D2=D45(l:M-m,l:N-m);
x_D3=D90(l:M-m,l:N-m);
x_D4=D135(l:M-m,l:N-m);
DAll = D0+D45+D135+D90;
end