Skip to content

Instantly share code, notes, and snippets.

@davidsonfellipe
Last active December 18, 2015 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsonfellipe/5864534 to your computer and use it in GitHub Desktop.
Save davidsonfellipe/5864534 to your computer and use it in GitHub Desktop.
LenaJS.grayscale = function(pixels, args) {
for (var i = 0; i < pixels.data.length; i += 4) {
var r = pixels.data[i],
g = pixels.data[i+1],
b = pixels.data[i+2];
pixels.data[i] = pixels.data[i+1] = pixels.data[i+2] = 0.2126*r + 0.7152*g + 0.0722*b;
}
return pixels;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment