Last active
March 5, 2017 07:28
-
-
Save Underdoge/554ad12a52537b50578ff700d7d8896a to your computer and use it in GitHub Desktop.
boxBlur
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
function boxBlur(image) { | |
var sum=0; | |
var blurred=[],line=[]; | |
for (var x=0;x+3<=image.length;x++){ | |
for (var y=0;y+3<=image[0].length;y++){ | |
sum=0; | |
for (var i=x;i<3+x;i++){ | |
for (var j=y;j<3+y;j++){ | |
sum+=image[i][j]; | |
} | |
} | |
line.push(Math.floor(sum/9)); | |
} | |
blurred[x]=line; | |
line=[]; | |
} | |
return blurred; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment