I want to find a convolution matrix for a certain 2D kernel $ H $.
For example, for image Img
of size $ m \times n $ , I want (in MATALB):
T * Img = reshape(conv2(Img, H, 'same'), [], 1);
Where T
is the convolution matrix and same
means the Convolution Shape (Output Size) matched the input size.
Theoretically, H should be converted to a toeplitz matrix, I'm using the MATLAB function convmtx2()
:
T = convmtx2(H, m, n);
Yet T
is of size $ (m+2) (n+2) \times (mn) $ as MATLAB's convmtx2
generates a convolution matrix which matches Convolution Shape of full
.
Is there a way to generate the Convolution Matrix which matches using conv2()
with the same
convolution shape parameter?