Help regarding MATLAB code for Detector in Spectrograms

Started by shar...@yahoo.co.in January 27, 2011
Dear All,

I am working in classifying birds based on their sounds in the audio data that is given to me. Currently I am working on an issue of removing rain drops in the spectrograms that I obtained from the audio data.

I have been given the audio data that was recorded on the entire day. The recordings are 20 min at each time interval (For eg) 1-1:20, 2:20,... 23-23:20). I divided the audio data into 10 secs chunks of 120 chunks at each interval of time ( 120 chunks per 20 min recording). I obtained the respective spectrograms. The spectrograms contain bird sounds and also rain. I have been using an energy detector so far but it doesn't distinguish between the raindrop and the bird sound. It just gives the entire energy of the spectrogram at various thresholds.

In this way I am not able to count the rain drops alone and eliminate it as the energy contains the bird sounds as well. I need to design a new rain drop detector that can disregard bird vocalization. The rain drop in the spectrogram is a single vertical line that has more Bandwidth while the bird sound has less Bandwidth. I need a detector code that takes in High BW i.e) Rain and count the rain drops alone and then remove it.

I would be glad If someone can help me on this.

Thanks,
Sharath

MATLAB code:

close all
clear all
clc
id_total = [];

%%% Read the filenames of the spectrograms from 10 AM to 11 :20 PM
j = 10:1:23;
for j= 10:23
for i = 0:119
if i <= 9
filename = ['PC_20090603_' num2str(j) '0000_000' num2str(i) '.bmp'];
elseif i> && i<
filename = ['PC_20090603_' num2str(j) '0000_00' num2str(i) '.bmp'];
elseif i>0
filename = ['PC_20090603_000000_0' num2str(i) '.bmp'];
end

aaa=imread(filename);
% figure,imshow(aaa)
% Obtain the Energy of the spectrograms
ss=sum(aaa.^2,1);
% figure,plot(ss)
% figure,subplot(211),imshow(aaa); subplot(212),plot(ss)
count = 0;
id = {70};
% Creation of a vector for thresholds
t_vec00:1000:70000;
for t=t_vec
count = count + 1;
id{count} = length(find(ss>t));

end
% Conversion of cell to double
id_1l2mat(id);

id_total = [id_total;id_1];
%plot(t_vec,id_1);
aa = sum(id_total);

end
end

%%% Read the filenames of the spectrograms from 1 AM to 9 :20 AM
id_total1 = [];

for j= 1:9
for i = 0:119
if i <= 9
filename1 = ['PC_20090603_0' num2str(j) '0000_000' num2str(i) '.bmp'];
elseif i> && i<
filename1 = ['PC_20090603_0' num2str(j) '0000_00' num2str(i) '.bmp'];
elseif i>0
filename1 = ['PC_20090603_000000_0' num2str(i) '.bmp'];
end

aaa1=imread(filename1);
% figure,imshow(aaa)
ss1=sum(aaa1.^2,1);
% figure,plot(ss)
% figure,subplot(211),imshow(aaa); subplot(212),plot(ss)
count1 = 0;
id1 = {70};

t_vec100:1000:70000;
for t1=t_vec1
count1 = count1 + 1;
id1{count1} = length(find(ss1>t1));

end
id_1_1l2mat(id1);
id_total1 = [id_total1;id_1_1];
%plot(t_vec,id_1);
aa1 = sum(id_total1);

end
end

id_total2 = [id_total1;id_total];
final_aa = [sum(id_total2(1:120,50:70));sum(id_total2(1:240,50:70));sum(id_total2(1:360,50:70));sum(id_total2(1:480,50:70));sum(id_total2(1:600,50:70));sum(id_total2(1:720,50:70));sum(id_total2(1:840,50:70));sum(id_total2(1:960,50:70));sum(id_total2(1:1080,50:70));sum(id_total2(1:1200,50:70));sum(id_total2(1:1320,50:70));sum(id_total2(1:1440,50:70));sum(id_total2(1:1560,50:70));sum(id_total2(1:1680,50:70));sum(id_total2(1:1800,50:70));sum(id_total2(1:1920,50:70));sum(id_total2(1:2040,50:70));sum(id_total2(1:2160,50:70));sum(id_total2(1:2280,50:70));sum(id_total2(1:2400,50:70));sum(id_total2(1:2520,50:70));sum(id_total2(1:2640,50:70));sum(id_total2(1:2760,50:70))];
% Plotting Cumulative raindrop count with at each time at a constant threshold
plot(final_aa(1:23,15));
title('Threshold at 6.5');
xlabel('Time of the Day');
ylabel('Raindrop Count');
% plot(t_vec,aa)