简体   繁体   English

如何为快速傅立叶变换(fft,swift)从图像数据创建复数?

[英]How I should create complex number from image data for Fast Fourier Transform (fft, swift)?

I have array of grayscale for example [0.0, 0.0, 0.0, 255.0, 255.0, 255.0, 130.0, 130.0, 130.0] 3x3 dimension, I need create array of complex numbers for fft function. 我有一个灰度数组,例如[0.0, 0.0, 0.0, 255.0, 255.0, 255.0, 130.0, 130.0, 130.0] 3x3尺寸,我需要为fft函数创建一个复数数组。 How I should convert this array? 我应该如何转换此数组? Im using swift 4 and it is for iOS, but I think its no matter. 我使用的是Swift 4,它适用于iOS,但是我认为这无关紧要。 And also using Accelerate framework from Apple 并且还使用Apple的Accelerate框架

so have 3 questions 所以有3个问题

  1. How I should convert this array? 我应该如何转换此数组?
  2. Is there any common theory how do it? 有什么共同的理论怎么做?
  3. How should I do it for RGB when working with channels? 使用通道时应如何针对RGB进行处理?

Fill real part of complex array with you data, and imaginary part - with zero (picture is pure real data). 用您的数据填充复杂数组的实部,然后用零填充虚部(图片是纯实数据)。

After FFT you'll have complex array (symmetrical because of pure real source). FFT之后,您将拥有复杂的数组(由于纯真实的源而对称)。 Both real and im. 真实和即时。 parts of result are important. 结果的一部分很重要。 For example, you can use both parts to calculate magnitude of spectrum, or to perform some treatment in frequency domain and make inverse FFT to get treated picture. 例如,您可以使用这两个部分来计算频谱的幅度,或者在频域中执行一些处理,然后进行逆FFT以获得处理后的图像。

What to do with RGB - depends on your needs. 如何处理RGB-取决于您的需求。 Sometimes one needs to perform FFT on every channel separately. 有时,需要分别在每个通道上执行FFT。 Sometimes one needs to work with brightness - in this case channels are joined using some law. 有时需要使用亮度-在这种情况下,使用某些法则将通道合并在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM