Mercurial > hg > simscene-py
comparison nonExposed/coloredSpectrumVisualization.m @ 34:39399de892ef
better handling of displays with pleasantness colors
author | Mathieu Lagrange <mathieu.lagrange@cnrs.fr> |
---|---|
date | Fri, 09 Jun 2017 16:37:50 +0200 |
parents | e26be576f241 |
children |
comparison
equal
deleted
inserted
replaced
33:d0ceb549f734 | 34:39399de892ef |
---|---|
3 wStep=1024; | 3 wStep=1024; |
4 wSize=wStep*2; | 4 wSize=wStep*2; |
5 maxFreqBin=400; | 5 maxFreqBin=400; |
6 | 6 |
7 % Producing a colored spectrum visualization | 7 % Producing a colored spectrum visualization |
8 | |
8 for i=1:size(tracks,1) | 9 for i=1:size(tracks,1) |
9 spec = log(1+abs(spectrogram(tracks(i,:), hanning(wSize), wStep, wSize))); | 10 spec = log(1+abs(spectrogram(tracks(i,:), hanning(wSize), wStep, wSize))); |
10 spec = min(1, spec ./ max(spec(:))); | 11 spec = min(1, spec ./ max(spec(:))); |
11 spec = spec(1:maxFreqBin,:); | 12 spec = spec(1:maxFreqBin,:); |
12 spec = flipud(spec); | 13 spec = flipud(spec); |
13 for colorComp=1:3 | 14 % black background |
14 if (i==1) | 15 % for colorComp=1:3 |
15 img(:,:,colorComp) = settingFigure.cmap(i,colorComp)*spec; | 16 % if (i==1) |
16 else | 17 % img(:,:,colorComp) = settingFigure.cmap(i,colorComp)*spec; |
17 img(:,:,colorComp) = img(:,:,colorComp)+settingFigure.cmap(i,colorComp)*spec; | 18 % else |
18 end | 19 % img(:,:,colorComp) = img(:,:,colorComp)+settingFigure.cmap(i,colorComp)*spec; |
20 % end | |
21 % end | |
22 %white background | |
23 if i==1 | |
24 img = ones(size(spec, 1), size(spec, 2), 3)*.4; | |
25 end | |
26 for colorComp=1:3 | |
27 img(:,:,colorComp) = (1-spec).*img(:,:,colorComp)+settingFigure.cmap(i,colorComp)*spec; | |
19 end | 28 end |
20 end | 29 end |
21 | 30 |
22 | 31 |
23 | 32 |
40 ytick=0:50:maxFreqBin; % every 500 Hz | 49 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)); | 50 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)') | 51 xlabel('time (sec)') |
43 ylabel('Frequency (Hz)') | 52 ylabel('Frequency (Hz)') |
44 | 53 |
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) | 54 set(findall(f,'-property','FontSize'),'FontSize',settingFigure.FontSize) |
50 set(findall(f,'-property','FontName'),'FontName','Arial') | 55 set(findall(f,'-property','FontName'),'FontName','Arial') |
51 | 56 |
52 print(f,fileName,'-dpng') | 57 if figuresOption == 1 |
53 | 58 set(f,'PaperUnits','centimeters') |
59 set(f,'PaperPositionMode','manual') | |
60 set(f,'papersize',[settingFigure.width,settingFigure.height]) | |
61 set(f,'paperposition',[0,0,settingFigure.width,settingFigure.height]) | |
62 | |
63 print(f,fileName,'-dpng') | |
54 end | 64 end |
55 | 65 |