source: birds/specwhiten.m @ 57

Last change on this file since 57 was 57, checked in by vcheplygina, 11 years ago
File size: 640 bytes
RevLine 
[55]1%% Input must be a spectrogram
2
3function s2 = whiten(s,fmax)
4
5%Values output by spectrogram are already in [0, 1] range
6
7%Square root of spectrogram (of the absolute value?)
8s1 = sqrt(abs(s));
9%s1 = sqrt(s);
10
11%For each frame, find a quantity similar to the energy"
12
13[Nf Nt] = size(s1);
14energy = nan(Nt,1);
15
16for t=1:Nt
17   energy(t) = 1/fmax * sum(s1(:,t).^2);
18end
19
20threshold = quantile(energy, 0.2);
21
22lowestix = find(energy<threshold);
23lowestenergy = energy(lowestix);
24
25
26P = nan(Nf,1);
27s2 = s1;
28for f=1:Nf
29    P(f) = sqrt(eps + sum(s1(f,lowestix).^2));
30    s2(f,:) = s1(f,:) ./P(f);
31end
32
33
34
35
36
37
38
39
40
41
42
Note: See TracBrowser for help on using the repository browser.