mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-15 12:50:04 +01:00
Fixed the Colormap module
This commit is contained in:
14
dist/image-sequencer.js
vendored
14
dist/image-sequencer.js
vendored
@@ -35424,14 +35424,15 @@ module.exports = function SegmentedColormap(options) {
|
|||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.title = "Segmented Colormap";
|
options.title = "Segmented Colormap";
|
||||||
var output
|
options.colormap = options.colormap || "default";
|
||||||
|
var output;
|
||||||
|
|
||||||
function draw(input,callback) {
|
function draw(input,callback) {
|
||||||
this_ = this;
|
this_ = this;
|
||||||
function changePixel(r, g, b, a) {
|
function changePixel(r, g, b, a) {
|
||||||
var ndvi = (r - b) / (r + b);
|
var ndvi = (b - r) / (r + b);
|
||||||
var normalized = (ndvi + 1) / 2;
|
var normalized = (ndvi + 1) / 2;
|
||||||
var res = default_colormap(normalized);
|
var res = colormaps[options.colormap](normalized);
|
||||||
return [res[0], res[1], res[2], 255];
|
return [res[0], res[1], res[2], 255];
|
||||||
}
|
}
|
||||||
function output(image,datauri,mimetype){
|
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 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) {
|
function segmented_colormap(segments) {
|
||||||
return function(x) {
|
return function(x) {
|
||||||
var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3;
|
var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3;
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ module.exports = function SegmentedColormap(options) {
|
|||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.title = "Segmented Colormap";
|
options.title = "Segmented Colormap";
|
||||||
var output
|
options.colormap = options.colormap || "default";
|
||||||
|
var output;
|
||||||
|
|
||||||
function draw(input,callback) {
|
function draw(input,callback) {
|
||||||
this_ = this;
|
this_ = this;
|
||||||
function changePixel(r, g, b, a) {
|
function changePixel(r, g, b, a) {
|
||||||
var ndvi = (r - b) / (r + b);
|
var ndvi = (b - r) / (r + b);
|
||||||
var normalized = (ndvi + 1) / 2;
|
var normalized = (ndvi + 1) / 2;
|
||||||
var res = default_colormap(normalized);
|
var res = colormaps[options.colormap](normalized);
|
||||||
return [res[0], res[1], res[2], 255];
|
return [res[0], res[1], res[2], 255];
|
||||||
}
|
}
|
||||||
function output(image,datauri,mimetype){
|
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 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) {
|
function segmented_colormap(segments) {
|
||||||
return function(x) {
|
return function(x) {
|
||||||
var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3;
|
var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3;
|
||||||
|
|||||||
Reference in New Issue
Block a user