diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a172dc2929..93d735f3db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -191,33 +191,240 @@ All module folders must have an `info.json` file which looks like the following: "url": "Optional link to module's source code or documentation", "inputs": { "var1": { - "type": "text", - "default": "default value" + "type": "string", + "default": "default value", + "htmlType": + { + "type": "text", + } } }, "outputs": { "out1": { - "type": "text" + "type": "integer", + "htmlType": + { + "type": "text" + } + } + } +} +``` + +#### Contains: +- `name` +- `description` +- `url` (optional) +- `inputs` +- `outputs` + +##### `name`(*string*)(required): +The name of the module + +e.g: +```json + { + "name": "Average" + } +``` + +##### `description`(*string*)(required): +Description for the module + +e.g: +```json + { + "name": "Average", + "description": "Average all pixel color", + } +``` + +##### `url`(*string*)(optional): +URL linking to docs for the module in `docs/MOULES.md` + +e.g: +```json + { + "name": "Brightness", + "url": "https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" + } +``` + +##### `inputs`(*object*)(optional): +Contains objects with keys equal to the input names. + +Each object has: +- `type` +- `desc` +- `default` +- `htmlType` + +e.g: +```json +{ + "inputs": + { + "input1": + { + "type": "string", + "htmlType": + { + "type": "text" + } } } } ``` -Types may be one of "text", "integer", "float", "select". -Integer and Float types should also specify minimum and maximum values like this: +###### `type`(*string*)(required) +May be one of `integer`, `float`, `percentage`, `string`, `PATH`, `URL`, `select` etc. + +```json +{ + "var1": { + "type": "percentage", + } +} +``` + +###### `desc`(*string*)(required) +Description for the input. + +```json +{ + "var1": { + "type": "percentage", + "desc": "Module Description" + } +} +``` + +###### `default`(*string*|*number*)(required) +Default value for the input. + +e.g: +```json +{ + "type": "text", + "default": "default value" +} +``` + +###### `htmlType`(*object*)(required) +Can contain: +- `type` +- `step` +- `values` +- `placeholder` +- `min` (optional*) +- `max` (optional*) +e.g: ```json -"var1": { - "type": "integer", +{ + "htmlType": + { + "type": "range", + "min": 0, + "max": 1, + "step": 0.1, + } +} +``` + +###### `type`(*string*)(required) +Any valid html type. Can be `range`, `select`, `number`, `text`. + +e.g: +```json +{ + "type": "text" +} +``` + +###### `step`(*number*)(optional) +Step value for `range` type inputs. Defaults to `1` for `range` type inputs. + +e.g: +```json +{ + "type": "range", "min": 0, - "max": 4, - "default": 1 + "max": 1, + "step": 0.1 } ``` -Similarly, "Select" type inputs should have a `values` array. +###### `values`(*array*)(optional*) +Array of string values for `select` type inputs. Required for `select` type inputs. + +e.g: +```json +{ + "type": "select", + "values": ["val1", "val2", "val3"] +} +``` + +###### `placeholder`(*string*)(optional) +A placeholder for the input. + +e.g: +```json +{ + "type": "text", + "placeholder": "example placeholder" +} +``` + +###### `min`(*number*)(optional*) +Minimum value for `range` type inputs. Required for `range` type inputs. + +e.g: +```json +{ + "type": "range", + "min": 0, + "max": 1 +} +``` + +###### `max`(*number*)(optional*) +Maximum value for `range` htmlType inputs. Required for `range` type inputs. + +e.g: +```json +{ + "type": "range", + "min": 0, + "max": 1 +} +``` + +##### `outputs`(*object*)(optional): +Contains objects with keys equal to the output names. Similar to the inputs object. + +Each object has: +- `type` +- `desc` +- `htmlType` + +e.g: +```json +{ + "outputs": + { + "output1":{ + "type": "string", + "htmlType": + { + "type": "text" + } + } + } +} +``` -Also, A module may have output values. These must be defined as shown above. ### Progress reporting diff --git a/dist/image-sequencer-ui.js b/dist/image-sequencer-ui.js index cc4c77360f..aed50f4c0d 100644 --- a/dist/image-sequencer-ui.js +++ b/dist/image-sequencer-ui.js @@ -155,8 +155,8 @@ function DefaultHtmlStepUi(_sequencer, options) {
Press apply to see changes
Select a new module to add to your sequence.
Brightness
Contrast
Saturation
Rotate
Crop
Averages (r, g, b, a): " + sum.join(', ') + "
"); - return pixels; - } - - function output(image, datauri, mimetype){ - - // This output is accessible by Image Sequencer - step.output = { - src: datauri, - format: mimetype - }; - } - - return require('../_nomodule/PixelManipulation.js')(input, { - output: output, - changePixel: changePixel, - extraManipulation: extraManipulation, - format: input.format, - image: options.image, - callback: callback - }); - - } - return { - options: options, - draw: draw, - output: output, - UI: UI - } -} +/* +* Average all pixel colors +*/ +module.exports = function Average(options, UI){ + + options.blur = options.blur || 2 + var output; + + options.step.metadata = options.step.metadata || {}; + + function draw(input,callback,progressObj){ + + progressObj.stop(true); + progressObj.overrideFlag = true; + + var step = this; + + function changePixel(r, g, b, a){ + return [r,g,b,a] + } + + // do the averaging + function extraManipulation(pixels){ + var sum = [0,0,0,0]; + for (var i = 0; i < pixels.data.length; i += 4) { + sum[0] += pixels.data[i + 0]; + sum[1] += pixels.data[i + 1]; + sum[2] += pixels.data[i + 2]; + sum[3] += pixels.data[i + 3]; + } + + sum[0] = parseInt(sum[0] / (pixels.data.length / 4)); + sum[1] = parseInt(sum[1] / (pixels.data.length / 4)); + sum[2] = parseInt(sum[2] / (pixels.data.length / 4)); + sum[3] = parseInt(sum[3] / (pixels.data.length / 4)); + + for (var i = 0; i < pixels.data.length; i += 4) { + pixels.data[i + 0] = sum[0]; + pixels.data[i + 1] = sum[1]; + pixels.data[i + 2] = sum[2]; + pixels.data[i + 3] = sum[3]; + } + // report back and store average in metadata: + options.step.metadata.averages = sum; + console.log("average: ", sum); + // TODO: refactor into a new "display()" method as per https://github.com/publiclab/image-sequencer/issues/242 + if (options.step.inBrowser && options.step.ui) $(options.step.ui).find('.details').append("Averages (r, g, b, a): " + sum.join(', ') + "
"); + return pixels; + } + + function output(image, datauri, mimetype){ + + // This output is accessible by Image Sequencer + step.output = { + src: datauri, + format: mimetype + }; + } + + return require('../_nomodule/PixelManipulation.js')(input, { + output: output, + changePixel: changePixel, + extraManipulation: extraManipulation, + format: input.format, + image: options.image, + callback: callback + }); + + } + return { + options: options, + draw: draw, + output: output, + UI: UI + } +} },{"../_nomodule/PixelManipulation.js":253}],162:[function(require,module,exports){ -module.exports = [ - require('./Module'), - require('./info.json') +module.exports = [ + require('./Module'), + require('./info.json') ] },{"./Module":161,"./info.json":163}],163:[function(require,module,exports){ -module.exports={ - "name": "Average", - "description": "Average all pixel color", - "inputs": { - }, - "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" -} +module.exports={ + "name": "Average", + "description": "Average all pixel color", + "inputs": { + }, + "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" +} },{}],164:[function(require,module,exports){ -module.exports = function Dynamic(options, UI, util) { - - options.func = options.func || "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }"; - options.offset = options.offset || -2; - - var output; - - // This function is called on every draw. - function draw(input, callback, progressObj) { - - progressObj.stop(true); - progressObj.overrideFlag = true; - - var step = this; - - // convert to runnable code: - if (typeof options.func === "string") eval('options.func = ' + options.func); - - var getPixels = require('get-pixels'); - - // convert offset as string to int - if(typeof options.offset === "string") options.offset = parseInt(options.offset); - - // save first image's pixels - var priorStep = this.getStep(options.offset); - - getPixels(priorStep.output.src, function(err, pixels) { - options.firstImagePixels = pixels; - - function changePixel(r2, g2, b2, a2, x, y) { - // blend! - var p = options.firstImagePixels; - return options.func( - r2, g2, b2, a2, - p.get(x, y, 0), - p.get(x, y, 1), - p.get(x, y, 2), - p.get(x, y, 3) - ) - } - - function output(image, datauri, mimetype) { - - // This output is accessible by Image Sequencer - step.output = { src: datauri, format: mimetype }; - - } - - // run PixelManipulatin on second image's pixels - return require('../_nomodule/PixelManipulation.js')(input, { - output: output, - changePixel: changePixel, - format: input.format, - image: options.image, - inBrowser: options.inBrowser, - callback: callback - }); - }); - } - - return { - options: options, - draw: draw, - output: output, - UI: UI - } -} +module.exports = function Dynamic(options, UI, util) { + + options.func = options.func || "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }"; + options.offset = options.offset || -2; + + var output; + + // This function is called on every draw. + function draw(input, callback, progressObj) { + + progressObj.stop(true); + progressObj.overrideFlag = true; + + var step = this; + + // convert to runnable code: + if (typeof options.func === "string") eval('options.func = ' + options.func); + + var getPixels = require('get-pixels'); + + // convert offset as string to int + if(typeof options.offset === "string") options.offset = parseInt(options.offset); + + // save first image's pixels + var priorStep = this.getStep(options.offset); + + getPixels(priorStep.output.src, function(err, pixels) { + options.firstImagePixels = pixels; + + function changePixel(r2, g2, b2, a2, x, y) { + // blend! + var p = options.firstImagePixels; + return options.func( + r2, g2, b2, a2, + p.get(x, y, 0), + p.get(x, y, 1), + p.get(x, y, 2), + p.get(x, y, 3) + ) + } + + function output(image, datauri, mimetype) { + + // This output is accessible by Image Sequencer + step.output = { src: datauri, format: mimetype }; + + } + + // run PixelManipulatin on second image's pixels + return require('../_nomodule/PixelManipulation.js')(input, { + output: output, + changePixel: changePixel, + format: input.format, + image: options.image, + inBrowser: options.inBrowser, + callback: callback + }); + }); + } + + return { + options: options, + draw: draw, + output: output, + UI: UI + } +} },{"../_nomodule/PixelManipulation.js":253,"get-pixels":29}],165:[function(require,module,exports){ arguments[4][162][0].apply(exports,arguments) },{"./Module":164,"./info.json":166,"dup":162}],166:[function(require,module,exports){ -module.exports={ - "name": "Blend", - "description": "Blend two chosen image steps with the given function. Defaults to using the red channel from image 1 and the green and blue and alpha channels of image 2. Easier to use interfaces coming soon!", - "inputs": { - "offset": { - "type": "integer", - "desc": "Choose which image to blend the current image with. Two steps back is -2, three steps back is -3 etc.", - "default": -2 - }, - "blend": { - "type": "input", - "desc": "Function to use to blend the two images.", - "default": "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }" - } - }, - "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" -} +module.exports={ + "name": "Blend", + "description": "Blend two chosen image steps with the given function. Defaults to using the red channel from image 1 and the green and blue and alpha channels of image 2. Easier to use interfaces coming soon!", + "inputs": { + "offset": { + "type": "integer", + "desc": "Choose which image to blend the current image with. Two steps back is -2, three steps back is -3 etc.", + "default": -2, + "htmlType": + { + "type": "number" + } + }, + "blend": { + "type": "string", + "desc": "Function to use to blend the two images.", + "default": "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }", + "htmlType": + { + "type": "text" + } + } + }, + "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" +} },{}],167:[function(require,module,exports){ -module.exports = exports = function(pixels, blur) { - let kernel = kernelGenerator(blur, 1), oldpix = pixels; - kernel = flipKernel(kernel); - - for (let i = 0; i < pixels.shape[0]; i++) { - for (let j = 0; j < pixels.shape[1]; j++) { - let neighboutPos = getNeighbouringPixelPositions([i, j]); - let acc = [0.0, 0.0, 0.0, 0.0]; - for (let a = 0; a < kernel.length; a++) { - for (let b = 0; b < kernel.length; b++) { - acc[0] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 0) * kernel[a][b]); - acc[1] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 1) * kernel[a][b]); - acc[2] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 2) * kernel[a][b]); - acc[3] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 3) * kernel[a][b]); - } - } - pixels.set(i, j, 0, acc[0]); - pixels.set(i, j, 1, acc[1]); - pixels.set(i, j, 2, acc[2]); - } - } - return pixels; - - - - //Generates a 3x3 Gaussian kernel - function kernelGenerator(sigma, size) { - - /* - Trying out a variable radius kernel not working as of now - */ - // const coeff = (1.0/(2.0*Math.PI*sigma*sigma)) - // const expCoeff = -1 * (1.0/2.0 * sigma * sigma) - // let e = Math.E - // let result = [] - // for(let i = -1 * size;i<=size;i++){ - // let arr = [] - // for(let j= -1 * size;j<=size;j++){ - // arr.push(coeff * Math.pow(e,expCoeff * ((i * i) + (j*j)))) - // } - // result.push(arr) - // } - // let sum = result.reduce((sum,val)=>{ - // return val.reduce((sumInner,valInner)=>{ - // return sumInner+valInner - // }) - // }) - // result = result.map(arr=>arr.map(val=>(val + 0.0)/(sum + 0.0))) - - // return result - - return [ - [2.0 / 159.0, 4.0 / 159.0, 5.0 / 159.0, 4.0 / 159.0, 2.0 / 159.0], - [4.0 / 159.0, 9.0 / 159.0, 12.0 / 159.0, 9.0 / 159.0, 4.0 / 159.0], - [5.0 / 159.0, 12.0 / 159.0, 15.0 / 159.0, 12.0 / 159.0, 5.0 / 159.0], - [4.0 / 159.0, 9.0 / 159.0, 12.0 / 159.0, 9.0 / 159.0, 4.0 / 159.0], - [2.0 / 159.0, 4.0 / 159.0, 5.0 / 159.0, 4.0 / 159.0, 2.0 / 159.0] - ]; - } - function getNeighbouringPixelPositions(pixelPosition) { - let x = pixelPosition[0], y = pixelPosition[1], result = []; - - for (let i = -2; i <= 2; i++) { - let arr = []; - for (let j = -2; j <= 2; j++) - arr.push([x + i, y + j]); - - result.push(arr); - } - return result; - } - - function flipKernel(kernel) { - let result = []; - for (let i = kernel.length - 1; i >= 0; i--) { - let arr = []; - for (let j = kernel[i].length - 1; j >= 0; j--) { - arr.push(kernel[i][j]); - } - result.push(arr); - } - return result; - } +module.exports = exports = function(pixels, blur) { + let kernel = kernelGenerator(blur, 1), oldpix = pixels; + kernel = flipKernel(kernel); + + for (let i = 0; i < pixels.shape[0]; i++) { + for (let j = 0; j < pixels.shape[1]; j++) { + let neighboutPos = getNeighbouringPixelPositions([i, j]); + let acc = [0.0, 0.0, 0.0, 0.0]; + for (let a = 0; a < kernel.length; a++) { + for (let b = 0; b < kernel.length; b++) { + acc[0] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 0) * kernel[a][b]); + acc[1] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 1) * kernel[a][b]); + acc[2] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 2) * kernel[a][b]); + acc[3] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 3) * kernel[a][b]); + } + } + pixels.set(i, j, 0, acc[0]); + pixels.set(i, j, 1, acc[1]); + pixels.set(i, j, 2, acc[2]); + } + } + return pixels; + + + + //Generates a 3x3 Gaussian kernel + function kernelGenerator(sigma, size) { + + /* + Trying out a variable radius kernel not working as of now + */ + // const coeff = (1.0/(2.0*Math.PI*sigma*sigma)) + // const expCoeff = -1 * (1.0/2.0 * sigma * sigma) + // let e = Math.E + // let result = [] + // for(let i = -1 * size;i<=size;i++){ + // let arr = [] + // for(let j= -1 * size;j<=size;j++){ + // arr.push(coeff * Math.pow(e,expCoeff * ((i * i) + (j*j)))) + // } + // result.push(arr) + // } + // let sum = result.reduce((sum,val)=>{ + // return val.reduce((sumInner,valInner)=>{ + // return sumInner+valInner + // }) + // }) + // result = result.map(arr=>arr.map(val=>(val + 0.0)/(sum + 0.0))) + + // return result + + return [ + [2.0 / 159.0, 4.0 / 159.0, 5.0 / 159.0, 4.0 / 159.0, 2.0 / 159.0], + [4.0 / 159.0, 9.0 / 159.0, 12.0 / 159.0, 9.0 / 159.0, 4.0 / 159.0], + [5.0 / 159.0, 12.0 / 159.0, 15.0 / 159.0, 12.0 / 159.0, 5.0 / 159.0], + [4.0 / 159.0, 9.0 / 159.0, 12.0 / 159.0, 9.0 / 159.0, 4.0 / 159.0], + [2.0 / 159.0, 4.0 / 159.0, 5.0 / 159.0, 4.0 / 159.0, 2.0 / 159.0] + ]; + } + function getNeighbouringPixelPositions(pixelPosition) { + let x = pixelPosition[0], y = pixelPosition[1], result = []; + + for (let i = -2; i <= 2; i++) { + let arr = []; + for (let j = -2; j <= 2; j++) + arr.push([x + i, y + j]); + + result.push(arr); + } + return result; + } + + function flipKernel(kernel) { + let result = []; + for (let i = kernel.length - 1; i >= 0; i--) { + let arr = []; + for (let j = kernel[i].length - 1; j >= 0; j--) { + arr.push(kernel[i][j]); + } + result.push(arr); + } + return result; + } } },{}],168:[function(require,module,exports){ -/* -* Blur an Image -*/ -module.exports = function Blur(options, UI) { - - options.blur = options.blur || 2 - var output; - - function draw(input, callback, progressObj) { - - progressObj.stop(true); - progressObj.overrideFlag = true; - - var step = this; - - function changePixel(r, g, b, a) { - return [r, g, b, a] - } - - function extraManipulation(pixels) { - pixels = require('./Blur')(pixels, options.blur) - return pixels - } - - function output(image, datauri, mimetype) { - - // This output is accessible by Image Sequencer - step.output = { src: datauri, format: mimetype }; - - } - - return require('../_nomodule/PixelManipulation.js')(input, { - output: output, - changePixel: changePixel, - extraManipulation: extraManipulation, - format: input.format, - image: options.image, - callback: callback - }); - - } - return { - options: options, - draw: draw, - output: output, - UI: UI - } -} +/* +* Blur an Image +*/ +module.exports = function Blur(options, UI) { + + options.blur = options.blur || 2 + var output; + + function draw(input, callback, progressObj) { + + progressObj.stop(true); + progressObj.overrideFlag = true; + + var step = this; + + function changePixel(r, g, b, a) { + return [r, g, b, a] + } + + function extraManipulation(pixels) { + pixels = require('./Blur')(pixels, options.blur) + return pixels + } + + function output(image, datauri, mimetype) { + + // This output is accessible by Image Sequencer + step.output = { src: datauri, format: mimetype }; + + } + + return require('../_nomodule/PixelManipulation.js')(input, { + output: output, + changePixel: changePixel, + extraManipulation: extraManipulation, + format: input.format, + image: options.image, + callback: callback + }); + + } + return { + options: options, + draw: draw, + output: output, + UI: UI + } +} },{"../_nomodule/PixelManipulation.js":253,"./Blur":167}],169:[function(require,module,exports){ arguments[4][162][0].apply(exports,arguments) },{"./Module":168,"./info.json":170,"dup":162}],170:[function(require,module,exports){ -module.exports={ - "name": "Blur", - "description": "Applies a Gaussian blur given by the intensity value", - "inputs": { - "blur": { - "type": "range", - "desc": "Amount of gaussian blur(Less blur gives more detail, typically 0-5)", - "default": "2", - "min": "0", - "max": "5", - "step": "0.25" - } - }, - "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" -} +module.exports={ + "name": "Blur", + "description": "Applies a Gaussian blur given by the intensity value", + "inputs": { + "blur": { + "type": "float", + "desc": "Amount of gaussian blur(Less blur gives more detail, typically 0-5)", + "default": 2, + "htmlType": + { + "type": "range", + "min": 0, + "max": 5, + "step": 0.25 + } + } + }, + "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" +} },{}],171:[function(require,module,exports){ -/* -* Changes the Image Brightness -*/ - -module.exports = function Brightness(options,UI){ - - - var output; - - function draw(input,callback,progressObj){ - - options.brightness = parseInt(options.brightness) || 100; - var val = (options.brightness)/100.0; - progressObj.stop(true); - progressObj.overrideFlag = true; - - /* - In this case progress is handled by changepixel internally otherwise progressObj - needs to be overriden and used - For eg. progressObj = new SomeProgressModule() - */ - - var step = this; - - function changePixel(r, g, b, a){ - - r = Math.min(val*r, 255) - g = Math.min(val*g, 255) - b = Math.min(val*b, 255) - return [r, g, b, a] - } - - function output(image,datauri,mimetype){ - - // This output is accessible by Image Sequencer - step.output = {src:datauri,format:mimetype}; - - } - - return require('../_nomodule/PixelManipulation.js')(input, { - output: output, - changePixel: changePixel, - format: input.format, - image: options.image, - inBrowser: options.inBrowser, - callback: callback - }); - - } - return { - options: options, - draw: draw, - output: output, - UI: UI - } -} +/* +* Changes the Image Brightness +*/ + +module.exports = function Brightness(options,UI){ + + + var output; + + function draw(input,callback,progressObj){ + + options.brightness = parseInt(options.brightness) || 100; + var val = (options.brightness)/100.0; + progressObj.stop(true); + progressObj.overrideFlag = true; + + /* + In this case progress is handled by changepixel internally otherwise progressObj + needs to be overriden and used + For eg. progressObj = new SomeProgressModule() + */ + + var step = this; + + function changePixel(r, g, b, a){ + + r = Math.min(val*r, 255) + g = Math.min(val*g, 255) + b = Math.min(val*b, 255) + return [r, g, b, a] + } + + function output(image,datauri,mimetype){ + + // This output is accessible by Image Sequencer + step.output = {src:datauri,format:mimetype}; + + } + + return require('../_nomodule/PixelManipulation.js')(input, { + output: output, + changePixel: changePixel, + format: input.format, + image: options.image, + inBrowser: options.inBrowser, + callback: callback + }); + + } + return { + options: options, + draw: draw, + output: output, + UI: UI + } +} },{"../_nomodule/PixelManipulation.js":253}],172:[function(require,module,exports){ arguments[4][162][0].apply(exports,arguments) },{"./Module":171,"./info.json":173,"dup":162}],173:[function(require,module,exports){ -module.exports={ - "name": "Brightness", - "description": "Change the brightness of the image by given percent value", - "inputs": { - "brightness": { - "type": "range", - "desc": "% brightness for the new image", - "default": "175", - "min": "0", - "max": "200", - "step": "1" - } - }, - "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" -} +module.exports={ + "name": "Brightness", + "description": "Change the brightness of the image by given percent value", + "inputs": { + "brightness": { + "type": "float", + "desc": "% brightness for the new image", + "default": 175, + "htmlType": + { + "type": "range", + "min": 0, + "max": 200 + } + } + }, + "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" +} },{}],174:[function(require,module,exports){ -/* - * Display only one color channel - */ -module.exports = function Channel(options, UI) { - - options.channel = options.channel || "green"; - - var output; - - function draw(input, callback, progressObj) { - - progressObj.stop(true); - progressObj.overrideFlag = true; - - var step = this; - - function changePixel(r, g, b, a) { - if (options.channel == "red") return [r, 0, 0, a]; - if (options.channel == "green") return [0, g, 0, a]; - if (options.channel == "blue") return [0, 0, b, a]; - } - - function output(image, datauri, mimetype) { - - // This output is accesible by Image Sequencer - step.output = { src: datauri, format: mimetype }; - - } - - return require('../_nomodule/PixelManipulation.js')(input, { - output: output, - changePixel: changePixel, - format: input.format, - image: options.image, - inBrowser: options.inBrowser, - callback: callback - }); - - } - - return { - options: options, - //setup: setup, // optional - draw: draw, - output: output, - UI: UI - } -} +/* + * Display only one color channel + */ +module.exports = function Channel(options, UI) { + + options.channel = options.channel || "green"; + + var output; + + function draw(input, callback, progressObj) { + + progressObj.stop(true); + progressObj.overrideFlag = true; + + var step = this; + + function changePixel(r, g, b, a) { + if (options.channel == "red") return [r, 0, 0, a]; + if (options.channel == "green") return [0, g, 0, a]; + if (options.channel == "blue") return [0, 0, b, a]; + } + + function output(image, datauri, mimetype) { + + // This output is accesible by Image Sequencer + step.output = { src: datauri, format: mimetype }; + + } + + return require('../_nomodule/PixelManipulation.js')(input, { + output: output, + changePixel: changePixel, + format: input.format, + image: options.image, + inBrowser: options.inBrowser, + callback: callback + }); + + } + + return { + options: options, + //setup: setup, // optional + draw: draw, + output: output, + UI: UI + } +} },{"../_nomodule/PixelManipulation.js":253}],175:[function(require,module,exports){ arguments[4][162][0].apply(exports,arguments) },{"./Module":174,"./info.json":176,"dup":162}],176:[function(require,module,exports){ -module.exports={ - "name": "Channel", - "description": "Displays only one color channel of an image -- default is green", - "inputs": { - "channel": { - "type": "select", - "desc": "Color channel", - "default": "green", - "values": ["red", "green", "blue"] - } - }, - "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" -} +module.exports={ + "name": "Channel", + "description": "Displays only one color channel of an image -- default is green", + "inputs": { + "channel": { + "type": "select", + "desc": "Color channel", + "default": "green", + "htmlType": + { + "type": "select", + "values": ["red", "green", "blue"] + } + } + }, + "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" +} },{}],177:[function(require,module,exports){ -module.exports = function NdviColormapfunction(options, UI) { - - options.x = options.x || 0; - options.y = options.y || 0; - options.colormap = options.colormap || "default"; - options.h = options.h || 10; - this.expandSteps([ - { 'name': 'gradient', 'options': {} }, - { 'name': 'colormap', 'options': { colormap: options.colormap } }, - { 'name': 'crop', 'options': { 'y': 0, 'h': options.h } }, - { 'name': 'overlay', 'options': { 'x': options.x, 'y': options.y, 'offset': -4 } } - ]); - return { - isMeta: true - } +module.exports = function NdviColormapfunction(options, UI) { + + options.x = options.x || 0; + options.y = options.y || 0; + options.colormap = options.colormap || "default"; + options.h = options.h || 10; + this.expandSteps([ + { 'name': 'gradient', 'options': {} }, + { 'name': 'colormap', 'options': { colormap: options.colormap } }, + { 'name': 'crop', 'options': { 'y': 0, 'h': options.h } }, + { 'name': 'overlay', 'options': { 'x': options.x, 'y': options.y, 'offset': -4 } } + ]); + return { + isMeta: true + } } },{}],178:[function(require,module,exports){ arguments[4][162][0].apply(exports,arguments) },{"./Module":177,"./info.json":179,"dup":162}],179:[function(require,module,exports){ -module.exports={ - "name": "Colorbar", - "description": "Generates a colorbar to lay over the image", - "inputs": { - "colormap": { - "type": "select", - "desc": "Name of the Colormap", - "default": "default", - "values": [ - "default", - "greyscale", - "stretched", - "fastie" - ] - }, - "x": { - "type": "integer", - "desc": "X-position of the image on which the new image is overlayed", - "default": 0 - }, - "y": { - "type": "integer", - "desc": "Y-position of the image on which the new image is overlayed", - "default": 0 - }, - "h": { - "type": "iinteger", - "desc": "height of the colorbar", - "default": 10 - } - }, - "length": 4, - "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" +module.exports={ + "name": "Colorbar", + "description": "Generates a colorbar to lay over the image", + "inputs": { + "colormap": { + "type": "select", + "desc": "Name of the Colormap", + "default": "default", + "htmlType": + { + "type": "select", + "values": [ + "default", + "greyscale", + "stretched", + "fastie" + ] + } + }, + "x": { + "type": "integer", + "desc": "X-position of the image on which the new image is overlayed", + "default": 0, + "htmlType": + { + "type": "number" + } + }, + "y": { + "type": "integer", + "desc": "Y-position of the image on which the new image is overlayed", + "default": 0, + "htmlType": + { + "type": "number" + } + }, + "h": { + "type": "integer", + "desc": "height of the colorbar", + "default": 10, + "htmlType": + { + "type": "number" + } + } + }, + "length": 4, + "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" } },{}],180:[function(require,module,exports){ -/* - * Accepts a value from 0-255 and returns the new color-mapped pixel - * from a lookup table, which can be specified as an array of [begin, end] - * gradients, where begin and end are represented as [r, g, b] colors. In - * combination, a lookup table which maps values from 0 - 255 smoothly from black to white looks like: - * [ - * [0, [0, 0, 0], [255, 255, 255]], - * [1, [255, 255, 255], [255, 255, 255]] - * ] - * - * Adapted from bgamari's work in Infragram: https://github.com/p-v-o-s/infragram-js/commit/346c97576a07b71a55671d17e0153b7df74e803b - */ - -module.exports = function Colormap(value, options) { - options.colormap = options.colormap || colormaps.default; - // if a lookup table is provided as an array: - if(typeof(options.colormap) == "object") - colormapFunction = colormap(options.colormap); - // if a stored colormap is named with a string like "fastie": - else if(colormaps.hasOwnProperty(options.colormap)) - colormapFunction = colormaps[options.colormap]; - else colormapFunction = colormaps.default; - return colormapFunction(value / 255.00); -} - -function colormap(segments) { - return function(x) { - var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3; - _ref = [0, 0], y0 = _ref[0], y1 = _ref[1]; - _ref1 = [segments[0][0], 1], x0 = _ref1[0], x1 = _ref1[1]; - if (x < x0) { - return y0; - } - for (i = _i = 0, _len = segments.length; _i < _len; i = ++_i) { - _ref2 = segments[i], xstart = _ref2[0], y0 = _ref2[1], y1 = _ref2[2]; - x0 = xstart; - if (i === segments.length - 1) { - x1 = 1; - break; - } - x1 = segments[i + 1][0]; - if ((xstart <= x && x < x1)) { - break; - } - } - result = []; - for (i = _j = 0, _ref3 = y0.length; 0 <= _ref3 ? _j < _ref3 : _j > _ref3; i = 0 <= _ref3 ? ++_j : --_j) { - result[i] = (x - x0) / (x1 - x0) * (y1[i] - y0[i]) + y0[i]; - } - return result; - }; -}; - -var colormaps = { - greyscale: colormap([ - [0, [0, 0, 0], [255, 255, 255] ], - [1, [255, 255, 255], [255, 255, 255] ] - ]), - - bluwhtgrngis: colormap([ - [0, [6,23,86], [6,25, 84] ], - [0.0625, [6,25,84], [6,25, 84] ],//1 - [0.125, [6,25,84], [6,25, 84] ],//2 - [0.1875, [6,25,84], [6,25, 84] ], - [0.25, [6,25,84], [6,25,84] ], - [0.3125, [6,25,84], [9,24, 84] ],//5 - [0.3438, [9,24, 84], [119,120,162] ],//5 - [0.375, [119,129,162],[249,250,251] ], //6 - [0.406, [249,250,251],[255,255,255] ], //6.5 - [0.4375, [255,255,255],[255,255,255] ], //7 white - [0.50, [255,255,255],[214,205,191] ],//8 - [0.52, [214,205,191],[178,175,96] ],//8.2 - [0.5625, [178,175,96], [151,176,53] ],//9 - [0.593, [151,176,53], [146,188,12] ],//9.5 - [0.625, [146,188,12], [96,161,1] ], //10 - [0.6875, [96,161,1], [30,127,3] ],//11 - [0.75, [30,127,3], [0,99,1] ],//12 - [0.8125, [0,99,1], [0,74,1] ],//13 - [0.875, [0,74,1], [0,52, 0] ],//14 - [0.9375, [0,52, 0], [0,34,0] ], //15 - [0.968, [0,34,0], [68,70,67] ] //16 - ]), - - - brntogrn: colormap([ - [0, [110,12,3], [118,6,1] ], - [0.0625, [118,6,1], [141,19,6] ], - [0.125, [141,19,6], [165,35,13] ], - [0.1875, [165,35,13], [177,59,25] ], - [0.2188, [177,59,25], [192,91,36] ], - [0.25, [192,91,36], [214, 145, 76] ], - [0.3125, [214,145,76], [230,183,134] ], - [0.375, [230,183,134],[243, 224, 194]], - [0.4375, [243,224,194],[250,252,229] ], - [0.50, [250,252,229],[217,235,185] ], - [0.5625, [217,235,185],[184,218,143] ], - [0.625, [184,218,143],[141,202,89] ], - [0.6875, [141,202,89], [80,176,61] ], - [0.75, [80,176,61], [0, 147, 32] ], - [0.8125, [0,147,32], [1, 122, 22] ], - [0.875, [1,122,22], [0, 114, 19] ], - [0.90, [0,114,19], [0,105,18] ], - [0.9375, [0,105,18], [7,70,14] ] - - ]), - - - blutoredjet: colormap([ - [0, [0,0,140], [1,1,186] ], - [0.0625, [1,1,186], [0,1,248] ], - [0.125, [0,1,248], [0,70,254] ], - [0.1875, [0,70,254], [0,130,255] ], - [0.25, [0,130,255], [2,160,255] ], - [0.2813, [2,160,255], [0,187,255] ], //inset - [0.3125, [0,187,255], [6,250,255] ], - // [0.348, [0,218,255], [8,252,251] ],//inset - [0.375, [8,252,251], [27,254,228] ], - [0.406, [27,254,228], [70,255,187] ], //insert - [0.4375, [70,255,187], [104,254,151]], - [0.47, [104,254,151],[132,255,19] ],//insert - [0.50, [132,255,19], [195,255,60] ], - [0.5625, [195,255,60], [231,254,25] ], - [0.5976, [231,254,25], [253,246,1] ],//insert - [0.625, [253,246,1], [252,210,1] ], //yellow - [0.657, [252,210,1], [255,183,0] ],//insert - [0.6875, [255,183,0], [255,125,2] ], - [0.75, [255,125,2], [255,65, 1] ], - [0.8125, [255,65, 1], [247, 1, 1] ], - [0.875, [247,1,1], [200, 1, 3] ], - [0.9375, [200,1,3], [122, 3, 2] ] - - ]), - - - colors16: colormap([ - [0, [0,0,0], [0,0,0] ], - [0.0625, [3,1,172], [3,1,172] ], - [0.125, [3,1,222], [3,1, 222] ], - [0.1875, [0,111,255], [0,111,255] ], - [0.25, [3,172,255], [3,172,255] ], - [0.3125, [1,226,255], [1,226,255] ], - [0.375, [2,255,0], [2,255,0] ], - [0.4375, [198,254,0], [190,254,0] ], - [0.50, [252,255,0], [252,255,0] ], - [0.5625, [255,223,3], [255,223,3] ], - [0.625, [255,143,3], [255,143,3] ], - [0.6875, [255,95,3], [255,95,3] ], - [0.75, [242,0,1], [242,0,1] ], - [0.8125, [245,0,170], [245,0,170] ], - [0.875, [223,180,225], [223,180,225] ], - [0.9375, [255,255,255], [255,255, 255]] - - ]), - - default: colormap([ - [0, [45,1,121], [25,1,137] ], - [0.125, [25,1,137], [0,6,156] ], - [0.1875, [0,6,156], [7,41,172] ], - [0.25, [7,41,172], [22,84,187] ], - [0.3125, [22,84,187], [25,125,194] ], - [0.375, [25,125,194], [26,177,197] ], - [0.4375, [26,177,197], [23,199,193] ], - [0.47, [23,199,193], [25, 200,170] ], - [0.50, [25, 200,170], [21,209,27] ], - [0.5625, [21,209,27], [108,215,18] ], - [0.625, [108,215,18], [166,218,19] ], - [0.6875, [166,218,19], [206,221,20] ], - [0.75, [206,221,20], [222,213,19 ] ], - [0.7813, [222,213,19], [222, 191, 19]], - [0.8125, [222, 191, 19], [227,133,17] ], - [0.875, [227,133,17], [231,83,16] ], - [0.9375, [231,83,16], [220,61,48] ] - - ]), - - - fastie: 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] ] - ]), - - - stretched: colormap([ - [0, [0, 0, 255], [0, 0, 255] ], - [0.1, [0, 0, 255], [38, 195, 195] ], - [0.5, [0, 150, 0], [255, 255, 0] ], - [0.7, [255, 255, 0], [255, 50, 50] ], - [0.9, [255, 50, 50], [255, 50, 50] ] - ]) - +/* + * Accepts a value from 0-255 and returns the new color-mapped pixel + * from a lookup table, which can be specified as an array of [begin, end] + * gradients, where begin and end are represented as [r, g, b] colors. In + * combination, a lookup table which maps values from 0 - 255 smoothly from black to white looks like: + * [ + * [0, [0, 0, 0], [255, 255, 255]], + * [1, [255, 255, 255], [255, 255, 255]] + * ] + * + * Adapted from bgamari's work in Infragram: https://github.com/p-v-o-s/infragram-js/commit/346c97576a07b71a55671d17e0153b7df74e803b + */ + +module.exports = function Colormap(value, options) { + options.colormap = options.colormap || colormaps.default; + // if a lookup table is provided as an array: + if(typeof(options.colormap) == "object") + colormapFunction = colormap(options.colormap); + // if a stored colormap is named with a string like "fastie": + else if(colormaps.hasOwnProperty(options.colormap)) + colormapFunction = colormaps[options.colormap]; + else colormapFunction = colormaps.default; + return colormapFunction(value / 255.00); +} + +function colormap(segments) { + return function(x) { + var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3; + _ref = [0, 0], y0 = _ref[0], y1 = _ref[1]; + _ref1 = [segments[0][0], 1], x0 = _ref1[0], x1 = _ref1[1]; + if (x < x0) { + return y0; + } + for (i = _i = 0, _len = segments.length; _i < _len; i = ++_i) { + _ref2 = segments[i], xstart = _ref2[0], y0 = _ref2[1], y1 = _ref2[2]; + x0 = xstart; + if (i === segments.length - 1) { + x1 = 1; + break; + } + x1 = segments[i + 1][0]; + if ((xstart <= x && x < x1)) { + break; + } + } + result = []; + for (i = _j = 0, _ref3 = y0.length; 0 <= _ref3 ? _j < _ref3 : _j > _ref3; i = 0 <= _ref3 ? ++_j : --_j) { + result[i] = (x - x0) / (x1 - x0) * (y1[i] - y0[i]) + y0[i]; + } + return result; + }; +}; + +var colormaps = { + greyscale: colormap([ + [0, [0, 0, 0], [255, 255, 255] ], + [1, [255, 255, 255], [255, 255, 255] ] + ]), + + bluwhtgrngis: colormap([ + [0, [6,23,86], [6,25, 84] ], + [0.0625, [6,25,84], [6,25, 84] ],//1 + [0.125, [6,25,84], [6,25, 84] ],//2 + [0.1875, [6,25,84], [6,25, 84] ], + [0.25, [6,25,84], [6,25,84] ], + [0.3125, [6,25,84], [9,24, 84] ],//5 + [0.3438, [9,24, 84], [119,120,162] ],//5 + [0.375, [119,129,162],[249,250,251] ], //6 + [0.406, [249,250,251],[255,255,255] ], //6.5 + [0.4375, [255,255,255],[255,255,255] ], //7 white + [0.50, [255,255,255],[214,205,191] ],//8 + [0.52, [214,205,191],[178,175,96] ],//8.2 + [0.5625, [178,175,96], [151,176,53] ],//9 + [0.593, [151,176,53], [146,188,12] ],//9.5 + [0.625, [146,188,12], [96,161,1] ], //10 + [0.6875, [96,161,1], [30,127,3] ],//11 + [0.75, [30,127,3], [0,99,1] ],//12 + [0.8125, [0,99,1], [0,74,1] ],//13 + [0.875, [0,74,1], [0,52, 0] ],//14 + [0.9375, [0,52, 0], [0,34,0] ], //15 + [0.968, [0,34,0], [68,70,67] ] //16 + ]), + + + brntogrn: colormap([ + [0, [110,12,3], [118,6,1] ], + [0.0625, [118,6,1], [141,19,6] ], + [0.125, [141,19,6], [165,35,13] ], + [0.1875, [165,35,13], [177,59,25] ], + [0.2188, [177,59,25], [192,91,36] ], + [0.25, [192,91,36], [214, 145, 76] ], + [0.3125, [214,145,76], [230,183,134] ], + [0.375, [230,183,134],[243, 224, 194]], + [0.4375, [243,224,194],[250,252,229] ], + [0.50, [250,252,229],[217,235,185] ], + [0.5625, [217,235,185],[184,218,143] ], + [0.625, [184,218,143],[141,202,89] ], + [0.6875, [141,202,89], [80,176,61] ], + [0.75, [80,176,61], [0, 147, 32] ], + [0.8125, [0,147,32], [1, 122, 22] ], + [0.875, [1,122,22], [0, 114, 19] ], + [0.90, [0,114,19], [0,105,18] ], + [0.9375, [0,105,18], [7,70,14] ] + + ]), + + + blutoredjet: colormap([ + [0, [0,0,140], [1,1,186] ], + [0.0625, [1,1,186], [0,1,248] ], + [0.125, [0,1,248], [0,70,254] ], + [0.1875, [0,70,254], [0,130,255] ], + [0.25, [0,130,255], [2,160,255] ], + [0.2813, [2,160,255], [0,187,255] ], //inset + [0.3125, [0,187,255], [6,250,255] ], + // [0.348, [0,218,255], [8,252,251] ],//inset + [0.375, [8,252,251], [27,254,228] ], + [0.406, [27,254,228], [70,255,187] ], //insert + [0.4375, [70,255,187], [104,254,151]], + [0.47, [104,254,151],[132,255,19] ],//insert + [0.50, [132,255,19], [195,255,60] ], + [0.5625, [195,255,60], [231,254,25] ], + [0.5976, [231,254,25], [253,246,1] ],//insert + [0.625, [253,246,1], [252,210,1] ], //yellow + [0.657, [252,210,1], [255,183,0] ],//insert + [0.6875, [255,183,0], [255,125,2] ], + [0.75, [255,125,2], [255,65, 1] ], + [0.8125, [255,65, 1], [247, 1, 1] ], + [0.875, [247,1,1], [200, 1, 3] ], + [0.9375, [200,1,3], [122, 3, 2] ] + + ]), + + + colors16: colormap([ + [0, [0,0,0], [0,0,0] ], + [0.0625, [3,1,172], [3,1,172] ], + [0.125, [3,1,222], [3,1, 222] ], + [0.1875, [0,111,255], [0,111,255] ], + [0.25, [3,172,255], [3,172,255] ], + [0.3125, [1,226,255], [1,226,255] ], + [0.375, [2,255,0], [2,255,0] ], + [0.4375, [198,254,0], [190,254,0] ], + [0.50, [252,255,0], [252,255,0] ], + [0.5625, [255,223,3], [255,223,3] ], + [0.625, [255,143,3], [255,143,3] ], + [0.6875, [255,95,3], [255,95,3] ], + [0.75, [242,0,1], [242,0,1] ], + [0.8125, [245,0,170], [245,0,170] ], + [0.875, [223,180,225], [223,180,225] ], + [0.9375, [255,255,255], [255,255, 255]] + + ]), + + default: colormap([ + [0, [45,1,121], [25,1,137] ], + [0.125, [25,1,137], [0,6,156] ], + [0.1875, [0,6,156], [7,41,172] ], + [0.25, [7,41,172], [22,84,187] ], + [0.3125, [22,84,187], [25,125,194] ], + [0.375, [25,125,194], [26,177,197] ], + [0.4375, [26,177,197], [23,199,193] ], + [0.47, [23,199,193], [25, 200,170] ], + [0.50, [25, 200,170], [21,209,27] ], + [0.5625, [21,209,27], [108,215,18] ], + [0.625, [108,215,18], [166,218,19] ], + [0.6875, [166,218,19], [206,221,20] ], + [0.75, [206,221,20], [222,213,19 ] ], + [0.7813, [222,213,19], [222, 191, 19]], + [0.8125, [222, 191, 19], [227,133,17] ], + [0.875, [227,133,17], [231,83,16] ], + [0.9375, [231,83,16], [220,61,48] ] + + ]), + + + fastie: 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] ] + ]), + + + stretched: colormap([ + [0, [0, 0, 255], [0, 0, 255] ], + [0.1, [0, 0, 255], [38, 195, 195] ], + [0.5, [0, 150, 0], [255, 255, 0] ], + [0.7, [255, 255, 0], [255, 50, 50] ], + [0.9, [255, 50, 50], [255, 50, 50] ] + ]) + } },{}],181:[function(require,module,exports){ -module.exports = function Colormap(options,UI) { - - var output; - - // This function is called on every draw. - function draw(input,callback,progressObj) { - - progressObj.stop(true); - progressObj.overrideFlag = true; - - var step = this; - - function changePixel(r, g, b, a) { - var combined = (r + g + b) / 3.000; - var res = require('./Colormap')(combined, options); - return [res[0], res[1], res[2], 255]; - } - - function output(image,datauri,mimetype){ - - // This output is accessible by Image Sequencer - step.output = { src: datauri, format: mimetype }; - - } - return require('../_nomodule/PixelManipulation.js')(input, { - output: output, - changePixel: changePixel, - format: input.format, - image: options.image, - inBrowser: options.inBrowser, - callback: callback - }); - - } - - return { - options: options, - draw: draw, - output: output, - UI: UI - } -} +module.exports = function Colormap(options,UI) { + + var output; + + // This function is called on every draw. + function draw(input,callback,progressObj) { + + progressObj.stop(true); + progressObj.overrideFlag = true; + + var step = this; + + function changePixel(r, g, b, a) { + var combined = (r + g + b) / 3.000; + var res = require('./Colormap')(combined, options); + return [res[0], res[1], res[2], 255]; + } + + function output(image,datauri,mimetype){ + + // This output is accessible by Image Sequencer + step.output = { src: datauri, format: mimetype }; + + } + return require('../_nomodule/PixelManipulation.js')(input, { + output: output, + changePixel: changePixel, + format: input.format, + image: options.image, + inBrowser: options.inBrowser, + callback: callback + }); + + } + + return { + options: options, + draw: draw, + output: output, + UI: UI + } +} },{"../_nomodule/PixelManipulation.js":253,"./Colormap":180}],182:[function(require,module,exports){ arguments[4][162][0].apply(exports,arguments) },{"./Module":181,"./info.json":183,"dup":162}],183:[function(require,module,exports){ -module.exports={ - "name": "Colormap", - "description": "Maps brightness values (average of red, green & blue) to a given color lookup table, made up of a set of one more color gradients.\n\nFor example, 'cooler' colors like blue could represent low values, while 'hot' colors like red could represent high values.", - "inputs": { - "colormap": { - "type": "select", - "desc": "Name of the Colormap", - "default": "default", - "values": ["default","greyscale","bluwhtgrngis","stretched","fastie","brntogrn","blutoredjet","colors16"] - } - }, - "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" -} +module.exports={ + "name": "Colormap", + "description": "Maps brightness values (average of red, green & blue) to a given color lookup table, made up of a set of one more color gradients.\n\nFor example, 'cooler' colors like blue could represent low values, while 'hot' colors like red could represent high values.", + "inputs": { + "colormap": { + "type": "select", + "desc": "Name of the Colormap", + "default": "default", + "htmlType": + { + "type": "select", + "values": ["default","greyscale","bluwhtgrngis","stretched","fastie","brntogrn","blutoredjet","colors16"] + } + } + }, + "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" +} },{}],184:[function(require,module,exports){ -var _ = require('lodash'); -module.exports = exports = function(pixels , contrast){ - let oldpix = _.cloneDeep(pixels); - contrast = Number(contrast) - if (contrast < -100) contrast = -100; - if (contrast > 100) contrast = 100; - contrast = (100.0 + contrast) / 100.0; - contrast *= contrast; - - for (let i = 0; i < oldpix.shape[0]; i++) { - for (let j = 0; j < oldpix.shape[1]; j++) { - var r = oldpix.get(i,j,0)/255.0; - r -= 0.5; - r *= contrast; - r += 0.5; - r *= 255; - if (r < 0) r = 0; - if (r > 255) r = 255; - - - var g = oldpix.get(i,j,1)/255.0; - g -= 0.5; - g *= contrast; - g += 0.5; - g *= 255; - if (g < 0) g = 0; - if (g > 255) g = 255; - - - - var b = oldpix.get(i,j,2)/255.0; - b -= 0.5; - b *= contrast; - b += 0.5; - b *= 255; - if (b < 0) b = 0; - if (b > 255) b = 255; - - - pixels.set(i, j, 0, r); - pixels.set(i, j, 1, g); - pixels.set(i, j, 2, b); - - } - } - return pixels; +var _ = require('lodash'); +module.exports = exports = function(pixels , contrast){ + let oldpix = _.cloneDeep(pixels); + contrast = Number(contrast) + if (contrast < -100) contrast = -100; + if (contrast > 100) contrast = 100; + contrast = (100.0 + contrast) / 100.0; + contrast *= contrast; + + for (let i = 0; i < oldpix.shape[0]; i++) { + for (let j = 0; j < oldpix.shape[1]; j++) { + var r = oldpix.get(i,j,0)/255.0; + r -= 0.5; + r *= contrast; + r += 0.5; + r *= 255; + if (r < 0) r = 0; + if (r > 255) r = 255; + + + var g = oldpix.get(i,j,1)/255.0; + g -= 0.5; + g *= contrast; + g += 0.5; + g *= 255; + if (g < 0) g = 0; + if (g > 255) g = 255; + + + + var b = oldpix.get(i,j,2)/255.0; + b -= 0.5; + b *= contrast; + b += 0.5; + b *= 255; + if (b < 0) b = 0; + if (b > 255) b = 255; + + + pixels.set(i, j, 0, r); + pixels.set(i, j, 1, g); + pixels.set(i, j, 2, b); + + } + } + return pixels; } },{"lodash":75}],185:[function(require,module,exports){ -// /* -// * Changes the Image Contrast -// */ - -module.exports = function Contrast(options, UI) { - - options.contrast = options.contrast || 70 - var output; - - function draw(input, callback, progressObj) { - - progressObj.stop(true); - progressObj.overrideFlag = true; - - var step = this; - - function changePixel(r, g, b, a) { - return [r, g, b, a] - } - - function extraManipulation(pixels) { - pixels = require('./Contrast')(pixels, options.contrast) - return pixels - } - - function output(image, datauri, mimetype) { - - // This output is accessible by Image Sequencer - step.output = { src: datauri, format: mimetype }; - - } - - return require('../_nomodule/PixelManipulation.js')(input, { - output: output, - changePixel: changePixel, - extraManipulation: extraManipulation, - format: input.format, - image: options.image, - callback: callback - }); - - } - return { - options: options, - draw: draw, - output: output, - UI: UI - } -} +// /* +// * Changes the Image Contrast +// */ + +module.exports = function Contrast(options, UI) { + + options.contrast = options.contrast || 70 + var output; + + function draw(input, callback, progressObj) { + + progressObj.stop(true); + progressObj.overrideFlag = true; + + var step = this; + + function changePixel(r, g, b, a) { + return [r, g, b, a] + } + + function extraManipulation(pixels) { + pixels = require('./Contrast')(pixels, options.contrast) + return pixels + } + + function output(image, datauri, mimetype) { + + // This output is accessible by Image Sequencer + step.output = { src: datauri, format: mimetype }; + + } + + return require('../_nomodule/PixelManipulation.js')(input, { + output: output, + changePixel: changePixel, + extraManipulation: extraManipulation, + format: input.format, + image: options.image, + callback: callback + }); + + } + return { + options: options, + draw: draw, + output: output, + UI: UI + } +} },{"../_nomodule/PixelManipulation.js":253,"./Contrast":184}],186:[function(require,module,exports){ arguments[4][162][0].apply(exports,arguments) },{"./Module":185,"./info.json":187,"dup":162}],187:[function(require,module,exports){ -module.exports={ - "name": "Contrast", - "description": "Change the contrast of the image by given value", - "inputs": { - "contrast": { - "type": "range", - "desc": "contrast for the new image, typically -100 to 100", - "default": "70", - "min": "-100", - "max": "100", - "step": "1" - } - }, - "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" -} +module.exports={ + "name": "Contrast", + "description": "Change the contrast of the image by given value", + "inputs": { + "contrast": { + "type": "float", + "desc": "contrast for the new image, typically -100 to 100", + "default": 70, + "htmlType": + { + "type": "range", + "min": -100, + "max": 100 + } + } + }, + "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" +} },{}],188:[function(require,module,exports){ -var _ = require('lodash'); -module.exports = exports = function(pixels, constantFactor, kernelValues){ - let kernel = kernelGenerator(constantFactor, kernelValues), oldpix = _.cloneDeep(pixels); - kernel = flipKernel(kernel); - - for (let i = 0; i < pixels.shape[0]; i++) { - for (let j = 0; j < pixels.shape[1]; j++) { - let neighboutPos = getNeighbouringPixelPositions([i, j]); - let acc = [0.0, 0.0, 0.0, 0.0]; - for (let a = 0; a < kernel.length; a++) { - for (let b = 0; b < kernel.length; b++) { - acc[0] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 0) * kernel[a][b]); - acc[1] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 1) * kernel[a][b]); - acc[2] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 2) * kernel[a][b]); - acc[3] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 3) * kernel[a][b]); - } - } - acc[0] = acc[0]%255; - acc[1] = acc[1]%255; - acc[2] = acc[2]%255; - pixels.set(i, j, 0, acc[0]); - pixels.set(i, j, 1, acc[1]); - pixels.set(i, j, 2, acc[2]); - } - } - return pixels; - - - function kernelGenerator(constantFactor, kernelValues){ - kernelValues = kernelValues.split(" "); - for(i = 0 ; i < 9; i++){ - kernelValues[i] = Number(kernelValues[i]) * constantFactor; - } - let k = 0; - let arr = []; - for(i = 0; i < 3; i++){ - let columns = []; - for(j = 0; j < 3; j++){ - columns.push(kernelValues[k]); - k += 1; - } - arr.push(columns); - } - return arr; - } - - function getNeighbouringPixelPositions(pixelPosition) { - let x = pixelPosition[0], y = pixelPosition[1], result = []; - - for (let i = -1; i <= 1; i++) { - let arr = []; - for (let j = -1; j <= 1; j++) - arr.push([x + i, y + j]); - - result.push(arr); - } - return result; - } - - function flipKernel(kernel) { - let result = []; - for (let i = kernel.length - 1; i >= 0; i--) { - let arr = []; - for (let j = kernel[i].length - 1; j >= 0; j--) { - arr.push(kernel[i][j]); - } - result.push(arr); - } - return result; - } +var _ = require('lodash'); +module.exports = exports = function(pixels, constantFactor, kernelValues){ + let kernel = kernelGenerator(constantFactor, kernelValues), oldpix = _.cloneDeep(pixels); + kernel = flipKernel(kernel); + + for (let i = 0; i < pixels.shape[0]; i++) { + for (let j = 0; j < pixels.shape[1]; j++) { + let neighboutPos = getNeighbouringPixelPositions([i, j]); + let acc = [0.0, 0.0, 0.0, 0.0]; + for (let a = 0; a < kernel.length; a++) { + for (let b = 0; b < kernel.length; b++) { + acc[0] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 0) * kernel[a][b]); + acc[1] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 1) * kernel[a][b]); + acc[2] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 2) * kernel[a][b]); + acc[3] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 3) * kernel[a][b]); + } + } + acc[0] = acc[0]%255; + acc[1] = acc[1]%255; + acc[2] = acc[2]%255; + pixels.set(i, j, 0, acc[0]); + pixels.set(i, j, 1, acc[1]); + pixels.set(i, j, 2, acc[2]); + } + } + return pixels; + + + function kernelGenerator(constantFactor, kernelValues){ + kernelValues = kernelValues.split(" "); + for(i = 0 ; i < 9; i++){ + kernelValues[i] = Number(kernelValues[i]) * constantFactor; + } + let k = 0; + let arr = []; + for(i = 0; i < 3; i++){ + let columns = []; + for(j = 0; j < 3; j++){ + columns.push(kernelValues[k]); + k += 1; + } + arr.push(columns); + } + return arr; + } + + function getNeighbouringPixelPositions(pixelPosition) { + let x = pixelPosition[0], y = pixelPosition[1], result = []; + + for (let i = -1; i <= 1; i++) { + let arr = []; + for (let j = -1; j <= 1; j++) + arr.push([x + i, y + j]); + + result.push(arr); + } + return result; + } + + function flipKernel(kernel) { + let result = []; + for (let i = kernel.length - 1; i >= 0; i--) { + let arr = []; + for (let j = kernel[i].length - 1; j >= 0; j--) { + arr.push(kernel[i][j]); + } + result.push(arr); + } + return result; + } } },{"lodash":75}],189:[function(require,module,exports){ -module.exports = function Convolution(options, UI) { - - options.kernelValues = options.kernelValues || '1 1 1 1 1 1 1 1 1'; - options.constantFactor = options.constantFactor || 1/9; - var output; - - function draw(input, callback, progressObj) { - - progressObj.stop(true); - progressObj.overrideFlag = true; - - var step = this; - - function changePixel(r, g, b, a) { - return [r, g, b, a] - } - - function extraManipulation(pixels) { - pixels = require('./Convolution')(pixels, options.constantFactor, options.kernelValues) - return pixels - } - - function output(image, datauri, mimetype) { - - step.output = { src: datauri, format: mimetype }; - - } - - return require('../_nomodule/PixelManipulation.js')(input, { - output: output, - changePixel: changePixel, - extraManipulation: extraManipulation, - format: input.format, - image: options.image, - callback: callback - }); - - } - return { - options: options, - draw: draw, - output: output, - UI: UI - } -} +module.exports = function Convolution(options, UI) { + + options.kernelValues = options.kernelValues || '1 1 1 1 1 1 1 1 1'; + options.constantFactor = options.constantFactor || 1/9; + var output; + + function draw(input, callback, progressObj) { + + progressObj.stop(true); + progressObj.overrideFlag = true; + + var step = this; + + function changePixel(r, g, b, a) { + return [r, g, b, a] + } + + function extraManipulation(pixels) { + pixels = require('./Convolution')(pixels, options.constantFactor, options.kernelValues) + return pixels + } + + function output(image, datauri, mimetype) { + + step.output = { src: datauri, format: mimetype }; + + } + + return require('../_nomodule/PixelManipulation.js')(input, { + output: output, + changePixel: changePixel, + extraManipulation: extraManipulation, + format: input.format, + image: options.image, + callback: callback + }); + + } + return { + options: options, + draw: draw, + output: output, + UI: UI + } +} },{"../_nomodule/PixelManipulation.js":253,"./Convolution":188}],190:[function(require,module,exports){ arguments[4][162][0].apply(exports,arguments) },{"./Module":189,"./info.json":191,"dup":162}],191:[function(require,module,exports){ -module.exports={ - "name": "Convolution", - "description": "Image Convolution using a given 3x3 kernel matrix Read more", - "inputs": { - "constantFactor":{ - "type": "Float", - "desc": "a constant factor, multiplies all the kernel values by that factor", - "default": 0.1111, - "placeholder": 0.1111 - }, - - "kernelValues": { - "type": "String", - "desc": "nine space separated numbers representing the kernel values in left to right and top to bottom format.", - "default": "1 1 1 1 1 1 1 1 1", - "placeholder": "1 1 1 1 1 1 1 1 1" - } - }, - "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" -} +module.exports={ + "name": "Convolution", + "description": "Image Convolution using a given 3x3 kernel matrix Read more", + "inputs": { + "constantFactor":{ + "type": "float", + "desc": "a constant factor, multiplies all the kernel values by that factor", + "default": 0.1111, + "htmlType": + { + "type": "range", + "min": 0, + "max": 1, + "step": 0.001, + "placeholder": "0.1111" + } + }, + + "kernelValues": { + "type": "string", + "desc": "nine space separated numbers representing the kernel values in left to right and top to bottom format.", + "default": "1 1 1 1 1 1 1 1 1", + "htmlType": + { + "type": "text", + "placeholder": "1 1 1 1 1 1 1 1 1" + } + } + }, + "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md" +} },{}],192:[function(require,module,exports){ (function (Buffer){ -module.exports = function Crop(input,options,callback) { - - var getPixels = require('get-pixels'), - savePixels = require('save-pixels'); - - options.x = parseInt(options.x) || 0; - options.y = parseInt(options.y) || 0; - - getPixels(input.src,function(err,pixels){ - options.w = parseInt(options.w) || Math.floor(pixels.shape[0]); - options.h = parseInt(options.h) || Math.floor(pixels.shape[1]); - options.backgroundColor = options.backgroundColor || '255 255 255 255'; - var ox = options.x; - var oy = options.y; - var w = options.w; - var h = options.h; - var iw = pixels.shape[0]; //Width of Original Image - var ih = pixels.shape[1]; //Height of Original Image - var backgroundArray = []; - backgroundColor = options.backgroundColor.split(" "); - for(var i = 0; i < w ; i++){ - backgroundArray = backgroundArray.concat([backgroundColor[0],backgroundColor[1],backgroundColor[2],backgroundColor[3]]); - } - var newarray = new Uint8Array(4*w*h); - for (var n = oy; n < oy + h; n++) { - if(n\ - Select or drag in an image to overlay.\ -
\ -\ + Select or drag in an image to overlay.\ +
\ +c;)l=P[p++],fc&&((s=r[h--])[0]-=l*(s[0]-n)/_,s[1]-=l*(s[1]-o)/_,s[2]-=l*(s[2]-a)/_)}function T(t,e,n){var o,l,p,d,m,v=~(1<<31),g=v,_=-1,y=_;for(o=0;o>s-a)) =3&&0===t.bl_tree[2*S[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),l=t.opt_len+3+7>>>3,(c=t.static_len+3+7>>>3)<=l&&(l=c)):l=c=r+5,r+4<=l&&-1!==e?et(t,e,r,n):t.strategy===i||c===l?(q(t,(u<<1)+(n?1:0),3),$(t,j,T)):(q(t,(f<<1)+(n?1:0),3),function(t,e,r,n){var i;for(q(t,e-257,5),q(t,r-1,5),q(t,n-4,4),i=0;i >4==0?v:m)[15&S]=u(j,M)}break;case 65501:n(),s=n();break;case 65498:n();var A=e[r++],I=[];for(N=0;N>4],q.huffmanTableAC=m[15&R],I.push(q)}var L=e[r++],O=e[r++],F=e[r++],D=f(e,r,a,I,s,L,O,F>>4,15&F);r+=D;break;default:if(255==e[r-3]&&e[r-2]>=192&&e[r-2]<=254){r-=3;break}throw"unknown JPEG marker "+g.toString(16)}g=n()}if(1!=d.length)throw"only single frame JPEGs supported";for(var N=0;N=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,b,C)):C[0]+b+C[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i,o){var a,s,l;if((l=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=l.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):l.set&&(s=t.stylize("[Setter]","special")),P(n,i)||(a="["+i+"]"),s||(t.seen.indexOf(l.value)<0?(s=m(r)?u(t,l.value,null):u(t,l.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),_(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+s}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function m(t){return null===t}function v(t){return"number"==typeof t}function g(t){return"string"==typeof t}function _(t){return void 0===t}function y(t){return b(t)&&"[object RegExp]"===B(t)}function b(t){return"object"==typeof t&&null!==t}function w(t){return b(t)&&"[object Date]"===B(t)}function k(t){return b(t)&&("[object Error]"===B(t)||t instanceof Error)}function x(t){return"function"==typeof t}function B(t){return Object.prototype.toString.call(t)}function C(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(_(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!a[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;a[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else a[t]=function(){};return a[t]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=p,r.isBoolean=d,r.isNull=m,r.isNullOrUndefined=function(t){return null==t},r.isNumber=v,r.isString=g,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=_,r.isRegExp=y,r.isObject=b,r.isDate=w,r.isError=k,r.isFunction=x,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[C(t.getHours()),C(t.getMinutes()),C(t.getSeconds())].join(":"),[t.getDate(),E[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!b(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":42,_process:117,inherits:41}],44:[function(t,e,r){(function(e,n){"use strict";var i=t("assert"),o=t("pako/lib/zlib/zstream"),a=t("pako/lib/zlib/deflate.js"),s=t("pako/lib/zlib/inflate.js"),l=t("pako/lib/zlib/constants");for(var c in l)r[c]=l[c];r.NONE=0,r.DEFLATE=1,r.INFLATE=2,r.GZIP=3,r.GUNZIP=4,r.DEFLATERAW=5,r.INFLATERAW=6,r.UNZIP=7;function u(t){if("number"!=typeof t||ts&&(r=s-l),o=r;o>=0;o--){for(var f=!0,h=0;h>1,u=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,o=p&(1<<-u)-1,p>>=-u,u+=s;u>0;o=256*o+t[e+f],f+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=n;u>0;a=256*a+t[e+f],f+=h,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var a,s,l,c=8*o-i-1,u=(1<r?r:t}var s=function(){function t(t,e){this.width=t,this.data=new Uint8ClampedArray(t*e)}return t.prototype.get=function(t,e){return this.data[e*this.width+t]},t.prototype.set=function(t,e,r){this.data[e*this.width+t]=r},t}();e.binarize=function(t,e,r){if(t.length!==e*r*4)throw new Error("Malformed data passed to binarizer.");for(var l=new s(e,r),c=0;c0){if(_===l)break;_+=m,p-=f}}for(var w=[],k=0;k