Last active
December 18, 2015 23:49
-
-
Save davidsonfellipe/5864534 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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