1
$\begingroup$

I have implemented DFT from Vision & Graphics Group at the Faculty of Informatics and Information Technologies STU - Frequency domain filtration.

  1. Tried taking dft for the three Channels(R, G and B) and reconstructed the original image by taking inverse dft for all three channels and merged them together, but the image reconstructed doesnot have the same contrast as the original image.

But while altering the flags used in the link as such

  dft(input, Complex, DFT_SCALE);
  dft(Complex, InverseDFTImage, DFT_INVERSE + DFT_REALOUTPUT);
  InverseDFTImage.converTo(InverseDFTImage, CV_8U);

The output is same as the input, but while applying Gaussian filter, there are few colour differences near the edges.

1. Original Input Image
Original Input image

2. Output without any filters(followed the Procedure in the link)
Output without any filters(followed the Procedure in the link)

3. After applying Gaussian Low Pass Filter
After applying Gaussian Low Pass Filter

Can someone clarify this doubt.?
P.S Thanks in advance

$\endgroup$
7
  • $\begingroup$ Are you using MATLAB? $\endgroup$
    – Royi
    Feb 26, 2015 at 9:24
  • $\begingroup$ @Drazick: No I'm using OpenCV $\endgroup$ Feb 26, 2015 at 10:20
  • 1
    $\begingroup$ Then sorry, I don't understand their implementation of DFT. Usually, doing DFT and then IDFT result with the same vector / matirx up to numerical inaccuracies. $\endgroup$
    – Royi
    Feb 26, 2015 at 10:21
  • $\begingroup$ to add to what @Royi said, i doubt that (even with single-precision IEEE float for the RGB bitmaps) the quantization error would add up through the FFT passes to become particularly visible. them's are 24 honest mantissa bits. and if the bitmaps have 64-bit double instead of float, then forget it. the quantization noise floor is so many dB down that it will never build up to anything of consequence in the FFT and inverse FFT. $\endgroup$ Dec 8, 2016 at 23:37
  • $\begingroup$ and as best as i can tell, by looking, the otherwise unprocessed FFT/iFFT output image appears a little bluer. in the white images, lighthouse, buildings, fence, there seems to be less yellow light. the original appears brighter. it might be just a little darker, but it seems to me that the B bitmap got a slight boost or the R and G bitmaps got reduced by a very tiny amount(s). $\endgroup$ Dec 8, 2016 at 23:47

1 Answer 1

2
$\begingroup$

I saw same issue, and I found the answer in stackoverflow - DFT to spatial domain in OpenCV is not working.
for short, you can set imaginary part of filtering kernel zeros before you call mulSpectrums.

Mat planes[] = {Mat::zeros(dftImage1.size(), CV_32F), Mat::zeros(dftImage1.size(), CV_32F)};   
Mat kernel_spec;   
planes[0] = your_filter; // real     
// planes[1] = your_filter; 
// imaginar should be zero! Don't touch it.   
merge(planes, 2, kernel_spec);     
mulSpectrums(...  

Hope this helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.