Improve Code Quality and Optimize (#763)

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
Varun Gupta
2019-02-16 11:05:32 +05:30
committed by GitHub
parent f42aa2fd67
commit 75dc23fb55
26 changed files with 1332 additions and 921 deletions

View File

@@ -2,19 +2,15 @@ module.exports = function Balance(options, UI) {
var output;
function draw (input, callback, progressObj) {
function draw(input, callback, progressObj) {
options.temperature = (options.temperature > "40000") ? "40000" : options.temperature
options.temperature = (options.temperature > "40000") ? "40000" : options.temperature
progressObj.stop(true);
progressObj.overrideFlag = true;
var step = this;
function changePixel(r, g, b, a) {
return [r, g, b ,a]
}
function extraManipulation(pixels) {
let temp = parseInt(options.temperature)
@@ -39,35 +35,34 @@ module.exports = function Balance(options, UI) {
b = Math.min(Math.max(138.5177312231 * Math.log(b) - 305.0447927307, 0), 255);
}
for(let i=0; i<pixels.shape[0]; i++) {
for (let j=0; j<pixels.shape[1]; j++) {
for (let i = 0; i < pixels.shape[0]; i++) {
for (let j = 0; j < pixels.shape[1]; j++) {
r_data = pixels.get(i,j,0)
r_new_data = (255/r) * r_data
pixels.set(i,j,0,r_new_data)
r_data = pixels.get(i, j, 0)
r_new_data = (255 / r) * r_data
pixels.set(i, j, 0, r_new_data)
g_data = pixels.get(i,j,1)
g_new_data = (255/g) * g_data
pixels.set(i,j,1,g_new_data)
g_data = pixels.get(i, j, 1)
g_new_data = (255 / g) * g_data
pixels.set(i, j, 1, g_new_data)
b_data = pixels.get(i,j,2)
b_new_data = (255/b) * b_data
pixels.set(i,j,2,b_new_data)
}
b_data = pixels.get(i, j, 2)
b_new_data = (255 / b) * b_data
pixels.set(i, j, 2, b_new_data)
}
}
return pixels
return pixels
}
function output (image, datauri, mimetype){
function output(image, datauri, mimetype) {
step.output = {src:datauri,format: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,