Separated Filter is slower

Re: Separated Filter is slower

by Hussein Osman -
Number of replies: 0
Hi Naravich,

As you pointed out, it is all about how you implement the convolution function. If you performed element-wise multiplication for filter convolution using loops and standard multiplication, then it would definitely take more time than if you were to use np.multiply(). Only then, you would have observed the difference in performance between the separated filters and the 2D filter.
You can write a simple test code to check the time difference between both implementations. For example, the standard element-wise multiplication of two 1000x1000 matrices would take around 0.432s, whereas the numpy function would take 0.003s. (numbers may differ for different machines, but the difference in magnitude would always be comparable).