Is there anyway to do this faster? I want to reduce the O(N^2) complexity to something lower. Note: The filter kernel is rotational symmetric around N/2.
for(unsigned int k=N/2;k<source.getHeight()-N/2;k++)
{
for(unsigned int l=N/2;l<source.getWidth()-N/2;l++)
{
for(unsigned int m=0;m<N;m++)
{
for(unsigned int n=0;n<N;n++)
{
dest(l,k).red +=p_kernel[m][n]*source(l+n-N/2,k+m-N/2).red;
dest(l,k).green+=p_kernel[m][n]*source(l+n-N/2,k+m-N/2).green;
dest(l,k).blue +=p_kernel[m][n]*source(l+n-N/2,k+m-N/2).blue;
}
}
}
}
You need to learn about convolution theorem. It basically fourier transform of your image and kernel multiplied and then the result reverse transformed. Search it, there are tons of sites with example code.