#ifndef CONVOLUTION2D_H #define CONVOLUTION2D_H #ifndef __USE_SQUARE_BRACKETS_FOR_ELEMENT_ACCESS_OPERATOR #define __USE_SQUARE_BRACKETS_FOR_ELEMENT_ACCESS_OPERATOR #endif #include "../../math/boxkde/Image2D.h" #include "../../lib/simple_fft/fft.h" namespace DSP { template class Convolution2D { public: static inline Image2D convolve(Image2D signal, Image2D kernel){ RealArray2D signalReal; ComplexArray2D signalSpectrum; RealArray2D kernelReal; ComplexArray2D kernelSpectrum; //convert image2d single vector to 2d vector, just use pointers int signal_x = signal.width; int signal_y = signal.height; int kernel_x = kernel.width; int kernel_y = kernel.height; //check if power of 2, if not fill with zeros while(!isPowerOfTwo(signal_x)){ } if(!isPowerOfTwo(kernel.size)){ } //calculate FFT for both simple_fft::FFT(); //multiplay the results pointwise //IFFT simple_fft::IFFT(); //profit? } private: typedef std::vector > ComplexArray2D; typedef std::vector > RealArray2D; bool isPowerOfTwo (unsigned int x) { return ((x != 0) && !(x & (x - 1))); } }; } #endif // CONVOLUTION_H