Generating a Square-sized Convolution matrix

8 次查看(过去 30 天)
In my work, I am using a 7 x 7 kernel filter to convolve with a data matrix. In one step, I have to generate a matrix for this kernel and invert that matrix. To make it invertible, the convolution matrix must be square (pseudo inverse in not desired). Additionally, the convolution matrix should be generated such a way that edge conditions of the data is handled by zero padding. I tried convmtx(h,n) function, but it doesn't return a square matrix. But I need a convolution matrix which is square and sparse. To be more specific, if data size is (m by m), I will reshape it into a data vector V of size (1 by m*m), then I need a (m*m by m*m) filter matrix F, which will be multiplied with V. Is there any easy way to do that? Is there any other MATLAB function that can do this for me?

回答(2 个)

Harsha Medikonda
Harsha Medikonda 2015-7-6
To generate a square convolution matrix, you could use the function conv2. Please refer to the documentation link below for its usage

Image Analyst
Image Analyst 2015-7-7
You can use conv2() with the full option. Create the convolution kernel however you want to do it, like by taking the inverse of something or whatever. Then:
filteredImage = conv2(inputMatrix, kernel, 'full');
That will give zero padding but now you have to crop it to get back to the original size of the matrix:
filteredImage = filteredImage(3:end-3, 3:end-3);

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by