Consider a image of size 1920x1080. How to do cufft R2C and C2R for 720x960 ROI?
How to perform cufft fwd and inv transform for a specific region of interest(ROI) in a bigger array?
1 Answers
As pointed out in comments, CUfft has full support for performing transforms and inverse transforms on a subset of data within arrays, via the advanced data layout features of the API. Quoting from the documentation:
Advanced layout can be perceived as an additional layer of abstraction above the access to input/output data arrays. An element of coordinates [z][y][x] in signal number b in the batch will be associated with the following addresses in the memory:
1D
input[ b * idist + x * istride] output[ b * odist + x * ostride]
2D
input[b * idist + (x * inembed[1] + y) * istride] output[b * odist + (x * onembed[1] + y) * ostride]
3D
input[b * idist + ((x * inembed[1] + y) * inembed[2] + z) * istride] output[b * odist + ((x * onembed[1] + y) * onembed[2] + z) * ostride]
The istride and ostride parameters denote the distance between two successive input and output elements in the least significant (that is, the innermost) dimension respectively. In a single 1D transform, if every input element is to be used in the transform,
istride
should be set to 1 ; if every other input element is to be used in the transform, then istride should be set to 2 . Similarly, in a single 1D transform, if it is desired to output final elements one after another compactly,ostride
should be set to 1 ; if spacing is desired between the least significant dimension output data,ostride
should be set to the distance between the elements.
You can find an example of working with advanced data layouts in cuFFT in this Stack Overflow question

- 70,661
- 34
- 192
- 269