本文介绍了使用一维变换实现二维逆傅里叶变换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在python中实现一些将图像转换为傅里叶域的函数,反之亦然,用于图像处理任务。

我使用重复的1D-DFT实现了2D-DFT,它工作正常很好,但当我尝试使用重复的逆1D-DFT实现2D逆DFT时,出现了一些奇怪的问题 - 当我将图像转换为其傅里叶域然后再回到图像域时,看起来图像被反射并与之合并它的反思,如下所示:

I am trying to implement in python some functions that transform images to their fourier domain and vice-versa for image processing tasks.
I implemented the 2D-DFT using repeated 1D-DFT, and it worked fine, but when I tried to Implement 2D inverse DFT using repeated inverse 1D-DFT, some weird problem occurred - When I transform an image to its fourier domain and then back to the image domain, it looks like the image was reflected and merged with its reflection, as can be seen here:

这是输入:

这是输出

这是负责混乱的函数:

def IDFT2(fourier_image):
    image = np.zeros(fourier_image.shape)
    for col in range(image.shape[1]):
        image[:, col] = IDFT1(fourier_image[:, col])

    for row in range(image.shape[0]):
        image[row, :] = IDFT1(image[row,:])

    return image

我做错了什么?我很确定IDFT1工作正常,常规2D-DFT也是如此。

What did I do wrong? I am pretty sure that IDFT1 works fine, and so is the regular 2D-DFT.

推荐答案

我不使用 Python 所以我没有信心分析你的代码,但我的赌注是你很可能忘记在某个阶段实现复杂的价值....

I do not use Python so I am not confident to analyze your code but my bet is that you most likely forget to implement complex values at some stage....

it应该是:


  1. DFT 从真实域到复杂域的行

  2. DFT 从复杂域到复杂域的结果列

  3. 在需要时应用规范化

  4. 任何或无处理......

  5. iDFT 从复杂域到复杂域的行

  6. iDFT 从复杂到真实的结果列域

  7. 如果需要,应用规范化

  1. DFT rows from real to complex domain
  2. DFT columns of result from complex to complex domain
  3. apply normalization if needed
  4. any or none processing ...
  5. iDFT rows from complex to complex domain
  6. iDFT columns of result from complex to real domain
  7. apply normalization if needed

如果你只使用真实的复杂域第二次传递中的DFT / iDFT (子弹#2,#6 )然后它会创建镜像,因为 DFT 的实际值是一个镜像序列...顺便说一句。首先处理行或列并不重要...也可以先在 DFT 中处理行,然后在 iDFT 中先处理列,结果应该相同+/-浮动错误...

if you use just real to complex domain DFT/iDFT in the second passes (bullets #2,#6) then it would create the mirroring because DFT of real values is a mirrored sequence ... Btw. it does not matter if you process rows or columns first ... also you can process rows first in DFT and columns first in iDFT the result should be the same +/- floating errors ...

了解更多信息,请参阅



  • How to compute Discrete Fourier Transform?

以及所有子链接,特别是 2D FFT和包装示例,这样您就可以将结果与工作中的结果进行比较

and all the sub-links there especially the 2D FFT and wrapping example so you can compare your results with something working

这篇关于使用一维变换实现二维逆傅里叶变换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 06:32