source: birds/specwhiten.m @ 70

Last change on this file since 70 was 59, checked in by vcheplygina, 11 years ago
File size: 850 bytes
Line 
1%% Input must be a spectrogram
2
3function s2 = whiten(s,fmax)
4
5%Not sure about this, but the paper seems to assume this
6s = 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
15s1 = s;             %Version for segmentation
16
17%For each frame, find a quantity similar to the energy"
18
19[Nf Nt] = size(s1);
20energy = nan(Nt,1);
21
22for t=1:Nt
23   energy(t) = 1/fmax * sum(s1(:,t).^2);
24end
25
26threshold = quantile(energy, 0.2);
27
28lowestix = find(energy<threshold);
29%lowestenergy = energy(lowestix);
30
31
32P = nan(Nf,1);
33s2 = s1;
34for f=1:Nf
35    %P(f) = sqrt(eps + sum(s1(f,lowestix).^2));
36   
37    P(f) = sum(s1(f,lowestix)) / length(lowestix);  %Version for segmentation
38    s2(f,:) = s1(f,:) ./P(f);
39end
40
41
42
43
44
45
46
47
48
49
50
Note: See TracBrowser for help on using the repository browser.