% directory where the WAV-files of the birds are stored:
dpath = fullfile(mildatapath,'birds');

fname = 'PC13_20090531_050000_1.wav';
%fname = 'PC8_20090531_050000_99.wav';
[signal,fs] = wavread(fullfile(dpath,'wavs',fname));

[S,f,t] = spectrogram(signal,512,256,[],fs);

figure(2); clf; showspec(S,f,t);
figure(3); clf; showspec(imag(S), f,t);

% smooth and threshold the spectrogram?
G = fspecial('gaussian',[5 5],2); % window 5x5, sigma=2
I = imfilter(abs(S),G,'same');
t = dd_threshold(I(:),0.8);
mask = (I>t);
mask(f<2000,:) = 0;

figure(4); clf; imagesc(mask); axis xy;


