Combination of two convolutional filters

What is a single filter matrix equivalent to applying [1 1 1] twice in an image using imfilter with the "full" parameter? Will it be another 1x3 matrix?

+4
source share
2 answers

convolution is associative, which means (f*g)*h = f*(g*h) . Therefore, instead of

 r = conv(conv(x, [1,1,1]), [1,1,1]) 

you can use more efficient ones (since you are minimized to the image only once)

 asd = conv([1,1,1], [1,1,1]); r = conv(x, asd) 

where is the new function [1 2 3 2 1] , which, however, does not have the same size of the original filter.

+7
source

The full parameter tells the filter function to return an image of the same size of the filtered image. You can apply the same filter as many times as you like, but if you use full every time, the size should not change.

0
source

Source: https://habr.com/ru/post/1444760/


All Articles