-
Notifications
You must be signed in to change notification settings - Fork 1
/
spectogramImg.m
43 lines (41 loc) · 1.23 KB
/
spectogramImg.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function newcdata=spectogramImg(cdata)
%% this funciton save the spectogram of the audio signal as inout image for
% further image classification work
%%
[r,c,l]=size(cdata);
% newcdata=cdata;
cnt2=1;cnt1=1;
for ii=1:l
for kk=1:c
C = unique(cdata(:,kk,ii)==255);
cnt=hist(cdata(:,kk,ii)==255,C);
if numel(cnt)==1 && cnt==r
% newcdata(:,kk,:)=[];
colm(ii,cnt2)=kk;cnt2=cnt2+1;
end
end
end
for ii=1:l
for jj=1:r
C = unique(cdata(jj,:,ii)==255);
cnt=hist(cdata(jj,:,ii)==255,C);
if numel(cnt)==1 && cnt==c
% newcdata(jj,:,:)=[];
rows(ii,cnt1)=jj;cnt1=cnt1+1;
end
end
end
for ii=1:l
%%% remove white colmuns in the saved spectogram image
colns=nonzeros(colm(ii,:));
whitecolms=ismember(1:c,colns);
colmno=[1:c];
nonwhitecolm=colmno(~whitecolms);
% newcdata(:,:,ii)=cdata(:,nonwhitecolm,ii);
%%% remove white rowss in the saved spectogram image
nzrow=nonzeros(rows(ii,:));
whiterows=ismember(1:r,nzrow);
rowno=[1:r];
nonwhiterow=rowno(~whiterows);
newcdata(:,:,ii)=cdata(nonwhiterow,nonwhitecolm,ii);
end