Skip to content

Instantly share code, notes, and snippets.

@Underdoge
Last active March 5, 2017 07:28
Show Gist options
  • Save Underdoge/554ad12a52537b50578ff700d7d8896a to your computer and use it in GitHub Desktop.
Save Underdoge/554ad12a52537b50578ff700d7d8896a to your computer and use it in GitHub Desktop.
boxBlur
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