mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-14 20:30:01 +01:00
71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
/*
|
|
* Core modules; externalized these wrapper modules with:
|
|
* 'image-select': require('./modules/ImageSelect.js'),
|
|
*/
|
|
module.exports = {
|
|
|
|
// How much of this wrapper is necessary?
|
|
// Could it be for UI, and the actual module is for functionality?
|
|
// But 'image-select' is not set up that way; it's UI. But it's special.
|
|
'image-select': function ImageSelect() {
|
|
|
|
var imageselect;
|
|
|
|
function setup(onComplete) {
|
|
imageselect = require('./modules/ImageSelect.js')({
|
|
output: onComplete,
|
|
selector: '#drop'
|
|
});
|
|
}
|
|
|
|
function run(image, onComplete) {
|
|
if (onComplete) onComplete(get());
|
|
}
|
|
|
|
function get() {
|
|
return imageselect.getImage();
|
|
}
|
|
|
|
return {
|
|
title: "Select image",
|
|
run: run,
|
|
setup: setup,
|
|
get: get
|
|
}
|
|
|
|
},
|
|
|
|
'green-channel': require('./modules/GreenChannel.js'),
|
|
'ndvi-red': require('./modules/NdviRed.js'),
|
|
|
|
/*
|
|
'image-threshold': {
|
|
name: "Threshold image",
|
|
run: function imageThreshold(image, onComplete, options) {
|
|
|
|
options = options || {};
|
|
options.threshold = options.threshold || 30;
|
|
|
|
var canvas = document.createElement('canvas');
|
|
var context = canvas.getContext('2d');
|
|
context.drawImage(image, 0, 0 );
|
|
var imageData = context.getImageData(0, 0, element.width, element.height);
|
|
|
|
var imageThreshold = require('../node_modules/image-filter-threshold/src/index.js');
|
|
|
|
var result = imageThreshold({
|
|
data: imageData,
|
|
threshold: options.threshold
|
|
}).then(function (result) {
|
|
var image = new Image();
|
|
image.onload = function onLoad() {
|
|
onComplete(image);
|
|
}
|
|
image.src = result;
|
|
});
|
|
|
|
}
|
|
}
|
|
*/
|
|
}
|