FFT 图像变换的输入和输出应该是什么? [英] What should be the input and output for an FFT image transformation?

查看:45
本文介绍了FFT 图像变换的输入和输出应该是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 Java 中的 FFT Cooley-Tukey 算法获取灰度图像的频谱.我不知道如何形成算法的输入以及使用输出中的哪些值来形成光谱图像.

目前我的输入是一个复数数组,其中 Re = 8 位灰度域中像素的值,Im = 0;运行算法后,我获得了另一个复数数组,其中实部有很多超出 [0,255] 范围的值,虚部为 0.我试图从实数数组模 256 创建一个图像.

这是光谱的外观:

这就是我所拥有的:

显然我做错了什么,但我不知道是什么.

解决方案

您没有提供源代码...

  1. 你的结果看起来像分辨率树

    用于递归分辨率/频率信息缩放和特征提取,而不是FFT!!!因此,可能是您的递归错误或重叠数据(就地编码 FFT 几乎是疯狂的),您应该从 1D 变换开始,然后将其用于 2D 并目视检查每个阶段(以及匹配原始数据的逆变换)

  2. 你的 FFT 输出应该有非零虚部!!!

    看这里

    I try to obtain the spectrum of an grayscale image using FFT Cooley–Tukey algorithm in Java. I don't know exactly how to form the input for the algorithm and what values from the output to use in order to form the spectrum image.

    Currently my input is an array of complex numbers, with Re = value of the pixel in 8bit grayscale domain and Im = 0; After running the algorithm I obtain another array of complex numbers with the real part having a lot of values out of [0,255] range and imaginary part 0. I have tried to create an image from the real numbers array modulo 256.

    This is how the spectrum should look:

    And this is what I've got:

    Obviously I'me doing something terrible wrong but I don't know what.

    解决方案

    You did not provide your source code ...

    1. your result looks like resolution tree

      used for recursive resolution/frequency information scaling and feature extraction not FFT !!! So may be your recursion is wrong or you overlap data (to code in-place FFT is almost insanity) you should start with 1D transform and then use that for 2D and visually check every stage (also the inverse transform to match original data)

    2. your FFT output should have non zero Imaginary part !!!

      look here How to compute Discrete Fourier Transform and into all sub-links in that answer of mine

    3. is your image resolution exact power of 2?

      if not zero pad it or the FFT would not work properly

    4. your example is wrong

      this is how it looks like in real:

      • left is input image (copied from your question)
      • middle is real part
      • right is imaginary part

      you can combine them to power spectrum =sqrt(Re*Re+Im*Im) the Re and Im image is amplified to be seen else just few white dots in the corners would be visible. Here some more examples:

      your expected result looks like shifted by half of the image resolution (so the center of symmetry is in center of image instead of in corners)

    [Edit1] power and wrap

    have added power and wrap functions to mine app so here is the result:

    first the power is computed so intensity=sqrt(Re^2+Im^2) and then wrap is done by shifting image by half size right and down. What is overlapping that comes from the other side back so just swap all points in all lines swap((x,y),(x+xs/2,y)) and then the same for all columns swap((x,y),(x,y+ys/2)). Now the result matches the one from OP the app is here

    这篇关于FFT 图像变换的输入和输出应该是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆