3 ms·
In my experience, 3 passes of box blur looks good enough for small kernels (less than 50px). Is this faster than that?
by sebastianmestre 3y ago
In my experience, 3 passes of box blur looks good enough for small kernels (less than 50px). Is this faster than that?
- danbruc 3y agoWill be essentially the same performance. A box filter has to add one pixel entering the kernel and remove one pixel exiting the kernel. This one has one pixel entering and leaving each half of the kernel and then combining the two halfs. So three box blurs have six additions and once this filter is also six additions. Maybe the box filter could be somewhat slower because it has to increment two pointers three times while stack blur has to increment three pointers once and also incurs the loop overhead only once. For a fixed radius you could however use only one pointer and realize the offsets between the pointers with an appropriate addressing mode if available on the target architecture. This is the box filter inner loop. sum += data[right++] - data[left++] This is the stack blur inner loop. lsum += data[middle] - data[left++] rsum += data[right++] - data[middle++] sum += rsum - lsum