I got the matrix below:
9 18 27 36 45
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
and the kernel:
-0.5+0.8662i 1 -0.5-0.8662i
I'm trying to perform the convolution using valid mode:
ans = conv2(matrix,kernel,'valid');
The matlab returns:
0.0000+15.5916i 0.0000+15.5916i 0.0000+15.5916i
My question is how I can achieve the same results like matlab. I'm trying to do in the matlab in the first point, but the results is different.
a = matrix(1,1) * kernel(1);
a = a + matrix(1,2) * kernel(2);
a = a + matrix(1,3) * kernel(3);
Result: 0-15.5916i
For some reason the sign of the imaginary is positive using convolution. Why ?
I believe convolution is usually performed by "flipping" the kernel (left-right, up-down) and then sliding it across the matrix to perform a sum of multiplications.
In other words, what matlab is actually computing is:
a = matrix(1,1) * kernel(3);
a = a + matrix(1,2) * kernel(2);
a = a + matrix(1,3) * kernel(1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With