I am trying to apply fourier transform to an image, by following the code from link http://www.docs.opencv.org/2.4/doc/tutorials/core/discrete_fourier_transform/discrete_fourier_transform.html , after this I am trying to remove the noise components which are visible in fourier spectrum as horizontal and vertical lines, like in this image shown in link below: (http://www.imagemagick.org/Usage/fourier/twigs_spectrum.png) - Spectrum image
Now after zeroing out the noise pixel locations in the spectrum, I just want to see how the original image is changed now. I have applied inverse DFT to it, and reconstructed the image also but the image is null image. Here is my code:
Mat magI_copy;
magI.copyTo(magI_copy);
//magI.convertTo(magI_copy, CV_8U);
//imshow("image", magI_copy); waitKey();
for (int i = 0; i < 86; i++){
for (int j = 127; j < 130;j++){
magI_copy.at<float>(i, j) = 0;
}
}
for (int i = 171; i < magI_copy.rows; i++){
for (int j = 127; j < 130; j++){
magI_copy.at<float>(i, j) = 0;
}
}
for (int i = 126; i < 131; i++){
for (int j = 0; j < 87; j++){
magI_copy.at<float>(i, j) = 0;
}
}
for (int i = 126; i < 131; i++){
for (int j = 170; j < magI_copy.cols; j++){
magI_copy.at<float>(i, j) = 0;
}
}
///////////Inverse Transform
cv::Mat inverseTransform;
cv::dft(magI_copy, inverseTransform, cv::DFT_INVERSE | cv::DFT_REAL_OUTPUT);
normalize(inverseTransform, inverseTransform, 0, 1, CV_MINMAX);
Mat finalimage;
inverseTransform.convertTo(finalimage, CV_8U);