1 //print("i: " + i + "j: " + j);
3 function gaussianBlur() {
4 for (var y
= 0; y
< height
; ++y
) {
5 for (var x
= 0; x
< width
; ++x
) {
6 var r
= 0, g
= 0, b
= 0, a
= 0;
7 for (var j
= 1 - kernelSize
; j
< kernelSize
; ++j
) {
8 if (y
+ j
< 0 || y
+ j
>= height
) continue;
9 for (var i
= 1 - kernelSize
; i
< kernelSize
; ++i
) {
10 if (x
+ i
< 0 || x
+ i
>= width
) continue;
11 r
+= squidImageData
[4 * ((y
+ j
) * width
+ (x
+ i
)) + 0] * kernel
[Math
.abs(j
)][Math
.abs(i
)];
12 g
+= squidImageData
[4 * ((y
+ j
) * width
+ (x
+ i
)) + 1] * kernel
[Math
.abs(j
)][Math
.abs(i
)];
13 b
+= squidImageData
[4 * ((y
+ j
) * width
+ (x
+ i
)) + 2] * kernel
[Math
.abs(j
)][Math
.abs(i
)];
14 a
+= squidImageData
[4 * ((y
+ j
) * width
+ (x
+ i
)) + 3] * kernel
[Math
.abs(j
)][Math
.abs(i
)];
17 squidImageData
[4 * (y
* width
+ x
) + 0] = r
/ kernelSum
;
18 squidImageData
[4 * (y
* width
+ x
) + 1] = g
/ kernelSum
;
19 squidImageData
[4 * (y
* width
+ x
) + 2] = b
/ kernelSum
;
20 squidImageData
[4 * (y
* width
+ x
) + 3] = a
/ kernelSum
;
23 return squidImageData
;