Fixed the Colormap module

This commit is contained in:
Chinmay Pandhare
2017-07-13 01:03:08 +05:30
parent 0a4a82b006
commit f1ba9cd93c
2 changed files with 22 additions and 6 deletions

View File

@@ -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;

View File

@@ -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;