Suppose, we have a bitmap image represented as a 2D integer array,
int [,] image2D;
whose FFT is Complex[,] fftImage2D;
Suppose, we have an kernel represented as a 2D integer array,
int [,] kernel2D;
whose FFT is Complex[,] fftKernel2D;
We know that, the convolution (in spatial domain) of image2D
and kernel2D
would be,
int Rows = image2D.GetLength(0);
int Cols = image2D.GetLength(1);
for(int i=0 ; i<Rows ; i++)
{
for(int j=0 ; j<Cols ; j++)
{
//sweep the kernel2D across image2D
//...........................
}
}
We also know that, convolution in frequency domain would be, multiplication between fftImage2D
and fftKernel2D
.
How can I do this multiplication?
How can I multiply two Complex [,]
type 2D arrays of different dimensions? I have understood the theory. My problem is practical implementation. As I described in the question,
Are DFT of the image and DFT of the kernel going to be of different sizes? I guess so. So, how can I multiply them element by element?
In my code, each of the DFTs are represented by 2D Complex numbers. Should, I multiply them according to complex-number's multiplication rule? Probably yes. But, only when their dimensions are same. Right?