mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-13 20:00:05 +01:00
* wasmSuccess * modules use wasmSuccess * modules use wasmSuccess * add the tooltip * add GIF support * fix imageDImensions function * fix inputCoordinatesParser function * show correct image dimensions * show correct image dimensions * don't allow save as PDF for GIFs * fix QR module * fix BlobAnalysis * fix Blur * fix Colorbar * fix Crop * fix crop defaults * fix DrawRectangle * fix EdgeDetect * fix FlipImage * fix Gradient * fix Invert * fix Overlay * fix Resize * fix Rotate * fix TextOverlay * fix parse input test * make GIFs work in nodejs * sample GIF test * small change * cleanup * cleanup * cleanup * small fix * small change * handle errors * proper error handling and fix tests * cleanup * try a fix * try another fix * fix module benchmarks * try more fixes * revert * try fixing the tests * fix overlay test * add the gif tests * remove unnecessary changes * fix tests * whoops * add some docs * inBrowser * fix all module tests Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
const Blur = require('../Blur/Blur');
|
|
/*
|
|
* Detect Edges in an Image
|
|
* Uses Canny method for the same
|
|
* Read more: https://en.wikipedia.org/wiki/Canny_edge_detector
|
|
*/
|
|
module.exports = function edgeDetect(options, UI) {
|
|
|
|
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
|
options.blur = options.blur || defaults.blur;
|
|
options.highThresholdRatio = options.highThresholdRatio || defaults.highThresholdRatio;
|
|
options.lowThresholdRatio = options.lowThresholdRatio || defaults.lowThresholdRatio;
|
|
options.hysteresis = options.hysteresis || defaults.hysteresis;
|
|
|
|
var output;
|
|
|
|
// The function which is called on every draw.
|
|
function draw(input, callback, progressObj) {
|
|
|
|
progressObj.stop(true);
|
|
progressObj.overrideFlag = true;
|
|
|
|
var step = this;
|
|
|
|
// Makes the image greyscale
|
|
function changePixel(r, g, b, a) {
|
|
return [(r + g + b) / 3, (r + g + b) / 3, (r + g + b) / 3, a];
|
|
}
|
|
|
|
// Extra Manipulation function used as an enveloper for applying gaussian blur and Convolution
|
|
function extraManipulation(pixels) {
|
|
const blurPixels = Blur(pixels, options.blur);
|
|
return require('./EdgeUtils')(blurPixels, options.highThresholdRatio, options.lowThresholdRatio, options.hysteresis);
|
|
}
|
|
|
|
function output(image, datauri, mimetype, wasmSuccess) {
|
|
step.output = { src: datauri, format: mimetype, wasmSuccess, useWasm: options.useWasm };
|
|
}
|
|
|
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
|
output: output,
|
|
ui: options.step.ui,
|
|
changePixel: changePixel,
|
|
extraManipulation: extraManipulation,
|
|
format: input.format,
|
|
image: options.image,
|
|
inBrowser: options.inBrowser,
|
|
callback: callback,
|
|
useWasm: options.useWasm
|
|
});
|
|
}
|
|
|
|
return {
|
|
options: options,
|
|
draw: draw,
|
|
output: output,
|
|
UI: UI
|
|
};
|
|
}; |