Generating a Square-sized Convolution matrix

9 Ansichten (letzte 30 Tage)
Mohammad Imrul Jubair
Mohammad Imrul Jubair am 3 Jul. 2015
Beantwortet: Image Analyst am 7 Jul. 2015
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?

Antworten (2)

Harsha Medikonda
Harsha Medikonda am 6 Jul. 2015
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 am 7 Jul. 2015
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);

Kategorien

Mehr zu Linear Algebra finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by