Created
May 10, 2021 14:28
-
-
Save RahmatSaeedi/b722eb87b9d6b982cc032ec311b09bca to your computer and use it in GitHub Desktop.
CodeSignal - Arcade - Intro - JS - Box Blur
This file contains 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) { | |
let bluredImage = Array.from(Array(image.length-2), () => new Array(image[0].length-2)); | |
for(let i = 1; i < image.length-1; i++) { | |
for(let j = 1; j < image[i].length-1; j++){ | |
bluredImage[i-1][j-1] = Math.floor(( | |
image[i-1][j-1] + image[i-1][j] + image[i-1][j+1] + | |
image[i][j-1] + image[i][j] + image[i][j+1] + | |
image[i+1][j-1] + image[i+1][j] + image[i+1][j+1] | |
)/9); | |
} | |
} | |
return bluredImage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment