Mercurial > hg > octave-nkf
changeset 16366:6964e6b92fc1
hot.m: Make colormap compatible with Matlab (bug #36473).
* scripts/image/hot.m: Make colormap compatible with Matlab (bug #36473).
author | Rik <rik@octave.org> |
---|---|
date | Mon, 25 Mar 2013 14:32:49 -0700 |
parents | 8097a052ec57 |
children | 66330c7f6990 48fe490fd633 |
files | scripts/image/hot.m |
diffstat | 1 files changed, 21 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/hot.m +++ b/scripts/image/hot.m @@ -46,12 +46,27 @@ if (n == 1) map = [1, 1, 1]; elseif (n > 1) - x = linspace (0, 1, n)'; - r = (x < 2/5) .* (5/2 * x) ... - + (x >= 2/5); - g = (x >= 2/5 & x < 4/5) .* (5/2 * x - 1) ... - + (x >= 4/5); - b = (x >= 4/5) .* (5 * x - 4); + idx = floor (3/8 * n); + nel = idx; + + r = ones (n, 1); + if (nel > 0) + r(1:idx, 1) = [1:nel]' / nel; + endif + + g = zeros (n, 1); + g(idx+1:2*idx, 1) = r(1:idx); + g(2*idx+1:end, 1) = 1; + + idx = floor (3/4 * n); + if (any (mod (n, 8) == [0, 1, 3, 6])) + idx++; + endif + nel = n - idx + 1; + + b = zeros (n, 1); + b(idx:end, 1) = [1:nel]' / nel; + map = [r, g, b]; else map = zeros (0, 3);