diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 90ebf2d5..02a75cd6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ Happily accepting pull requests; to edit the core library, modify files in `./sr On ARM based devices, the `gl` module may require some libraries to be re-installed: -`sudo apt-get install -y build-essential libxi-dev libglu1-mesa-dev libglew-dev pkg-config` -- see https://github.com/stackgl/headless-gl#ubuntudebian for more. +`sudo apt-get install -y build-essential xserver-xorg-dev libxext-dev libxi-dev libglu1-mesa-dev libglew-dev pkg-config` -- see https://github.com/stackgl/headless-gl#ubuntudebian for more. Most contribution (we imagine) would be in the form of API-compatible modules, which need not be directly included. diff --git a/README.md b/README.md index c8b076a3..2822794b 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,7 @@ If only one module is to be added, `modules` is simply the name of the module. If multiple images are to be added, `modules` is an array, which holds the names of modules to be added, in that particular order. -optional_otions is just an optional parameter, in object form, which you might +optional_options is just an optional parameter, in object form, which you might want to provide to the modules. A variety of syntaxes are supported by Image Sequencer to add multiple steps and configurations quickly for module chaining. The project supports the string syntax, designed to be compact and URL friendly, and JSON, for handling more complex sequences. This can be achieved by passing strings to `sequencer.addStep()`: diff --git a/docs/MODULES.md b/docs/MODULES.md index 39ebd9ad..ca683bda 100644 --- a/docs/MODULES.md +++ b/docs/MODULES.md @@ -31,16 +31,17 @@ List of Module Documentations 26. [MinifyImage](#minify-image) 27. [Ndvi](#ndvi-module) 28. [Ndvi-Colormap](#ndvi-colormap-module) -29. [Overlay](#overlay-module) -30. [PaintBucket](#paint-bucket-module) -31. [ReplaceColor](#replacecolor-module) -32. [Resize](#resize-module) -33. [Rotate](#rotate-module) -34. [Saturation](#saturation-module) -35. [Segmented-Colormap](#segmented-colormap-module) -36. [Text-Overlay](#text-overlay) -37. [Threshold](#threshold) -38. [Tint](#tint) +29. [NoiseReduction](#noise-reduction) +30. [Overlay](#overlay-module) +31. [PaintBucket](#paint-bucket-module) +32. [ReplaceColor](#replacecolor-module) +33. [Resize](#resize-module) +34. [Rotate](#rotate-module) +35. [Saturation](#saturation-module) +36. [Segmented-Colormap](#segmented-colormap-module) +37. [Text-Overlay](#text-overlay) +38. [Threshold](#threshold) +39. [Tint](#tint) ## add-qr-module @@ -488,6 +489,21 @@ This module is used for demonstrating ndvi and colormap properties consecutively ``` +## Noise-Reduction + +Noise in an image are atypical pixels that are not representing the color or the exposure of the scene correctly. This Noise Reduction module reduces the noise in the image by using either median filtering or mean filtering techniques to change the RGB value of the pixels to create a smoother and fuller image. + +#### Usage +```js + sequencer.loadImage('PATH') + .addSteps('noise-reduction',options) + .run() +``` +where `options` is an object with the property `method`. `options.method` can be: +* Median Filtering: Set the RGB value of the pixel to the median RGB pixel value of all adjacent pixels (maximum 8 adjacent pixels and itself) +* Mean Filtering: Set the RGB value of the pixel to the mean RGB pixel value of all adjacent pixels (maximum 8 adjacent pixels and itself) + + ## overlay-module This module is used for overlaying an Image over another . diff --git a/examples/demo.css b/examples/demo.css index bdbb9e49..5f1dd8ec 100644 --- a/examples/demo.css +++ b/examples/demo.css @@ -47,6 +47,10 @@ body > .container-fluid { min-width:400px; } +.mouse { + cursor: pointer !important; +} + .nomargin { margin: 0 !important; } @@ -254,7 +258,8 @@ a.name-header{ } .trash-container button.btn-xs { - margin-top: -5px !important; + position: relative; + bottom: 7px; } .toggleIcon { @@ -280,3 +285,22 @@ a.name-header{ .toggle { cursor: default; } + +.dimension-tooltip:hover{ + text-decoration: none; +} + +.dimension-tooltip:focus{ + outline: none; +} + +.dimension-tooltip:focus-within{ + outline: none; +} + +.dimension-tooltip{ + position: relative; + bottom: 7px; + font-size: 16px; + color: #444; +} \ No newline at end of file diff --git a/examples/index.html b/examples/index.html index b14582a7..4b442d5d 100644 --- a/examples/index.html +++ b/examples/index.html @@ -187,7 +187,7 @@

Save

- diff --git a/examples/lib/defaultHtmlStepUi.js b/examples/lib/defaultHtmlStepUi.js index c6c7b320..f1478444 100644 --- a/examples/lib/defaultHtmlStepUi.js +++ b/examples/lib/defaultHtmlStepUi.js @@ -31,9 +31,9 @@ function DefaultHtmlStepUi(_sequencer, options) {
\
\
\ -
\ +
\

' + - '' + step.name + ' \ + '' + step.name + ' \ \

\
\ @@ -59,7 +59,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
'; var tools = - '
\ + '
\ \ @@ -319,6 +319,13 @@ function DefaultHtmlStepUi(_sequencer, options) { .val(step[i]); } } + + $(function () { + $('[data-toggle="tooltip"]').tooltip(); + _sequencer.getImageDimensions(step.imgElement.src, function (dim) { + step.ui.querySelector('.' + step.name).attributes['data-original-title'].value = `

Image Width: ${dim.width}
Image Height: ${dim.height}

`; + }); + }); } function imageHover(step){ diff --git a/examples/lib/intermediateHtmlStepUi.js b/examples/lib/intermediateHtmlStepUi.js index 7fb64004..a96f08e4 100644 --- a/examples/lib/intermediateHtmlStepUi.js +++ b/examples/lib/intermediateHtmlStepUi.js @@ -64,15 +64,6 @@ function IntermediateHtmlStepUi(_sequencer, step, options) {
'; } - - function selectNewStepUi($step) { - var insertSelect = $step('.insert-step-select'); - var m = insertSelect.val(); - $step('.insertDiv .info').html(_sequencer.modulesInfo(m).description); - $step('.insertDiv .add-step-btn').prop('disabled', false); - } - - var toggleDiv = function($step, callback = function(){}){ $step('.insertDiv').collapse('toggle'); if ($step('.insert-text').css('display') != 'none'){ @@ -104,13 +95,16 @@ function IntermediateHtmlStepUi(_sequencer, step, options) { }); } - $step('.insertDiv .close-insert-box').off('click').on('click', function(){toggleDiv(function(){});}); + $step('.insertDiv .close-insert-box').off('click').on('click', function(){ + toggleDiv($step); + $step('.insertDiv').removeClass('insertDiv'); + }); var insertStepSelect = $step('.insert-step-select'); insertStepSelect.html(''); // Add modules to the insertStep dropdown for (var m in modulesInfo) { - if (modulesInfo[m] !== undefined) + if (modulesInfo[m] && modulesInfo[m].name) insertStepSelect.append( '' ); @@ -118,47 +112,26 @@ function IntermediateHtmlStepUi(_sequencer, step, options) { insertStepSelect.selectize({ sortField: 'text' }); - $step('.inserDiv .add-step-btn').prop('disabled', true); - - insertStepSelect.append(''); - $step('.insertDiv .radio-group .radio').on('click', function () { - $(this).parent().find('.radio').removeClass('selected'); - $(this).addClass('selected'); - newStep = $(this).attr('data-value'); - $step('.insert-step-select').val(newStep); - selectNewStepUi($step); - insert(id, $step); - $(this).removeClass('selected'); + $('.insertDiv .radio-group .radio').on('click', function () { + var newStepName = $(this).attr('data-value'); + id = $($step('.insertDiv').parents()[3]).prevAll().length; + insert(id, $step, newStepName); }); - insertStepSelect.on('change', () => {selectNewStepUi($step);}); - $step('.insertDiv .add-step-btn').on('click', function () { insert(id, $step); }); + $step('.insertDiv .add-step-btn').on('click', function () { + var newStepName = insertStepSelect.val(); + id = $($step('.insertDiv').parents()[3]).prevAll().length; + insert(id, $step, newStepName); }); }; - function insert(id, $step) { - - options = options || {}; - var insertStepSelect = $step('.insert-step-select'); - if (insertStepSelect.val() == 'none') return; - - var newStepName = insertStepSelect.val(); + function insert(id, $step, newStepName) { toggleDiv($step); - var sequenceLength = 1; - if (sequencer.sequences[newStepName]) { - sequenceLength = sequencer.sequences[newStepName].length; - } else if (sequencer.modules[newStepName][1]['length']) { - sequenceLength = sequencer.modules[newStepName][1]['length']; - } - _sequencer - .insertSteps(id + 1, newStepName).run({ index: id }); - - // add to URL hash too + $step('.insertDiv').removeClass('insertDiv'); + _sequencer.insertSteps(id + 1, newStepName).run({ index: id }); urlHash.setUrlHashParameter('steps', _sequencer.toString()); - } return { insertStep }; } -module.exports = IntermediateHtmlStepUi; - +module.exports = IntermediateHtmlStepUi; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 82b69c30..5e6215d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1659,9 +1659,9 @@ "dev": true }, "buffer": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.0.tgz", - "integrity": "sha512-Xpgy0IwHK2N01ncykXTy6FpCWuM+CJSHoPVBLyNqyrWxsedpLvwsYUhf0ME3WRFNUhos0dMamz9cOS/xRDtU5g==", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.2.tgz", + "integrity": "sha512-iy9koArjAFCzGnx3ZvNA6Z0clIbbFgbdWQ0mKD3hO0krOrZh8UgA6qMKcZvwLJxS+D6iVR76+5/pV56yMNYTag==", "requires": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" @@ -4306,11 +4306,11 @@ } }, "fs-minipass": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", - "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", "requires": { - "minipass": "^2.2.1" + "minipass": "^2.6.0" } }, "fs.realpath": { @@ -5031,9 +5031,9 @@ "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" }, "gl": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/gl/-/gl-4.3.3.tgz", - "integrity": "sha512-a16acSGmSLoyX4s6QjzIWI4LYsxztvr7aR8vt8anZpA4RboTrQ21ZQCQ8WcKWnQp/dn+nSYnw1fn5rHH9D85jQ==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/gl/-/gl-4.4.0.tgz", + "integrity": "sha512-4FIq5tqiltTsadrLh6DGY4R9+aQwj25OM2WlXEv81N6YN1q1C0qR7ct0SKp1uUJdnBqbKhUJP3zQ1td40AVeJg==", "requires": { "bindings": "^1.5.0", "bit-twiddle": "^1.0.2", @@ -5252,12 +5252,12 @@ "integrity": "sha512-kDMvQ04qIqbrpGyYCShx8NhZYMiolb1XUkjnJn92/jcMsxjcPF7KFfDMJEg0VUwxVJzD4djzJNWbmJCs00YEVg==" }, "gpu.js": { - "version": "2.0.0-rc.26", - "resolved": "https://registry.npmjs.org/gpu.js/-/gpu.js-2.0.0-rc.26.tgz", - "integrity": "sha512-7ZbPR87ok/aGFtP0/h5U4SFXCETQMb/kl1CS/qfqnAo/ySAfz0ndGqFhrGWNAAyE7jnKTmKHkHqL+GY0FU3F/Q==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/gpu.js/-/gpu.js-2.0.0.tgz", + "integrity": "sha512-YCLny6cHJD3gFFxtyhbcGdsROx9VJYfrIY8HNCE/c8Ng+ZXnjG2EazUQ85bTOAKFtJ6hcgOQ0MxsRHIIiOzDdQ==", "requires": { "acorn": "^5.1.1", - "gl": "^4.3.3", + "gl": "^4.4.0", "gl-wiretap": "^0.6.0", "gpu-mock.js": "^1.1.0" } @@ -6175,9 +6175,9 @@ "dev": true }, "https-proxy-agent": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz", - "integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", + "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", "requires": { "agent-base": "^4.3.0", "debug": "^3.1.0" @@ -8197,9 +8197,9 @@ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minipass": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.4.0.tgz", - "integrity": "sha512-6PmOuSP4NnZXzs2z6rbwzLJu/c5gdzYg1mRI/WIYdx45iiX7T+a4esOzavD6V/KmBzAaopFSTZPZcUx73bqKWA==", + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.6.5.tgz", + "integrity": "sha512-ewSKOPFH9blOLXx0YSE+mbrNMBFPS+11a2b03QZ+P4LVrUHW/GAlqeYC7DBknDyMWkHzrzTpDhUvy7MUxqyrPA==", "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -8213,9 +8213,9 @@ } }, "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.2.tgz", + "integrity": "sha512-hR3At21uSrsjjDTWrbu0IMLTpnkpv8IIMFDFaoz43Tmu4LkmAXfH44vNNzpTnf+OAQQCHrb91y/wc2J4x5XgSQ==", "requires": { "minipass": "^2.2.1" } @@ -9295,9 +9295,9 @@ "dev": true }, "prebuild-install": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.0.tgz", - "integrity": "sha512-aaLVANlj4HgZweKttFNUVNRxDukytuIuxeK2boIMHjagNJCiVKWFsKF4tCE3ql3GbrD2tExPQ7/pwtEJcHNZeg==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.2.tgz", + "integrity": "sha512-INDfXzTPnhT+WYQemqnAXlP7SvfiFMopMozSgXCZ+RDLb279gKfIuLk4o7PgEawLp3WrMgIYGBpkxpraROHsSA==", "requires": { "detect-libc": "^1.0.3", "expand-template": "^2.0.3", @@ -9308,24 +9308,12 @@ "node-abi": "^2.7.0", "noop-logger": "^0.1.1", "npmlog": "^4.0.1", - "os-homedir": "^1.0.1", - "pump": "^2.0.1", + "pump": "^3.0.0", "rc": "^1.2.7", - "simple-get": "^2.7.0", - "tar-fs": "^1.13.0", + "simple-get": "^3.0.3", + "tar-fs": "^2.0.0", "tunnel-agent": "^0.6.0", "which-pm-runs": "^1.0.0" - }, - "dependencies": { - "pump": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", - "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - } } }, "prelude-ls": { @@ -10517,13 +10505,28 @@ "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=" }, "simple-get": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-2.8.1.tgz", - "integrity": "sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz", + "integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==", "requires": { - "decompress-response": "^3.3.0", + "decompress-response": "^4.2.0", "once": "^1.3.1", "simple-concat": "^1.0.0" + }, + "dependencies": { + "decompress-response": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", + "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "requires": { + "mimic-response": "^2.0.0" + } + }, + "mimic-response": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.0.0.tgz", + "integrity": "sha512-8ilDoEapqA4uQ3TwS0jakGONKXVJqpy+RpM+3b7pLdOjghCrEiGp9SRkFbUHAmZW9vdnrENWHjaweIoTIJExSQ==" + } } }, "single-line-log": { @@ -11483,13 +11486,13 @@ } }, "tar": { - "version": "4.4.10", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.10.tgz", - "integrity": "sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==", + "version": "4.4.11", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.11.tgz", + "integrity": "sha512-iI4zh3ktLJKaDNZKZc+fUONiQrSn9HkCFzamtb7k8FFmVilHVob7QsLX/VySAW8lAviMzMbFw4QtFb4errwgYA==", "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.3.5", + "minipass": "^2.6.4", "minizlib": "^1.2.1", "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", @@ -11504,23 +11507,57 @@ } }, "tar-fs": { - "version": "1.16.3", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz", - "integrity": "sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.0.tgz", + "integrity": "sha512-vaY0obB6Om/fso8a8vakQBzwholQ7v5+uy+tF3Ozvxv1KNezmVQAiWtcNmMHFSFPqL3dJA8ha6gdtFbfX9mcxA==", "requires": { - "chownr": "^1.0.1", + "chownr": "^1.1.1", "mkdirp": "^0.5.1", - "pump": "^1.0.0", - "tar-stream": "^1.1.2" + "pump": "^3.0.0", + "tar-stream": "^2.0.0" }, "dependencies": { - "pump": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", - "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "bl": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.0.tgz", + "integrity": "sha512-EUAyP5UHU5hxF8BPT0LKW8gjYLhq1DQIcneOX/pL/m2Alo+OYDQAJlHq+yseMP50Os2nHXOSic6Ss3vSQeyf4A==", "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" + "readable-stream": "^3.0.1" + } + }, + "readable-stream": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + }, + "tar-stream": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.0.tgz", + "integrity": "sha512-+DAn4Nb4+gz6WZigRzKEZl1QuJVOLtAwwF+WUxy1fJ6X63CaGaUAxJRD2KEn1OMfcbCjySTYpNC6WmfQoIEOdw==", + "requires": { + "bl": "^3.0.0", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" } } } diff --git a/src/ImageSequencer.js b/src/ImageSequencer.js index f432ed41..f980efb7 100644 --- a/src/ImageSequencer.js +++ b/src/ImageSequencer.js @@ -329,6 +329,7 @@ ImageSequencer = function ImageSequencer(options) { log: log, objTypeOf: objTypeOf, copy: copy, + getImageDimensions: require('./util/getImageDimensions'), setInputStep: require('./ui/SetInputStep')(sequencer) }; diff --git a/src/modules/AddQR/QR.js b/src/modules/AddQR/QR.js index 72de51ec..b23e3ef7 100644 --- a/src/modules/AddQR/QR.js +++ b/src/modules/AddQR/QR.js @@ -32,7 +32,7 @@ module.exports = exports = function (options, pixels, oldPixels, callback) { } else { - pixelSetter(m, n, [qrPixels.get(m, n, 0), qrPixels.get(m, n, 1), qrPixels.get(m, n, 2), qrPixels.get(m, n, 3)], pixels); + pixelSetter(m, n, [oldPixels.get(m, n, 0), oldPixels.get(m, n, 1), oldPixels.get(m, n, 2), oldPixels.get(m, n, 3)], pixels); } } diff --git a/src/modules/DrawRectangle/DrawRectangle.js b/src/modules/DrawRectangle/DrawRectangle.js index a38ac4bd..ee9bf114 100644 --- a/src/modules/DrawRectangle/DrawRectangle.js +++ b/src/modules/DrawRectangle/DrawRectangle.js @@ -19,7 +19,7 @@ module.exports = exports = function(pixels, options){ for (var n = startX; n <= endX + thickness; n++){ for (var k = startY; k <= endY + thickness; k++){ - pixelSetter(n, k, color, pixels); //to remove 4th channel - pixels.set(n, k, 3, color[3]); + pixelSetter(n, k, [color[0], color[1], color[2]], pixels); //to remove 4th channel - pixels.set(n, k, 3, color[3]); } } }; diff --git a/src/modules/GammaCorrection/Module.js b/src/modules/GammaCorrection/Module.js index 256d5538..18a4ee75 100644 --- a/src/modules/GammaCorrection/Module.js +++ b/src/modules/GammaCorrection/Module.js @@ -10,8 +10,7 @@ module.exports = function Gamma(options, UI) { var step = this; var defaults = require('./../../util/getDefaults.js')(require('./info.json')), - adjustment = options.adjustment || defaults.adjustment; - var val = adjustment / defaults.adjustment; + val = options.adjustment || defaults.adjustment; function changePixel(r, g, b, a) { diff --git a/src/modules/GammaCorrection/info.json b/src/modules/GammaCorrection/info.json index 81e31808..63d10b5a 100644 --- a/src/modules/GammaCorrection/info.json +++ b/src/modules/GammaCorrection/info.json @@ -5,9 +5,10 @@ "adjustment": { "type": "float", "desc": "gamma correction (inverse of actual gamma factor) for the new image", - "default": 0.2, - "min": 2, - "max": 1 + "default": 0.5, + "min": 0, + "max": 5, + "step": 0.1 } }, "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md#gamma-correction-module" diff --git a/src/modules/GridOverlay/GridOverlay.js b/src/modules/GridOverlay/GridOverlay.js index 82f95340..2a28bf8c 100644 --- a/src/modules/GridOverlay/GridOverlay.js +++ b/src/modules/GridOverlay/GridOverlay.js @@ -2,11 +2,11 @@ module.exports = exports = function(pixels, options){ var defaults = require('./../../util/getDefaults.js')(require('./info.json')); const pixelSetter = require('../../util/pixelSetter.js'); - if(Number(options.x)==0){ + if(Number(options.x) == 0){ options.x = 1; - } - if( Number(options.y)==0) { - options.y =1; + } + if( Number(options.y) == 0) { + options.y = 1; } options.x = Math.abs(Number(options.x)) || defaults.x; @@ -17,14 +17,14 @@ module.exports = exports = function(pixels, options){ for(var x = 0; x < pixels.shape[0]; x += options.x){ for(var y = 0 ; y < pixels.shape[1]; y++){ - pixelSetter(x, y, color, pixels); // to remove 4th channel - pixels.set(x, y, 3, color[3]); + pixelSetter(x, y, [color[0], color[1], color[2]], pixels); // to remove 4th channel - pixels.set(x, y, 3, color[3]); } } for(var y = 0; y < pixels.shape[1]; y += options.y){ for(var x = 0 ; x < pixels.shape[0]; x++){ - pixelSetter(x, y, color, pixels); // to remove 4th channel - pixels.set(x, y, 3, color[3]); + pixelSetter(x, y, [color[0], color[1], color[2]], pixels); // to remove 4th channel - pixels.set(x, y, 3, color[3]); } } diff --git a/src/modules/Rotate/Module.js b/src/modules/Rotate/Module.js index d40e09a1..6c522d4d 100644 --- a/src/modules/Rotate/Module.js +++ b/src/modules/Rotate/Module.js @@ -23,20 +23,17 @@ module.exports = function Rotate(options, UI) { function extraManipulation(pixels) { var rotate_value = (options.rotate) % 360; - - if (rotate_value % 360 == 0) - return pixels; - - var bitmap = new imagejs.Bitmap({ width: pixels.shape[0], height: pixels.shape[1] }); - bitmap._data.data = pixels.data; - - var rotated = bitmap.rotate({ - degrees: rotate_value, - }); - pixels.data = rotated._data.data; - + var radians = (Math.PI) * rotate_value / 180; + var width = pixels.shape[0]; + var height = pixels.shape[1]; + var cos = Math.cos(radians); + var sin = Math.sin(radians); + //final dimensions after rotation + var pixels2 = require('ndarray')(new Uint8Array(4 * (Math.floor(Math.abs(width * cos) + Math.abs(height * sin) + 5) * (Math.floor(Math.abs(width * sin) + Math.abs(height * cos)) + 5))).fill(0), [Math.floor(Math.abs(width * cos) + Math.abs(height * sin)) + 5, Math.floor(Math.abs(width * sin) + Math.abs(height * cos)) + 4, 4]); + pixels = require('./Rotate')(pixels, pixels2, options, rotate_value, width, height, cos, sin); return pixels; } + function output(image, datauri, mimetype) { // This output is accesible by Image Sequencer diff --git a/src/modules/Rotate/Rotate.js b/src/modules/Rotate/Rotate.js new file mode 100644 index 00000000..06f246fd --- /dev/null +++ b/src/modules/Rotate/Rotate.js @@ -0,0 +1,38 @@ +module.exports = function Rotate(pixels, pixels2, options, rotate_value, width, height, cos, sin){ + var imagejs = require('imagejs'); + var height_half = Math.floor(height / 2); + var width_half = Math.floor(width / 2); + var dimension = width + height; + + if (rotate_value % 360 == 0) + return pixels; + function copyPixel(x1, y1, x2, y2,pixel_set,pixel_get){ + pixel_set.set(x1, y1, 0, pixel_get.get(x2, y2, 0)); + pixel_set.set(x1, y1, 1, pixel_get.get(x2, y2, 1)); + pixel_set.set(x1, y1, 2, pixel_get.get(x2, y2, 2)); + pixel_set.set(x1, y1, 3, pixel_get.get(x2, y2, 3)); + } + + pixels1 = require('ndarray')(new Uint8Array(4 * dimension * dimension).fill(0), [dimension, dimension, 4]); + //copying all the pixels from image to pixels1 + for (var n = 0; n < pixels.shape[0]; n++){ + for (var m = 0; m < pixels.shape[1]; m++){ + copyPixel(n + height_half, m + width_half, n, m,pixels1,pixels); + } + } + //rotating pixels1 + var bitmap = new imagejs.Bitmap({ width: pixels1.shape[0], height: pixels1.shape[1] }); + bitmap._data.data = pixels1.data; + + var rotated = bitmap.rotate({ + degrees: rotate_value, + }); + pixels1.data = rotated._data.data; + //cropping extra whitespace + for (var n = 0; n < pixels2.shape[0]; n++){ + for (var m = 0; m < pixels2.shape[1]; m++){ + copyPixel(n, m, n + Math.floor(dimension / 2 - Math.abs(width * cos / 2) - Math.abs(height * sin / 2)) - 1, m + Math.floor(dimension / 2 - Math.abs(height * cos / 2) - Math.abs(width * sin / 2)) - 1,pixels2,pixels1); + } + } + return pixels2; +}; diff --git a/src/util/getImageDimensions.js b/src/util/getImageDimensions.js new file mode 100644 index 00000000..e04bf878 --- /dev/null +++ b/src/util/getImageDimensions.js @@ -0,0 +1,10 @@ +module.exports = function getImageDimensions(img, cb) { + var getPixels = require('get-pixels'); + var dimensions = { width: '', height: '' }; + getPixels(img, function(err, pixels) { + dimensions.width = pixels.shape[0]; + dimensions.height = pixels.shape[1]; + cb(dimensions); + }); +}; + \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 0b4565ac..d166b9d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -306,10 +306,10 @@ after@0.8.2: resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" integrity sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8= -agent-base@^4.1.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9" - integrity sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg== +agent-base@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" + integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== dependencies: es6-promisify "^5.0.0" @@ -1146,9 +1146,9 @@ buffer-xor@^1.0.3: integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= buffer@^5.0.2, buffer@^5.2.1, buffer@~5.4.0: - version "5.4.0" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.4.0.tgz#33294f5c1f26e08461e528b69fa06de3c45cbd8c" - integrity sha512-Xpgy0IwHK2N01ncykXTy6FpCWuM+CJSHoPVBLyNqyrWxsedpLvwsYUhf0ME3WRFNUhos0dMamz9cOS/xRDtU5g== + version "5.4.2" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.4.2.tgz#2012872776206182480eccb2c0fba5f672a2efef" + integrity sha512-iy9koArjAFCzGnx3ZvNA6Z0clIbbFgbdWQ0mKD3hO0krOrZh8UgA6qMKcZvwLJxS+D6iVR76+5/pV56yMNYTag== dependencies: base64-js "^1.0.2" ieee754 "^1.1.4" @@ -2416,9 +2416,9 @@ es6-map@^0.1.5: event-emitter "~0.3.5" es6-promise@^4.0.3: - version "4.2.6" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.6.tgz#b685edd8258886365ea62b57d30de28fadcd974f" - integrity sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q== + version "4.2.8" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" + integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== es6-promise@^4.0.5: version "4.2.5" @@ -3392,10 +3392,10 @@ gl-wiretap@^0.6.0: resolved "https://registry.yarnpkg.com/gl-wiretap/-/gl-wiretap-0.6.0.tgz#7f292f875094da58a7964835451188307092a1a8" integrity sha512-QmkkieSYcPy3vTAP6faQp6TkgrtC+fIF/L85HEH+kajIr5zbgx2dr9wkk4PMzea3kBsgB1pZ0MuGHaDn76qHdA== -gl@^4.3.3: - version "4.3.3" - resolved "https://registry.yarnpkg.com/gl/-/gl-4.3.3.tgz#b8b91f4718397e67803b4d95a0c4c443425dd462" - integrity sha512-a16acSGmSLoyX4s6QjzIWI4LYsxztvr7aR8vt8anZpA4RboTrQ21ZQCQ8WcKWnQp/dn+nSYnw1fn5rHH9D85jQ== +gl@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/gl/-/gl-4.4.0.tgz#3d448769a9222ba809da4db80dd1f3c4b85498a0" + integrity sha512-4FIq5tqiltTsadrLh6DGY4R9+aQwj25OM2WlXEv81N6YN1q1C0qR7ct0SKp1uUJdnBqbKhUJP3zQ1td40AVeJg== dependencies: bindings "^1.5.0" bit-twiddle "^1.0.2" @@ -3578,12 +3578,12 @@ gpu-mock.js@^1.1.0: integrity sha512-kDMvQ04qIqbrpGyYCShx8NhZYMiolb1XUkjnJn92/jcMsxjcPF7KFfDMJEg0VUwxVJzD4djzJNWbmJCs00YEVg== gpu.js@^2.0.0-rc.12: - version "2.0.0-rc.26" - resolved "https://registry.yarnpkg.com/gpu.js/-/gpu.js-2.0.0-rc.26.tgz#92aebcf905b0d0482ae71716ffaa6d63c437b605" - integrity sha512-7ZbPR87ok/aGFtP0/h5U4SFXCETQMb/kl1CS/qfqnAo/ySAfz0ndGqFhrGWNAAyE7jnKTmKHkHqL+GY0FU3F/Q== + version "2.0.0" + resolved "https://registry.yarnpkg.com/gpu.js/-/gpu.js-2.0.0.tgz#cd57be4e2e2c76796ce38b03dae019e6e05efeea" + integrity sha512-YCLny6cHJD3gFFxtyhbcGdsROx9VJYfrIY8HNCE/c8Ng+ZXnjG2EazUQ85bTOAKFtJ6hcgOQ0MxsRHIIiOzDdQ== dependencies: acorn "^5.1.1" - gl "^4.3.3" + gl "^4.4.0" gl-wiretap "^0.6.0" gpu-mock.js "^1.1.0" @@ -3983,11 +3983,11 @@ https-browserify@^1.0.0: integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= https-proxy-agent@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0" - integrity sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ== + version "2.2.4" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" + integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== dependencies: - agent-base "^4.1.0" + agent-base "^4.3.0" debug "^3.1.0" humanize@^0.0.9: @@ -5485,9 +5485,9 @@ ms@2.0.0: integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= ms@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== mute-stream@0.0.7: version "0.0.7"