Iterative 2D Convolution Optimization, Help?

I need to write an iterative 2D convolution, i.e. Starting with a 4k sample image, run a convolution algorithm, then run the same convolution on the result. Padding is added to the image such that the result is 4K.

My thought was to implement an Im2col technique, apply a Gaussian kernel, then place the output back in the image. The key issue is: Is there a way to avoid recomputing the patch matrix each step? Or, is there an alternative method which may require less memory reallocation/overall computation time?

Thanks!

Not sure I understood that correctly. You want the convolution of an image I with some kernel K and then repeat that process. So in the end you compute I \star K \star \ldots \star K?
By the convolution theorem, this is equivalent to \mathcal{F}(\hat I \hat{K}^n), where the products are elementwise and the hat denotes a Fourier transformed quantity. So you just need to Fourier transform your kernel once and then exponentiate it to the power of how many times you want to apply the kernel.

If your kernel is truly a Gaussian then there is another shortcut: The convolution of a Gaussian with itself is again a Gaussian - you just get twice the variance. So instead of doing N convolution of gaussians with variance \sigma^2 you can do a sinble convolution with a Gaussian of variance N \sigma^2.

For doing single convolutions in Julia, check out DSP.jl

3 Likes