The Glacial Box Blur Algorithm Implementation

Computing the new average by going over the entire box for each pixel is obviously wrong.. you should subtract the edge column that's leaving and add the one that's entering the box.. but, at least, it works 😊 https://codepen.io/chipdesigner/pen/YzONwOo function doBlur(){ var w = img.getWidth(); var h = img.getHeight(); var x,y; var imgBlur = new SimpleImage(width=img.getWidth(), height=img.getHeight()); var p, pb, pij, avgR,avgG,avgB,total; for( p of img.values() ){ avgR = 0; avgG = 0; avgB = 0; total = 0; x = p.getX(); y = p.getY(); for( let i = Math.max(0,x-BOX); i <= Math.min(w-1,x+BOX);i++ ){ for( let j = Math.max(0,y-BOX); j <= Math.min(h-1,y+BOX);j++){ pij = img.getPixel(i,j); avgR += pij.getRed(); avgG += pij.getGreen(); ...