Suppose,
u = [1 2 1 3 ; 1 2 1 3 ; 1 2 1 3];
v = [2 0 1 ; 2 0 1 ; 2 0 1];
I want to achieve
w = conv2(u, v); % [2 4 3 8 1 3 ; 4 8 6 16 2 6 ; 6 12 9 24 3 9 ; 4 8 6 16 2 6 ; 2 4 3 8 1 3]
And, suppose, I don't want to use conv2().
Using Matlab, I discovered that,
w1 = conv([1 2 1 3], [2 0 1]) % [2 4 3 8 1 3]
w2 = conv([1 2 1 3], [2 0 1]) % [2 4 3 8 1 3]
w3 = conv([1 2 1 3], [2 0 1]) % [2 4 3 8 1 3]
So, we get:
w123 = [w1 ; w2 ; w3] % [2 4 3 8 1 3 ; 2 4 3 8 1 3 ; 2 4 3 8 1 3];
Using Matlab, I also discovered that,
x = [2 ; 2 ; 2]
y = [1 ; 1 ; 1]
z = conv(x, y); % [2 ; 4 ; 6 ; 4 ; 2];
x = [4 ; 4 ; 4]
y = [1 ; 1 ; 1]
z = conv(x, y); % [4 ; 8 ; 12 ; 8 ; 4];
x = [3 ; 3 ; 3]
y = [1 ; 1 ; 1]
z = conv(x, y); % [3 ; 6 ; 9 ; 6 ; 3];
x = [8 ; 8 ; 8]
y = [1 ; 1 ; 1]
z = conv(x, y); % [8 ; 16 ; 24 ; 16 ; 8];
x = [1 ; 1 ; 1]
y = [1 ; 1 ; 1]
z = conv(x, y); % [1 ; 2 ; 3 ; 2 ; 1];
x = [3 ; 3 ; 3]
y = [1 ; 1 ; 1]
z = conv(x, y); % [3 ; 6 ; 9 ; 6 ; 3];
Which means, if we perform 1D convolution on each row of u with kernel [2 0 1], and then apply 1D convolution on each column with kernel [1; 1; 1], we obtain:
2 4 3 8 1 3
4 8 6 16 2 6
6 12 9 24 3 9
4 8 6 16 2 6
2 4 3 8 1 3
So, my question is, where does this [1 ; 1 ; 1] come from?
And, most importantly, what would happen if the rows are not same?