meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.56k stars 406 forks source link

Add channel parameter for greyscale filter #157

Open letmaik opened 10 years ago

letmaik commented 10 years ago

From a given color image I need to display one of its channels as a greyscale image. For that I do something like:

this.channels({
    red: ch == 'r' ? 0 : -100,
    green: ch == 'g' ? 0 : -100,
    blue: ch == 'b' ? 0 : -100
});

However then I cannot use the greyscale filter as the resulting image is too dark. I don't want a weighted average of all channels but instead just use a single channel and make a greyscale image out of it. Is there an easy way to do that and if not, could it be achieved by adding a channel parameter to the greyscale filter?