Post

Replies

Boosts

Views

Activity

Reply to Custom CoreImage Box Blur kernel Much slower than equivalent built-in CIBoxBlur
It appears that you're not using a separable approach to your filter. Using a separable approach will take down the complexity from O(n^2) to O(2n) where the kernel size is nxn. I suggest you take a look at this video https://www.youtube.com/watch?v=SiJpkucGa1o to learn more about separable filters. I also suggest mipmapping the texture you want to blur and blurring one of the lower resolution levels of the mipmap. You can then scale it up with linear sampling to avoid pixelation of the final result. This is the approach that apple takes in this example for their implementation of a Gaussian Blur filter. The same approach can be used for box blurs. Finally, you can take advantage of the GPU's linear sampling to effectively half your kernel radius for the same result, which will make your filter much faster. To use this method, all you have to do is sample in between every 2 pixels instead of sampling each one individually. More information on how this is used in gaussian blurs can be found at: https://www.rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/#:~:text=see%20the%20difference.-,Linear%20sampling,-So%20far%2C%20we
Dec ’21