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

Filter parametrization #28

Open
andcl opened this issue Jul 28, 2020 · 4 comments
Open

Filter parametrization #28

andcl opened this issue Jul 28, 2020 · 4 comments

Comments

@andcl
Copy link

andcl commented Jul 28, 2020

Not really an issue, but a suggestion.
It could be really nice to somehow parametrize the effects and the amount of effect in each one, using one or more selectors for example.

@davidsonfellipe
Copy link
Owner

@andcl Hey Andrés, I started to add this with the new function for brightness, from -100 to +100

https://github.com/davidsonfellipe/lena.js/blob/master/docs/all-filters.html

Thanks for reporting

@andcl
Copy link
Author

andcl commented Jul 29, 2020

@davidsonfellipe Very nice job, will keep an eye on it when you arrive to the highpass filter ;)
Thanks for the response.

@davidsonfellipe
Copy link
Owner

@andcl some new filters accepting amount:

  • contrast
  • noise
  • brightness
  • thresholding

@davidsonfellipe
Copy link
Owner

@andcl alternatively you can create filters based on convolution like this.

// npm install  'lena.js'
import { convolution } from 'lena.js';

const customFilter = function (pixels) {
  const divider = 15
  const operator = [
    2 / divider,
    4 / divider,
    5 / divider,
    4 / divider,
    2 / divider,
    4 / divider,
    9 / divider,
    12 / divider,
    9 / divider,
    4 / divider,
    5 / divider,
    12 / divider,
    15 / divider,
    12 / divider,
    5 / divider,
    4 / divider,
    9 / divider,
    12 / divider,
    9 / divider,
    4 / divider,
    2 / divider,
    4 / divider,
    5 / divider,
    4 / divider,
    2 / divider,
  ]

  return convolution(pixels, operator)
}

export default customFilter

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

No branches or pull requests

2 participants