2D Convolution Operation Problem
1 2 3 0 1
I=
4 5 6 1 2 1 0 -1
7 8 9 0 1 K= 1 0 -1
1 2 3 4 5 1 0 -1
6 7 8 9 0
We slide the 3×3 kernel over the 5×5 image producing a 3×3 output. For each 3×3 patch:
show the patch, the element-wise product with the kernel, row sums, then the total.
1) Output at (row 0, col 0) → top-left
Patch:
[1 2 3]
[4 5 6]
[7 8 9]
Element-wise product (patch * kernel):
[1*1 2*0 3*(-1)] => [ 1 0 -3 ]
[4*1 5*0 6*(-1)] => [ 4 0 -6 ]
[7*1 8*0 9*(-1)] => [ 7 0 -9 ]
Row sums: 1+0-3 = -2, 4+0-6 = -2, 7+0-9 = -2
Total = -2 + (-2) + (-2) = -6
Output(0,0) = -6
2) Output at (0,1) → top-middle
Patch:
[2 3 0]
[5 6 1]
[8 9 0]
Product:
[2*1 3*0 0*(-1)] => [ 2 0 0 ]
[5*1 6*0 1*(-1)] => [ 5 0 -1 ]
[8*1 9*0 0*(-1)] => [ 8 0 0 ]
Row sums: 2, 5+0-1 = 4, 8
Total = 2 + 4 + 8 = 14
Output(0,1) = 14
3) Output at (0,2) → top-right
Patch:
[3 0 1]
[6 1 2]
[9 0 1]
Product:
[3*1 0*0 1*(-1)] => [ 3 0 -1 ]
[6*1 1*0 2*(-1)] => [ 6 0 -2 ]
[9*1 0*0 1*(-1)] => [ 9 0 -1 ]
Row sums: 3+0-1 = 2, 6+0-2 = 4, 9+0-1 = 8
Total = 2 + 4 + 8 = 14
Output(0,2) = 14
4) Output at (1,0) → middle-left
Patch:
[4 5 6]
[7 8 9]
[1 2 3]
Product:
[4*1 5*0 6*(-1)] => [ 4 0 -6 ]
[7*1 8*0 9*(-1)] => [ 7 0 -9 ]
[1*1 2*0 3*(-1)] => [ 1 0 -3 ]
Row sums: -2, -2, -2
Total = -6
Output(1,0) = -6
5) Output at (1,1) → center
Patch:
[5 6 1]
[8 9 0]
[2 3 4]
Product:
[5*1 6*0 1*(-1)] => [ 5 0 -1 ] (row sum = 4)
[8*1 9*0 0*(-1)] => [ 8 0 0 ] (row sum = 8)
[2*1 3*0 4*(-1)] => [ 2 0 -4 ] (row sum = -2)
Total = 4 + 8 + (-2) = 10
Output(1,1) = 10
6) Output at (1,2) → middle-right
Patch:
[6 1 2]
[9 0 1]
[3 4 5]
Product:
[6*1 1*0 2*(-1)] => [ 6 0 -2 ] (row sum = 4)
[9*1 0*0 1*(-1)] => [ 9 0 -1 ] (row sum = 8)
[3*1 4*0 5*(-1)] => [ 3 0 -5 ] (row sum = -2)
Total = 4 + 8 + (-2) = 10
Output(1,2) = 10
7) Output at (2,0) → bottom-left
Patch:
[7 8 9]
[1 2 3]
[6 7 8]
Product:
[7*1 8*0 9*(-1)] => [ 7 0 -9 ]
[1*1 2*0 3*(-1)] => [ 1 0 -3 ]
[6*1 7*0 8*(-1)] => [ 6 0 -8 ]
Row sums: -2, -2, -2
Total = -6
Output(2,0) = -6
8) Output at (2,1) → bottom-middle
Patch:
[8 9 0]
[2 3 4]
[7 8 9]
Product:
[8*1 9*0 0*(-1)] => [ 8 0 0 ] (row sum = 8)
[2*1 3*0 4*(-1)] => [ 2 0 -4 ] (row sum = -2)
[7*1 8*0 9*(-1)] => [ 7 0 -9 ] (row sum = -2)
Total = 8 + (-2) + (-2) = 4
Output(2,1) = 4
9) Output at (2,2) → bottom-right
Patch:
[9 0 1]
[3 4 5]
[8 9 0]
Product:
[9*1 0*0 1*(-1)] => [ 9 0 -1 ] (row sum = 8)
[3*1 4*0 5*(-1)] => [ 3 0 -5 ] (row sum = -2)
[8*1 9*0 0*(-1)] => [ 8 0 0 ] (row sum = 8)
Total = 8 + (-2) + 8 = 14
Output(2,2) = 14
Final 3×3 output (no flip, stride 1, no padding)
[ -6 14 14 ]
[ -6 10 10 ]
[ -6 4 14 ]