I have RGBalpha images stored in a row-major array of structures (RGBa, RGBa, etc.
) as 32 bits floats in C99. I need to blur them using large, non-separable, 2D kernels, channel by channel (each channel gets the same kernel). So I figured using the convolution theorem and doing it in Fourier space would be more efficient. I'm using FFTW3.
I saw FFTW3 uses the same data structure for 3D: image[width][height][channels]
. For disposable code, before, I use to split each channel apart and do a 2D convolution per channel, but I guess doing it in 3D at once would spare some data flip-flopping. So I'm headed toward 3D, although I'm not really comfortable with Fourier formalism in 3D.
However, there is something I don't make sense of, out of the FFTW3 documentation: what does the fftw_plan_dft_r2c_3d
function do ? Is it a channel-wise 2D FFT, or does it do a real 3D FFT with inter-channel frequency decomposition ? That's important because the alpha channel is there for SIMD alignment but is not relevant in the process and should not be linked to the solution.
Then I don't understand how to turn my 2D kernel into something usable in 3D (assuming the previous condition is met). Should I duplicate it along the depth axis (so, stack it 3 times), or only once and pad the remaining depth with zeros ?