Add matrix math module (#358)

* Add matrix math module

* add info.json file

* correct format of module

* Add a constant factor input field

* clone the pixels array

* change default values
This commit is contained in:
Mridul97
2018-10-04 22:16:21 +05:30
committed by Jeffrey Warren
parent 338e610fe7
commit 70654a5aac
7 changed files with 345 additions and 67 deletions

View File

@@ -0,0 +1,45 @@
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
}
}