Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contrast Module should use changePixel Method #1472

Closed
harshkhandeparkar opened this issue Jan 12, 2020 · 1 comment · Fixed by #1482
Closed

Contrast Module should use changePixel Method #1472

harshkhandeparkar opened this issue Jan 12, 2020 · 1 comment · Fixed by #1482

Comments

@harshkhandeparkar
Copy link
Member

Please describe the problem (or idea)

The Contrast module currently uses extraManipulation but the manipulation process is repetitive so it could use changePixel instead which would also WebAssembly accelerate it

Current Code:

let oldpix = _.cloneDeep(pixels);
contrast = Number(contrast);
if (contrast < -100) contrast = -100;
if (contrast > 100) contrast = 100;
contrast = (100.0 + contrast) / 100.0;
contrast *= contrast;
for (let i = 0; i < pixels.shape[0]; i++) {
for (let j = 0; j < pixels.shape[1]; j++) {
var rgbarray = [oldpix.get(i, j, 0) / 255.0, oldpix.get(i, j, 1) / 255.0, oldpix.get(i, j, 2) / 255.0];
for(var idx = 0;idx < 3;idx++){
rgbarray[idx] -= 0.5;
rgbarray[idx] *= contrast;
rgbarray[idx] += 0.5;
rgbarray[idx] *= 255;
if (rgbarray[idx] < 0) rgbarray[idx] = 0;
if (rgbarray[idx] > 255) rgbarray[idx] = 255;
}
pixelSetter(i, j, rgbarray, pixels);

Please show us where to look

https://beta.sequencer.publiclab.org

What's your PublicLab.org username?

This can help us diagnose the issue:

Browser, version, and operating system

Many bugs are related to these -- please help us track it down and reproduce what you're seeing!


Thank you!

Your help makes Public Lab better! We deeply appreciate your helping refine and improve this site.

To learn how to write really great issues, which increases the chances they'll be resolved, see:

https://publiclab.org/wiki/developers#Contributing+for+non-coders

@harshkhandeparkar harshkhandeparkar changed the title Contrast Module should use ChangePixel Contrast Module should use changePixel Jan 12, 2020
@harshkhandeparkar harshkhandeparkar changed the title Contrast Module should use changePixel Contrast Module should use changePixel Method Jan 12, 2020
@rishabhshuklax
Copy link
Member

Can I claim this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants