I'm trying to figure out the convolution matrix of a 2D-mask in MATLAB, for boht linear and circular convolution.
So far, I've got the command: convmtx2 which successful works when applying the operation: g = H?f if compared to imfilter(f,h,'full').
However, I've not found anything for the circular matrix. I've tried to generate my own matrix according to Gonzalez&Woods (block circulant matrix), but the results are not the same as imfilter(f,h,'circular'). The borders are different in appearance.
On the other hand, I've tried to do it just padding the mask with ceros (padarray(...,'post')) and performing the circular equivalent matrix (gallery('circul',hpadded(:)). The results are the same as with the aforementioned block circulant matrix.
I would be very grateful if you could give any idea about what happen, even if you have any source code. I've not seen anything on the Net about circular convolution matrix for 2D-mask (just only for 1D).
Thank you very much in advance,
MaS
I have no clear idea what you want to compute.
If you want to compute a convolution on a (Z/nZ) x (Z/mZ) (a torus like), then: simply use conv2, then operate the following on the output: cut the tail and add to the head. The butcher size is the size of the kernel minus one (-1).
Bruno
Sorry for not being so clear in my last post. My aim is to obtain the convolution matrix in both linear and circular convolution models, that is to say, H_matrix:
g(x,y) = h(x,y) ** f(x,y) <->
g_lexicographic = H_matrix . f_lexicographic
where H_matrix is the convolution matrix and f and g are 2D images.
Depending on the model, you have a diferent structure for the convolution matrix. Regarding lineal convolution, MATLAB offers the "convmtx2" to obtain the convolution matrix, but I have not found anything to get the analagous matrix in circular convolution model 2D.
I'm really interested in the H_matrix and not actually the convolution result, as I expect to perform some operations on that matrix.
I really appreciate your comments.
Best regards,
MaS
>
> I'm really interested in the H_matrix and not actually the convolution result, as I expect to perform some operations on that matrix.
The same remark applies on the convolution results and matrix.
Result: To convert linear to circular, do the tail cutting and add this tail to the head of the result.
For the matrix, just do the same on its rows.
Bruno