DFT to spatial domain in OpenCV is not working

前端 未结 1 1152
长情又很酷
长情又很酷 2021-02-10 15:25

I have created dft of an image and after some adjustment with filters i want to convert it back to the real image but every time when i do that it gives me wrong result ..seems

相关标签:
1条回答
  • 2021-02-10 15:48

    I see a few problems going on here.

    First, you need to use the mulSpectrums function to convolve two FFTs, and not multiply.

    Second, the createGaussianHighPassFilter is only outputting a single channel non-complex filter. You'll probably need to just set the complex channel to Mat::zeros like you did for your input image.

    Third, don't convert the output of the FFT to log-magnitude spectrum. It will not combine correctly with the filter, and you won't get the same thing when performing the inverse. So, just return complexImg right after the DFT is executed. Log-magnitude spectrum is useful for a human to look at the data, but not for what you are trying to do.

    Finally, make sure you pay attention to the difference to between the full-complex output of dft and the Complex Conjugate Symmetric (CCS) packed output. Intel has a good page on how this data is formatted here. In your case, for simplicity I would keep everything in full-complex mode to make your life easier.

    Hope that helps!

    0 讨论(0)
提交回复
热议问题