diff --git a/dist/image-sequencer.js b/dist/image-sequencer.js index 3c6ef06d..b1d30aac 100644 --- a/dist/image-sequencer.js +++ b/dist/image-sequencer.js @@ -35424,14 +35424,15 @@ module.exports = function SegmentedColormap(options) { options = options || {}; options.title = "Segmented Colormap"; - var output + options.colormap = options.colormap || "default"; + var output; function draw(input,callback) { this_ = this; function changePixel(r, g, b, a) { - var ndvi = (r - b) / (r + b); + var ndvi = (b - r) / (r + b); var normalized = (ndvi + 1) / 2; - var res = default_colormap(normalized); + var res = colormaps[options.colormap](normalized); return [res[0], res[1], res[2], 255]; } function output(image,datauri,mimetype){ @@ -35461,6 +35462,13 @@ var stretched_colormap = segmented_colormap([[0, [0, 0, 255], [0, 0, 255]], [0.1 var fastie_colormap = segmented_colormap([[0, [255, 255, 255], [0, 0, 0]], [0.167, [0, 0, 0], [255, 255, 255]], [0.33, [255, 255, 255], [0, 0, 0]], [0.5, [0, 0, 0], [140, 140, 255]], [0.55, [140, 140, 255], [0, 255, 0]], [0.63, [0, 255, 0], [255, 255, 0]], [0.75, [255, 255, 0], [255, 0, 0]], [0.95, [255, 0, 0], [255, 0, 255]]]); +var colormaps = { + greyscale: greyscale_colormap, + default: default_colormap, + stretched: stretched_colormap, + fastie: fastie_colormap +} + function segmented_colormap(segments) { return function(x) { var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3; diff --git a/src/modules/SegmentedColormap.js b/src/modules/SegmentedColormap.js index 1615f184..005a3cd2 100644 --- a/src/modules/SegmentedColormap.js +++ b/src/modules/SegmentedColormap.js @@ -2,14 +2,15 @@ module.exports = function SegmentedColormap(options) { options = options || {}; options.title = "Segmented Colormap"; - var output + options.colormap = options.colormap || "default"; + var output; function draw(input,callback) { this_ = this; function changePixel(r, g, b, a) { - var ndvi = (r - b) / (r + b); + var ndvi = (b - r) / (r + b); var normalized = (ndvi + 1) / 2; - var res = default_colormap(normalized); + var res = colormaps[options.colormap](normalized); return [res[0], res[1], res[2], 255]; } function output(image,datauri,mimetype){ @@ -39,6 +40,13 @@ var stretched_colormap = segmented_colormap([[0, [0, 0, 255], [0, 0, 255]], [0.1 var fastie_colormap = segmented_colormap([[0, [255, 255, 255], [0, 0, 0]], [0.167, [0, 0, 0], [255, 255, 255]], [0.33, [255, 255, 255], [0, 0, 0]], [0.5, [0, 0, 0], [140, 140, 255]], [0.55, [140, 140, 255], [0, 255, 0]], [0.63, [0, 255, 0], [255, 255, 0]], [0.75, [255, 255, 0], [255, 0, 0]], [0.95, [255, 0, 0], [255, 0, 255]]]); +var colormaps = { + greyscale: greyscale_colormap, + default: default_colormap, + stretched: stretched_colormap, + fastie: fastie_colormap +} + function segmented_colormap(segments) { return function(x) { var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3;