Line | |
---|
1 | %% Input must be a spectrogram
|
---|
2 |
|
---|
3 | function s2 = whiten(s,fmax)
|
---|
4 |
|
---|
5 | %Not sure about this, but the paper seems to assume this
|
---|
6 | s = abs(s);
|
---|
7 |
|
---|
8 | %Values output by spectrogram are already in [0, 1] range?
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 | %Square root of spectrogram (of the absolute value?)
|
---|
13 |
|
---|
14 | %s1 = sqrt(abs(s)); %Version 1
|
---|
15 | s1 = s; %Version for segmentation
|
---|
16 |
|
---|
17 | %For each frame, find a quantity similar to the energy"
|
---|
18 |
|
---|
19 | [Nf Nt] = size(s1);
|
---|
20 | energy = nan(Nt,1);
|
---|
21 |
|
---|
22 | for t=1:Nt
|
---|
23 | energy(t) = 1/fmax * sum(s1(:,t).^2);
|
---|
24 | end
|
---|
25 |
|
---|
26 | threshold = quantile(energy, 0.2);
|
---|
27 |
|
---|
28 | lowestix = find(energy<threshold);
|
---|
29 | %lowestenergy = energy(lowestix);
|
---|
30 |
|
---|
31 |
|
---|
32 | P = nan(Nf,1);
|
---|
33 | s2 = s1;
|
---|
34 | for f=1:Nf
|
---|
35 | %P(f) = sqrt(eps + sum(s1(f,lowestix).^2));
|
---|
36 |
|
---|
37 | P(f) = sum(s1(f,lowestix)) / length(lowestix);
|
---|
38 | s2(f,:) = s1(f,:) ./P(f);
|
---|
39 | end
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.