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.
Batsu source share