Mercurial > hg > simscene-py
comparison nonExposed/coloredSpectrumVisualization.m @ 21:e26be576f241
add figure functions and beta version of getClassInfo
author | gregoire lafay <gregoirelafay@sfr.fr> |
---|---|
date | Thu, 14 Jan 2016 06:54:31 +0100 |
parents | |
children | 39399de892ef |
comparison
equal
deleted
inserted
replaced
20:3e78af49b119 | 21:e26be576f241 |
---|---|
1 function [] = coloredSpectrumVisualization(tracks,figNum,settingFigure,figuresOption,fileName,sr) | |
2 | |
3 wStep=1024; | |
4 wSize=wStep*2; | |
5 maxFreqBin=400; | |
6 | |
7 % Producing a colored spectrum visualization | |
8 for i=1:size(tracks,1) | |
9 spec = log(1+abs(spectrogram(tracks(i,:), hanning(wSize), wStep, wSize))); | |
10 spec = min(1, spec ./ max(spec(:))); | |
11 spec = spec(1:maxFreqBin,:); | |
12 spec = flipud(spec); | |
13 for colorComp=1:3 | |
14 if (i==1) | |
15 img(:,:,colorComp) = settingFigure.cmap(i,colorComp)*spec; | |
16 else | |
17 img(:,:,colorComp) = img(:,:,colorComp)+settingFigure.cmap(i,colorComp)*spec; | |
18 end | |
19 end | |
20 end | |
21 | |
22 | |
23 | |
24 | |
25 img = img/max(img(:)); | |
26 | |
27 switch figuresOption | |
28 case 1 | |
29 f=figure('Visible', 'off'); | |
30 case 2 | |
31 f=figure(figNum); | |
32 end | |
33 | |
34 | |
35 clf; | |
36 imagesc(img); | |
37 xlim([0 size(img,2)]) | |
38 ylim([0 maxFreqBin]) | |
39 xtick=0:round(settingFigure.sr/wStep*20):size(img,2); % every 20 sec | |
40 ytick=0:50:maxFreqBin; % every 500 Hz | |
41 set(gca,'YTick',0:50:maxFreqBin,'YTicklabel', fliplr(round(ytick*settingFigure.sr/wSize)),'xtick',xtick,'xTicklabel',round(xtick*wStep/settingFigure.sr)); | |
42 xlabel('time (sec)') | |
43 ylabel('Frequency (Hz)') | |
44 | |
45 set(f,'PaperUnits','centimeters') | |
46 set(f,'PaperPositionMode','manual') | |
47 set(f,'papersize',[settingFigure.width,settingFigure.height]) | |
48 set(f,'paperposition',[0,0,settingFigure.width,settingFigure.height]) | |
49 set(findall(f,'-property','FontSize'),'FontSize',settingFigure.FontSize) | |
50 set(findall(f,'-property','FontName'),'FontName','Arial') | |
51 | |
52 print(f,fileName,'-dpng') | |
53 | |
54 end | |
55 |