There are already some answers regarding the conv2(A,B,'same')
function (e.g. here: 2D Convolution in Python similar to Matlab's conv2) but I was unable to find anything regarding conv2(h1,h2,A,'same')
.
To quote the MATLAB documentation:
C = conv2(h1,h2,A) first convolves A with the vector h1 along the rows and then with the vector h2 along the columns. The size of C is determined as follows: if n1 = length(h1) and n2 = length(h2), then mc = max([ma+n1-1,ma,n1]) and nc = max([na+n2-1,na,n2]).
Is there a way to achieve this behavior using python (or numpy, scipy, etc.)?
Context:
I try to achieve the following:
h1 = [ 0.05399097 0.24197072 0.39894228 0.24197072 0.05399097]
h2 = [ 0.10798193 0.24197072 -0. -0.24197072 -0.10798193]
A = img[:,:,1]
C = conv2(h1, h2, A, 'same')
Where img is a rgb image.