Fftw c2c: lack of symmetry in converted real data

I recently ran into some issues related to using the fftw and c2c conversion (see 3d c2c fft with the fftw library ). Since I discovered my problems with using fftw lib, I created a new Question to discuss this situation in more detail. Since I am doing a complex complex transformation with real data, my converted data in Fourier space must be symmetric: F [n] = con (F [Nn])

Now I have done some conversions with small blocks of test data to check the converted data for this symmetry. For 1D conversion, each operation worked as expected, but for higher measurements, I got real unexpected results.

I use fftwf_plan_dft_2dto convert an 8x8 grayscale image to Fourier space, and a complex result is given:

n 
0 real 7971 imag 0 
1 real -437.279 imag -802.151 
2 real -289 imag -566 
3 real -182.721 imag 15.8486 
4 real 31 imag 0 
5 real -182.721 imag -15.8486 
6 real -289 imag 566 
7 real -437.279 imag 802.151 
8 real -1499.79 imag -315.233 
9 real 182.693 imag -74.5563 
10 real 55.9239 imag -12.8234 
11 real -84.7868 imag -9.10052 
12 real -14.4264 imag 211.208 
13 real 289.698 imag 214.723 
14 real 452.659 imag -246.279 
15 real 1136.35 imag -763.85 
16 real 409 imag -134 
17 real -141.865 imag 42.6396 
18 real -33 imag 122 
19 real 129.075 imag -49.7868 
20 real 1 imag -150 
21 real 109.865 imag -84.6396 
22 real 95 imag -142 
23 real -841.075 imag -92.2132 
24 real -108.207 imag -89.2325 
25 real -127.213 imag 28.8995 
26 real -36.6589 imag -8.27922 
27 real -74.6934 imag 43.4437 
28 real 70.4264 imag 29.2082 
29 real -88.3545 imag -81.8499 
30 real -127.924 imag -190.823 
31 real 230.302 imag 8.7229 
32 real -53 imag 0 
33 real -73.1127 imag -22.8578 
34 real -85 imag -82 
35 real -10.8873 imag 51.1421 
36 real -65 imag 0 
37 real -10.8873 imag -51.1421 
38 real -85 imag 82 
39 real -73.1127 imag 22.8578 
40 real -108.207 imag 89.2325 
41 real 230.302 imag -8.7229 
42 real -127.924 imag 190.823 
43 real -88.3545 imag 81.8499 
44 real 70.4264 imag -29.2082 
45 real -74.6934 imag -43.4437 
46 real -36.6589 imag 8.27922 
47 real -127.213 imag -28.8995 
48 real 409 imag 134 
49 real -841.075 imag 92.2132 
50 real 95 imag 142 
51 real 109.865 imag 84.6396 
52 real 1 imag 150 
53 real 129.075 imag 49.7868 
54 real -33 imag -122 
55 real -141.865 imag -42.6396 
56 real -1499.79 imag 315.233 
57 real 1136.35 imag 763.85 
58 real 452.659 imag 246.279 
59 real 289.698 imag -214.723 
60 real -14.4264 imag -211.208 
61 real -84.7868 imag 9.10052 
62 real 55.9239 imag 12.8234 
63 real 182.693 imag 74.5563

Sorry for this long list of data, but this shows my problem.

For example, for F[3]=-182.721 + 15.8486iI expected F[64-3] = F[61] = -182.721 - 15.8486i, but, as you see, this -84.7868 + 9.10052i. Instead, the conjugate F[3]is at index 5. The same for other couples.

If there is a system, I cannot find it.

Here is the complete code:

QImage image("/Users/wolle/Desktop/wolf.png");
int w = image.width();
int h = image.height();
int size  = w * h;

cl_float *rawImage = imageToRaw(image); // converts a QImage into an rgb array [0..255]

fftwf_complex *complexImage = (fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex) * size);
fftwf_complex *freqBuffer = (fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex) * size);

// real data to complex data
for (int i = 0; i < size; i++)
{
    complexImage[i][0] = (float)rawImage[i];
    complexImage[i][1] = 0.0f;
}

fftwf_plan forward = fftwf_plan_dft_2d(w, h, complexImage, freqBuffer, FFTW_FORWARD, FFTW_ESTIMATE);

fftwf_execute(forward);

for (int y = 0; y < h; y++)
{
    for (int x = 0; x < w; x++)
    {
        int gid = y * w + x;
        qDebug() << gid  << "real" << freqBuffer[gid][0] << "imag" << freqBuffer[gid][1];
    }
}

I would be grateful for the help.: - D

Hi

Wolf

+3
source share
1 answer

, x FFT (x) -. . , (x, y) 16 * x + y (16-x, 16-y) 16 * (16-x mod 16) + (16-y mod 16), , y 0, 272-16 * xy mod 256.

, , 16x16, 8x8. , (x, y) 8 * x + y (8-x, 8-y) 8 * (8-x mod 8) + (8-y mod 8).

, , x = 0, y 8-y - , , 3 5, .

( x = 0 y = 0, , "8-y mod 8" , 0.)

+3

All Articles