There is a very important difference. The implementation in the image package seems to be a typical limited version used in image processing to achieve the βsameβ image size after convolution. Thus, it matches the βsameβ option in the signal processing package if we use mode = 'constant', as in the above examples. It seems that the signal processing package implements a real strict definition of the convolution operator. Perhaps for this reason it is slower. Find attached examples with completely different results.
In [13]: a=array([[1,2,1]]) In [14]: b=array([[1],[2],[1]]) In [17]: convolveim(a,b) Out[17]: array([[4, 8, 4]]) In [18]: convolveim(b,a) Out[18]: array([[4], [8], [4]]) In [19]: convolvesig(a,b) Out[19]: array([[1, 2, 1], [2, 4, 2], [1, 2, 1]]) In [20]: convolvesig(b,a) Out[20]: array([[1, 2, 1], [2, 4, 2], [1, 2, 1]])
Note that the implementation of the signal processing package is conditional, as expected for proper convolution. However, the implementation in the image package is not and provides a solution with the same parameters as the first parameter.
source share