I am trying implement inverse discrete Fourier transfrom for the image which i applied discrete Fourier transform beforehand. The output is kind of two images. One image is in correct position the other is reversed position. Could you help me to solve this issue?
Here is the code i have written.
double inverseFourierReal = 0.0;
double inverseFourierImg = 0.0;
double degreeValue,cosValue,sinValue;
// double inverse = inverseFourier;
for(int rowm = 0; rowm < rows; rowm++ )
for(int coln = 0; coln < cols; coln++ ) {
inverseFourierImg = 0.0;
inverseFourierReal = 0.0;
for(int rowk = 0; rowk < rows; rowk++ ) {
for(int coll = 0; coll < cols; coll++ ) {
degreeValue = 2. * PI * (float(rowk*rowm)/rows + float(coll*coln)/cols);
cosValue = cos(degreeValue);
sinValue = sin(degreeValue);
inverseFourierReal += cosValue * fourierImageReal[rowk][coll] - sinValue * fourierImageImg[rowk][coll];
//inverseFourierImg += (cosValue * fourierImageImg[rowk][coll] + sinValue * fourierImageReal[rowk][coll]);
//cout<<inverseFourierReal;
}
}
invr_FourierReal.at<double>(rowm,coln) = abs((inverseFourierReal) / (sqrt(rows*cols)));
// invr_FourierReal.at<double>(rowm,coln) = double(inverseFourierReal) / (sqrt(rows*cols));
//invr_FourierImg.at<double>(int(rowm),int(coln)) = double(inverseFourierImg) / (sqrt(rows*cols));
}
You can see the output image here:
Edit:
I have changed the code and you can see new output. it is upside down.
I used Lena image for the input
P.S sorry for my poor English.