1 |
4 |
dgisselq |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2 |
|
|
%%
|
3 |
|
|
%% Filename: mymap.m
|
4 |
|
|
%%
|
5 |
|
|
%% Project: A Wishbone Controlled PWM (audio) controller
|
6 |
|
|
%%
|
7 |
|
|
%% Purpose: This file generates my favorite spectrogram color map. The map
|
8 |
|
|
%% is designed so that zero maps to black, and one maps to white.
|
9 |
|
|
%% In between the two extremes, the color goes from black to blue, red,
|
10 |
|
|
%% orange, yellow, and then white.
|
11 |
|
|
%%
|
12 |
|
|
%% The one argument given to the colormap is the number of colors
|
13 |
|
|
%% you would like to have in your map. 64 is often sufficient.
|
14 |
|
|
%%
|
15 |
|
|
%% Creator: Dan Gisselquist, Ph.D.
|
16 |
|
|
%% Gisselquist Technology, LLC
|
17 |
|
|
%%
|
18 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
19 |
|
|
%%
|
20 |
|
|
%% Copyright (C) 2017, Gisselquist Technology, LLC
|
21 |
|
|
%%
|
22 |
|
|
%% This program is free software (firmware): you can redistribute it and/or
|
23 |
|
|
%% modify it under the terms of the GNU General Public License as published
|
24 |
|
|
%% by the Free Software Foundation, either version 3 of the License, or (at
|
25 |
|
|
%% your option) any later version.
|
26 |
|
|
%%
|
27 |
|
|
%% This program is distributed in the hope that it will be useful, but WITHOUT
|
28 |
|
|
%% ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
29 |
|
|
%% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
30 |
|
|
%% for more details.
|
31 |
|
|
%%
|
32 |
|
|
%% You should have received a copy of the GNU General Public License along
|
33 |
|
|
%% with this program. (It's in the $(ROOT)/doc directory. Run make with no
|
34 |
|
|
%% target there if the PDF file isn't present.) If not, see
|
35 |
|
|
%% <http://www.gnu.org/licenses/> for a copy.
|
36 |
|
|
%%
|
37 |
|
|
%% License: GPL, v3, as defined and found on www.gnu.org,
|
38 |
|
|
%% http://www.gnu.org/licenses/gpl.html
|
39 |
|
|
%%
|
40 |
|
|
%%
|
41 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
42 |
|
|
%%
|
43 |
|
|
%%
|
44 |
|
|
function [map] = mymap(nclrs)
|
45 |
|
|
|
46 |
|
|
map = zeros(nclrs,3);
|
47 |
|
|
idx = ((1:nclrs)-1)/(nclrs-1);
|
48 |
|
|
|
49 |
|
|
map(:,1) = 1 - cos((idx-1/3)*3*pi)';
|
50 |
|
|
map((idx<1/3),1) = 0;
|
51 |
|
|
map((idx>2/3),1) = 1;
|
52 |
|
|
|
53 |
|
|
map(:,2) = 1 - cos((idx-2/3)*3*pi)';
|
54 |
|
|
map(idx<2/3,2) = 0;
|
55 |
|
|
|
56 |
|
|
map(:,3) = 0.5 * (1-cos(idx*3*pi))';
|
57 |
|
|
map((idx<5/6)&(idx>=2/3),3) = 0;
|
58 |
|
|
map((idx>=5/6),3) = 1-cos((idx(idx>=5/6)-2/3)*1.5*pi)';
|
59 |
|
|
|
60 |
|
|
map(map>1.0) = 1.0;
|
61 |
|
|
map(map<0.0) = 0.0;
|