0

I inherited an image processing application. Trying to figure things out here. I have three questions. 1) Do I have the sequence correct F2C, C2C, C2F? 2) Should I run C2C in one direction once? 3) Which direction should I use (forward or backward)?

Background:

The input and output is a 2D image.

First a R2C is done using cufftF2C (cuda off the shelf) Then a C2C is done. This was hand coded by original developer. Finally C2R is done using cufftC2F (cuda off the shelf)

The result is a great picture only unsightly zig-zag lines appear. The original developer used 1D plans (nx = x and batch = y). I want to replace these with 2D plans (nx = x and ny = y). I also want to replace the home grown C2C with the cuda off the shelf cufftC2C.

JackT
  • 57
  • 7
  • 3
    There is no F2C or C2F in [CUFFT](http://docs.nvidia.com/cuda/cufft/index.html#abstract). Perhaps you mean R2C and C2R. A really good answer here would (IMO) require a really long answer, mostly a tutorial on the Fourier Transform. It strikes me as a pretty broad question. It's not clear what knowledge if any you have of fourier transforms, what they do, and how they are used (which is a topic that is entirely independent of CUDA). – Robert Crovella May 26 '16 at 22:15

1 Answers1

1

1) Do I have the sequence correct [R2C], C2C, [C2R]? No, there are two domains in Fourier transform: space and frequency. A transform goes from space to frequency with CUFFT_FORWARD and frequency to space with CUFFT_INVERSE.

2) Should I run C2C in one direction once ? Depending on the usage of Hermitian symmetry you dont necessarily need C2C(see below).

3) Which direction should I use (forward or backward)? If you want to apply an image processing filter, your output is most likely in the same space as your input, hence you have to apply as one forward transformation and one inverse transformation.

Notes on data layout and R2C / C2R optimizations

When using C2R or R2C transforms, cufft is making use of the Hermitian symmetry of the frequency-space vector, hence solely storing the first half of the vector (the remaining part is not even touched):

Apart from the general complex-to-complex (C2C) transform, cuFFT implements efficiently two other types: real-to-complex (R2C) and complex-to-real (C2R). In many practical applications the input vector is real-valued. It can be easily shown that in this case the output satisfies Hermitian symmetry ( X k = X N − k ∗ , where the star denotes complex conjugation). The converse is also true: for complex-Hermitian input the inverse transform will be purely real-valued. cuFFT takes advantage of this redundancy and works only on the first half of the Hermitian vector.

If the operation you are performing in frequency domain does not have the same Hermitian symmetry, the optimization is not true anymore, and the C2R operation would not provide you the the expected result.

Also note the data requirements and layout of the approach which is a bit different than the one for C2C.

Florent DUGUET
  • 2,786
  • 16
  • 28