-
Notifications
You must be signed in to change notification settings - Fork 326
/
compute_alpha_map.m
44 lines (37 loc) · 908 Bytes
/
compute_alpha_map.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
44
function [a,c] = compute_alpha_map(aname, options)
% compute_alpha_map - set up alphamap
%
% [a,c] = compute_alpha_map(aname, options);
%
% aname is the name of the alphamap can be 'rampup', 'rampdown', 'gaussian'.
%
% a is an alphamap.
%
% Copyright (c) 2007 Gabriel Peyre
if nargin<2
cname = 'jet';
end
options.null = 0;
nalpha = getoptions(options, 'nalpha',256);
sigma = getoptions(options, 'sigma',.08);
c = getoptions(options, 'center',.4);
x = linspace(0,1,nalpha);
switch lower(aname)
case 'rampup'
a = x;
case 'rampdown'
a = 1-x;
case 'gaussian'
a = exp( -(x-c).^2 / (2*sigma^2) );
end
alphamap(a);
cname = getoptions(options, 'cname', 'jet');
% compute an associate colormap
c0 = eval([cname '(256);']);
nc = size(c0,1);
si = rescale(cumsum(a));
s = linspace(0,1,nc);
c = zeros(length(si),3);
for i=1:3
c(:,i) = interp1(s,c0(:,i),si);
end