Fast Fourier Transform 2D

Fast Fourier Transform 2D (hereafter referred to FFT2D) is a fast algorithm based on fast Fourier transform (hereafter referred to FFT), which converts two-dimensional data from time domain to frequency domain. This algorithm can convert 2D data from time domain to frequency domain, and provide basic support for signal processing in frequency domain. It is usually used as the pre-step for frequency domain analysis of 2D data such as image.

Operator Effect

Time Domain Input DataParameterFrequency Domain Output Data
imagep_size = HB_HPL_FFT16
normalize = 0
dataType = HB_HPL_DATA_TYPE_I16
imFormat = HB_IM_FORMAT_SEPARATE
numDimensionSize = 2
image

Principle

FFT2D is an extension method developed based on the FFT algorithm. It conducts FFT processing separately on two-dimensional data along both the x and y axes, thereby mapping time-domain data to frequency-domain data. The specific procedure is as follows:

  1. Perform FFT calculation on each row of the two-dimensional data, where nx represents the number of FFT points set in the interface parameters for the x-axis.
HPL5FFT2D_x
  1. Building upon the processing in step 1, perform FFT calculation on each column of the two-dimensional data, where ny represents the number of FFT points set in the interface parameters for the y-axis.
HPL5FFT2D_y
  1. Return the results of the calculations from step 2.

API Interface

int32_t hbFFT2D(hbUCPTaskHandle_t *taskHandle, hbHPLImaginaryData *dst, hbHPLImaginaryData const *src, hbFFT2DParam const *param);

For detailed interface information, please refer to hbFFT2D

Usage

// Include the header #include "hobot/hb_ucp.h" #include "hobot/hpl/hb_hpl.h" #include "hobot/hpl/hb_fft_2d.h" // init, allocate memory for data src_length = 1024 * 1024 * 5; hbUCPMallocCached(&src_re_mem, src_length, 0); hbUCPMallocCached(&src_im_mem, src_length, 0); hbHPLImaginaryData src; src.realDataVirAddr = src_re_mem.virAddr; src.realDataPhyAddr = src_re_mem.phyAddr; src.imDataVirAddr = src_im_mem.virAddr; src.imDataPhyAddr = src_im_mem.phyAddr; src.numDimensionSize = 2; src.dataType = HB_HPL_DATA_TYPE_I16; src.imFormat = HB_IM_FORMAT_SEPARATE; src.dimensionSize[0] = 16 * 11; src.dimensionSize[1] = 32 * 2; hbUCPMallocCached(&dst_re_mem, src_length, 0); hbUCPMallocCached(&dst_im_mem, src_length, 0); hbHPLImaginaryData dst; dst.realDataVirAddr = dst_re_mem.virAddr; dst.realDataPhyAddr = dst_re_mem.phyAddr; dst.imDataVirAddr = dst_im_mem.virAddr; dst.imDataPhyAddr = dst_im_mem.phyAddr; dst.numDimensionSize = 2; dst.dataType = HB_HPL_DATA_TYPE_I16; dst.imFormat = HB_IM_FORMAT_SEPARATE; dst.dimensionSize[0] = 16 * 11; dst.dimensionSize[1] = 32 * 2; // init param hbFFT2DParam param; param.nx = HB_FFT_POINT_SIZE_16; param.ny = HB_FFT_POINT_SIZE_32; param.normalize = 0; // init task handle and schedule param hbUCPSchedParam sched_param; HB_UCP_INITIALIZE_SCHED_PARAM(&sched_param); sched_param.backend = HB_UCP_DSP_CORE_0; // create task hbFFT2D(&task_handle, &dst, &src, &param); // submit task hbUCPSubmitTask(task_handle, &sched_param); // wait for task done hbUCPWaitTaskDone(task_handle, 0); // release task handle hbUCPReleaseTask(task_handle); // release memory hbUCPFree(&src_re_mem); hbUCPFree(&src_im_mem); hbUCPFree(&dst_re_mem); hbUCPFree(&dst_im_mem);