mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-14 04:10:04 +01:00
Contrast module now uses changePixel Method (#1482)
* contrast module uses changePixel Method * change if block to Math function * fix bug Co-authored-by: Harsh Khandeparkar <34770591+HarshKhandeparkar@users.noreply.github.com> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
This commit is contained in:
committed by
Jeffrey Warren
parent
45c54bb9af
commit
94caefa2cd
@@ -15,9 +15,27 @@ module.exports = function Contrast(options, UI) {
|
||||
|
||||
var step = this;
|
||||
|
||||
function extraManipulation(pixels) {
|
||||
pixels = require('./Contrast')(pixels, options.contrast);
|
||||
return pixels;
|
||||
let contrast = options.contrast;
|
||||
|
||||
contrast = Number(contrast);
|
||||
if (contrast < -100) contrast = -100;
|
||||
if (contrast > 100) contrast = 100;
|
||||
contrast = (100.0 + contrast) / 100.0;
|
||||
contrast *= contrast;
|
||||
|
||||
function changeContrast(p){
|
||||
p -= 0.5;
|
||||
p *= contrast;
|
||||
p += 0.5;
|
||||
p *= 255;
|
||||
p = Math.max(0, p);
|
||||
p = Math.min(p, 255);
|
||||
return p;
|
||||
}
|
||||
|
||||
function changePixel(r, g, b, a) {
|
||||
|
||||
return [changeContrast(r / 255), changeContrast(g / 255), changeContrast(b / 255), a];
|
||||
}
|
||||
|
||||
function output(image, datauri, mimetype, wasmSuccess) {
|
||||
@@ -27,7 +45,7 @@ module.exports = function Contrast(options, UI) {
|
||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||
output: output,
|
||||
ui: options.step.ui,
|
||||
extraManipulation: extraManipulation,
|
||||
changePixel: changePixel,
|
||||
format: input.format,
|
||||
image: options.image,
|
||||
callback: callback,
|
||||
|
||||
Reference in New Issue
Block a user