Add comments; Remove do-nothing, do-nothing-pix

This commit is contained in:
Chinmay Pandhare
2017-08-21 10:01:02 +05:30
parent 54c7393417
commit cc308748c8
14 changed files with 20403 additions and 20327 deletions

40473
dist/image-sequencer.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -2,18 +2,12 @@
* Core modules and their info files
*/
module.exports = {
'do-nothing': [
require('./modules/DoNothing/Module'),require('./modules/DoNothing/info')
],
'green-channel': [
require('./modules/GreenChannel/Module'),require('./modules/GreenChannel/info')
],
'ndvi-red': [
require('./modules/NdviRed/Module'),require('./modules/NdviRed/info')
],
'do-nothing-pix': [
require('./modules/DoNothingPix/Module'),require('./modules/DoNothingPix/info')
],
'invert': [
require('./modules/Invert/Module'),require('./modules/Invert/info')
],

View File

@@ -14,26 +14,39 @@
* y = options.y + options.h
*/
module.exports = function CropModule(options,UI) {
options = options || {};
options.title = "Crop Image";
UI.onSetup(options.step);
var output
// Tell the UI that a step has been added
UI.onSetup(options.step);
var output;
// This function is caled everytime the step has to be redrawn
function draw(input,callback) {
// Tell the UI that the step has been triggered
UI.onDraw(options.step);
const step = this;
require('./Crop')(input,options,function(out,format){
// This output is accessible to Image Sequencer
step.output = {
src: out,
format: format
}
options.step.output = out;
UI.onComplete(options.step);
callback();
});
// This output is accessible to the UI
options.step.output = out;
// Tell the UI that the step has been drawn
UI.onComplete(options.step);
// Tell Image Sequencer that step has been drawn
callback();
});
}

View File

@@ -2,29 +2,46 @@
* Decodes QR from a given image.
*/
module.exports = function DoNothing(options,UI) {
options = options || {};
options.title = "Decode QR Code";
// Tell the UI that a step has been added
UI.onSetup(options.step);
var output;
var jsQR = require('jsqr');
var getPixels = require('get-pixels');
// This function is called everytime a step has to be redrawn
function draw(input,callback) {
UI.onDraw(options.step);
const step = this;
getPixels(input.src,function(err,pixels){
if(err) throw err;
var w = pixels.shape[0];
var h = pixels.shape[1];
var decoded = jsQR.decodeQRFromImage(pixels.data,w,h);
// This output is accessible to Image Sequencer
step.output = input;
step.output.data = decoded;
// Tell Image Sequencer that this step is complete
callback();
// These values are accessible to the UI
options.step.output = input.src;
options.step.qrval = decoded;
// Tell the UI that the step is complete and output is set
UI.onComplete(options.step);
});
}
return {

View File

@@ -1,5 +1,10 @@
{
"name": "Decode QR",
"inputs": {
},
"outputs": {
"qrval": {
"type": "text"
}
}
}

View File

@@ -1,26 +0,0 @@
/*
* Demo Module. Does nothing. Adds a step where output is equal to input.
*/
module.exports = function DoNothing(options,UI) {
options = options || {};
options.title = "Do Nothing";
UI.onSetup(options.step);
var output;
function draw(input,callback) {
UI.onDraw(options.step);
this.output = input;
options.step.output = this.output.src;
callback();
UI.onComplete(options.step);
}
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}

View File

@@ -1,5 +0,0 @@
{
"name": "Do Nothing",
"inputs": {
}
}

View File

@@ -1,40 +0,0 @@
/*
* This module extracts pixels and saves them as it is.
*/
module.exports = function DoNothingPix(options,UI) {
options = options || {};
options.title = "Do Nothing with pixels";
UI.onSetup(options.step);
var output;
function draw(input,callback) {
UI.onDraw(options.step);
const step = this;
function changePixel(r, g, b, a) {
return [r, g, b, a];
}
function output(image,datauri,mimetype){
step.output = {src:datauri,format:mimetype}
options.step.output = datauri;
UI.onComplete(options.step);
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output,
changePixel: changePixel,
format: input.format,
image: options.image,
callback: callback
});
}
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}

View File

@@ -1,5 +0,0 @@
{
"name": "extract pixels, do nothing, and replace",
"inputs": {
}
}

View File

@@ -1,21 +1,30 @@
/*
* Creates Fisheye Effect
* Resolves Fisheye Effect
*/
module.exports = function DoNothing(options,UI) {
options = options || {};
options.title = "Fisheye GL";
var output;
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
require('fisheyegl');
function draw(input,callback) {
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
const step = this;
if (!options.inBrowser) { // This module is only for browser
this.output = input;
callback();
}
else {
// Create a canvas, if it doesn't already exist.
if (!document.querySelector('#image-sequencer-canvas')) {
var canvas = document.createElement('canvas');
canvas.style.display = "none";
@@ -28,6 +37,7 @@ module.exports = function DoNothing(options,UI) {
selector: "#image-sequencer-canvas"
});
// Parse the inputs
options.a = parseFloat(options.a) || distorter.lens.a;
options.b = parseFloat(options.b) || distorter.lens.b;
options.Fx = parseFloat(options.Fx) || distorter.lens.Fx;
@@ -36,6 +46,7 @@ module.exports = function DoNothing(options,UI) {
options.x = parseFloat(options.x) || distorter.fov.x;
options.y = parseFloat(options.y) || distorter.fov.y;
// Set fisheyegl inputs
distorter.lens.a = options.a;
distorter.lens.b = options.b;
distorter.lens.Fx = options.Fx;
@@ -44,11 +55,19 @@ module.exports = function DoNothing(options,UI) {
distorter.fov.x = options.x;
distorter.fov.y = options.y;
// generate fisheyegl output
distorter.setImage(input.src,function(){
// this output is accessible to Image Sequencer
step.output = {src: canvas.toDataURL(), format: input.format};
// This output is accessible to the UI
options.step.output = step.output.src;
// Tell Image Sequencer and UI that step has been drawn
callback();
UI.onComplete(options.step);
});
}

View File

@@ -6,22 +6,33 @@ module.exports = function GreenChannel(options,UI) {
options = options || {};
options.title = "Green channel only";
options.description = "Displays only the green channel of an image";
// Tell UI that a step has been set up
UI.onSetup(options.step);
var output;
function draw(input,callback) {
// Tell UI that a step is being drawn
UI.onDraw(options.step);
const step = this;
function changePixel(r, g, b, a) {
return [0, g, 0, a];
}
function output(image,datauri,mimetype){
// This output is accesible by Image Sequencer
step.output = {src:datauri,format:mimetype};
// This output is accessible by UI
options.step.output = datauri;
// Tell UI that step ahs been drawn
UI.onComplete(options.step);
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output,
changePixel: changePixel,

View File

@@ -6,24 +6,35 @@ module.exports = function GreenChannel(options,UI) {
options = options || {};
options.title = "Invert Colors";
options.description = "Inverts the colors of the image";
// Tell UI that a step has been set up.
UI.onSetup(options.step);
var output;
//function setup() {} // optional
// The function which is called on every draw.
function draw(input,callback) {
// Tell UI that a step is being drawn.
UI.onDraw(options.step);
const step = this;
function changePixel(r, g, b, a) {
return [255-r, 255-g, 255-b, a];
}
function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype};
// This output is accessible by UI
options.step.output = datauri;
// Tell UI that step has been drawn.
UI.onComplete(options.step);
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output,
changePixel: changePixel,
@@ -36,7 +47,6 @@ module.exports = function GreenChannel(options,UI) {
return {
options: options,
//setup: setup, // optional
draw: draw,
output: output,
UI: UI

View File

@@ -5,11 +5,15 @@ module.exports = function NdviRed(options,UI) {
options = options || {};
options.title = "NDVI for red-filtered cameras (blue is infrared)";
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output;
// The function which is called on every draw.
function draw(input,callback) {
// Tell the UI that a step is being drawn.
UI.onDraw(options.step);
const step = this;
@@ -18,11 +22,19 @@ module.exports = function NdviRed(options,UI) {
var x = 255 * (ndvi + 1) / 2;
return [x, x, x, a];
}
function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype};
// This output is accessible by the UI.
options.step.output = datauri;
// Tell the UI that step has been drawn succesfully.
UI.onComplete(options.step);
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output,
changePixel: changePixel,

View File

@@ -2,11 +2,15 @@ module.exports = function SegmentedColormap(options,UI) {
options = options || {};
options.title = "Segmented Colormap";
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output;
// This function is called on every draw.
function draw(input,callback) {
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
const step = this;
@@ -16,10 +20,18 @@ module.exports = function SegmentedColormap(options,UI) {
var res = require('./SegmentedColormap')(normalized,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};
// This output is accessible by the UI
options.step.output = datauri;
// Tell the UI that the draw is complete
UI.onComplete(options.step);
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output,