source: birds/specwhiten.m @ 100

Last change on this file since 100 was 59, checked in by vcheplygina, 12 years ago
File size: 850 bytes
RevLine 
[55]1%% Input must be a spectrogram
2
3function s2 = whiten(s,fmax)
4
[58]5%Not sure about this, but the paper seems to assume this
6s = abs(s);
[55]7
[58]8%Values output by spectrogram are already in [0, 1] range?
9
10
11
[55]12%Square root of spectrogram (of the absolute value?)
13
[58]14%s1 = sqrt(abs(s)); %Version 1
15s1 = s;             %Version for segmentation
16
[55]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);
[58]29%lowestenergy = energy(lowestix);
[55]30
31
32P = nan(Nf,1);
33s2 = s1;
34for f=1:Nf
[58]35    %P(f) = sqrt(eps + sum(s1(f,lowestix).^2));
36   
[59]37    P(f) = sum(s1(f,lowestix)) / length(lowestix);  %Version for segmentation
[55]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.