Skip to content

Commit

Permalink
resolves publiclab#113 add brightness module
Browse files Browse the repository at this point in the history
Signed-off-by: tech4GT <[email protected]>
  • Loading branch information
tech4GT committed Jan 29, 2018
1 parent 7699919 commit 8619894
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 25 deletions.
115 changes: 94 additions & 21 deletions dist/image-sequencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38721,12 +38721,15 @@ module.exports = LoadImage;

},{"urify":113}],124:[function(require,module,exports){
/*
* Core modules and their info files
*/
* Core modules and their info files
*/
module.exports = {
'green-channel': [
require('./modules/GreenChannel/Module'),require('./modules/GreenChannel/info')
],
'brightness': [
require('./modules/Brightness/Module'),require('./modules/Brightness/info')
],
'ndvi-red': [
require('./modules/NdviRed/Module'),require('./modules/NdviRed/info')
],
Expand All @@ -38750,7 +38753,7 @@ module.exports = {
]
}

},{"./modules/Crop/Module":129,"./modules/Crop/info":130,"./modules/DecodeQr/Module":131,"./modules/DecodeQr/info":132,"./modules/Dynamic/Module":133,"./modules/Dynamic/info":134,"./modules/FisheyeGl/Module":135,"./modules/FisheyeGl/info":136,"./modules/GreenChannel/Module":137,"./modules/GreenChannel/info":138,"./modules/Invert/Module":139,"./modules/Invert/info":140,"./modules/NdviRed/Module":141,"./modules/NdviRed/info":142,"./modules/SegmentedColormap/Module":143,"./modules/SegmentedColormap/info":145}],125:[function(require,module,exports){
},{"./modules/Brightness/Module":128,"./modules/Brightness/info":129,"./modules/Crop/Module":131,"./modules/Crop/info":132,"./modules/DecodeQr/Module":133,"./modules/DecodeQr/info":134,"./modules/Dynamic/Module":135,"./modules/Dynamic/info":136,"./modules/FisheyeGl/Module":137,"./modules/FisheyeGl/info":138,"./modules/GreenChannel/Module":139,"./modules/GreenChannel/info":140,"./modules/Invert/Module":141,"./modules/Invert/info":142,"./modules/NdviRed/Module":143,"./modules/NdviRed/info":144,"./modules/SegmentedColormap/Module":145,"./modules/SegmentedColormap/info":147}],125:[function(require,module,exports){
function ReplaceImage(ref,selector,steps,options) {
if(!ref.options.inBrowser) return false; // This isn't for Node.js
var tempSequencer = ImageSequencer({ui: false});
Expand Down Expand Up @@ -38923,6 +38926,76 @@ module.exports = function UserInterface(events = {}) {
}

},{}],128:[function(require,module,exports){
/*
* Changes the Image Brightness
*/

module.exports = function Brightness(options,UI){
options = options || {};
options.title = "Brightness";
options.description = "Changes the brightness of the image";

//Tell the UI that a step has been set up
UI.onSetup(options.step);
var output;

function draw(input,callback){

// Tell the UI that a step is being drawn
UI.onDraw(options.step);

var step = this;

function changePixel(r, g, b, a){
var val = (options.brightness)/100.0

r = val*r<255?val*r:255
g = val*g<255?val*g:255
b = val*b<255?val*b:255
return [r , g, 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,
format: input.format,
image: options.image,
callback: callback
});

}
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}
},{"../_nomodule/PixelManipulation.js":148}],129:[function(require,module,exports){
module.exports={
"name": "Brightness",
"description": "Change the brightness of the image by given value",
"inputs": {
"brightness": {
"type": "integer",
"desc": "% brightness for the new image",
"default": 0
}
}
}
},{}],130:[function(require,module,exports){
(function (Buffer){
module.exports = function Crop(input,options,callback) {

Expand Down Expand Up @@ -38968,7 +39041,7 @@ module.exports = function Crop(input,options,callback) {
};

}).call(this,require("buffer").Buffer)
},{"buffer":3,"get-pixels":19,"save-pixels":93}],129:[function(require,module,exports){
},{"buffer":3,"get-pixels":19,"save-pixels":93}],131:[function(require,module,exports){
/*
* Image Cropping module
* Usage:
Expand Down Expand Up @@ -39029,7 +39102,7 @@ module.exports = function Crop(input,options,callback) {
}
}

},{"./Crop":128}],130:[function(require,module,exports){
},{"./Crop":130}],132:[function(require,module,exports){
module.exports={
"name": "Crop",
"description": "Crop image to given x, y, w, h",
Expand Down Expand Up @@ -39058,7 +39131,7 @@ module.exports={
}
}

},{}],131:[function(require,module,exports){
},{}],133:[function(require,module,exports){
/*
* Decodes QR from a given image.
*/
Expand Down Expand Up @@ -39114,7 +39187,7 @@ module.exports = function DoNothing(options,UI) {
}
}

},{"get-pixels":19,"jsqr":51}],132:[function(require,module,exports){
},{"get-pixels":19,"jsqr":51}],134:[function(require,module,exports){
module.exports={
"name": "Decode QR",
"inputs": {
Expand All @@ -39126,7 +39199,7 @@ module.exports={
}
}

},{}],133:[function(require,module,exports){
},{}],135:[function(require,module,exports){
module.exports = function Dynamic(options,UI) {

options = options || {};
Expand Down Expand Up @@ -39203,7 +39276,7 @@ module.exports = function Dynamic(options,UI) {
}
}

},{"../_nomodule/PixelManipulation.js":146}],134:[function(require,module,exports){
},{"../_nomodule/PixelManipulation.js":148}],136:[function(require,module,exports){
module.exports={
"name": "Dynamic",
"description": "A module which accepts JavaScript math expressions to produce each color channel based on the original image's color. See <a href='https://publiclab.org/wiki/infragram-sandbox'>Infragrammar</a>.",
Expand Down Expand Up @@ -39231,7 +39304,7 @@ module.exports={
}
}

},{}],135:[function(require,module,exports){
},{}],137:[function(require,module,exports){
/*
* Resolves Fisheye Effect
*/
Expand Down Expand Up @@ -39315,7 +39388,7 @@ module.exports = function DoNothing(options,UI) {
}
}

},{"fisheyegl":11}],136:[function(require,module,exports){
},{"fisheyegl":11}],138:[function(require,module,exports){
module.exports={
"name": "Fisheye GL",
"inputs": {
Expand Down Expand Up @@ -39381,7 +39454,7 @@ module.exports={
}
}

},{}],137:[function(require,module,exports){
},{}],139:[function(require,module,exports){
/*
* Display only the green channel
*/
Expand Down Expand Up @@ -39436,14 +39509,14 @@ module.exports = function GreenChannel(options,UI) {
}
}

},{"../_nomodule/PixelManipulation.js":146}],138:[function(require,module,exports){
},{"../_nomodule/PixelManipulation.js":148}],140:[function(require,module,exports){
module.exports={
"name": "Green Channel",
"inputs": {
}
}

},{}],139:[function(require,module,exports){
},{}],141:[function(require,module,exports){
/*
* Invert the image
*/
Expand Down Expand Up @@ -39499,15 +39572,15 @@ module.exports = function Invert(options,UI) {
}
}

},{"../_nomodule/PixelManipulation.js":146}],140:[function(require,module,exports){
},{"../_nomodule/PixelManipulation.js":148}],142:[function(require,module,exports){
module.exports={
"name": "Invert",
"description": "Inverts the image.",
"inputs": {
}
}

},{}],141:[function(require,module,exports){
},{}],143:[function(require,module,exports){
/*
* NDVI with red filter (blue channel is infrared)
*/
Expand Down Expand Up @@ -39563,14 +39636,14 @@ module.exports = function NdviRed(options,UI) {
}
}

},{"../_nomodule/PixelManipulation.js":146}],142:[function(require,module,exports){
},{"../_nomodule/PixelManipulation.js":148}],144:[function(require,module,exports){
module.exports={
"name": "NDVI Red",
"inputs": {
}
}

},{}],143:[function(require,module,exports){
},{}],145:[function(require,module,exports){
module.exports = function SegmentedColormap(options,UI) {

options = options || {};
Expand Down Expand Up @@ -39623,7 +39696,7 @@ module.exports = function SegmentedColormap(options,UI) {
}
}

},{"../_nomodule/PixelManipulation.js":146,"./SegmentedColormap":144}],144:[function(require,module,exports){
},{"../_nomodule/PixelManipulation.js":148,"./SegmentedColormap":146}],146:[function(require,module,exports){
/*
* Accepts a value from 0-255 and returns the new color-mapped pixel
* from a lookup table, which can be specified as an array of [begin, end]
Expand Down Expand Up @@ -39712,7 +39785,7 @@ var colormaps = {
])
}

},{}],145:[function(require,module,exports){
},{}],147:[function(require,module,exports){
module.exports={
"name": "Segmented Colormap",
"description": "Maps brightness values (average of red, green & blue) to a given color lookup table, made up of a set of one more color gradients.",
Expand All @@ -39726,7 +39799,7 @@ module.exports={
}
}

},{}],146:[function(require,module,exports){
},{}],148:[function(require,module,exports){
(function (Buffer){
/*
* General purpose per-pixel manipulation
Expand Down
2 changes: 1 addition & 1 deletion dist/image-sequencer.min.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/Modules.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/*
* Core modules and their info files
*/
* Core modules and their info files
*/
module.exports = {
'green-channel': [
require('./modules/GreenChannel/Module'),require('./modules/GreenChannel/info')
],
'brightness': [
require('./modules/Brightness/Module'),require('./modules/Brightness/info')
],
'ndvi-red': [
require('./modules/NdviRed/Module'),require('./modules/NdviRed/info')
],
Expand Down
57 changes: 57 additions & 0 deletions src/modules/Brightness/Module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Changes the Image Brightness
*/

module.exports = function Brightness(options,UI){
options = options || {};
options.title = "Brightness";
options.description = "Changes the brightness of the image";

//Tell the UI that a step has been set up
UI.onSetup(options.step);
var output;

function draw(input,callback){

// Tell the UI that a step is being drawn
UI.onDraw(options.step);

var step = this;

function changePixel(r, g, b, a){
var val = (options.brightness)/100.0

r = val*r<255?val*r:255
g = val*g<255?val*g:255
b = val*b<255?val*b:255
return [r , g, 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,
format: input.format,
image: options.image,
callback: callback
});

}
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}
11 changes: 11 additions & 0 deletions src/modules/Brightness/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Brightness",
"description": "Change the brightness of the image by given value",
"inputs": {
"brightness": {
"type": "integer",
"desc": "% brightness for the new image",
"default": 0
}
}
}
2 changes: 1 addition & 1 deletion test/image-sequencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test('loadImages loads a DataURL image and creates a step.', function (t){

test('modulesInfo() returns info for each module', function (t){
var info = sequencer.modulesInfo();
t.equal(Object.keys(info).length, 8);
t.equal(Object.keys(info).length, 9);
t.equal(Object.keys(info).length, Object.keys(sequencer.modules).length);
t.equal(info.hasOwnProperty(Object.keys(sequencer.modules)[0]), true);
t.equal(info[Object.keys(sequencer.modules)[0]].hasOwnProperty('name'), true);
Expand Down

0 comments on commit 8619894

Please sign in to comment.