Inverse Fast Fourier Transform 2D

The Inverse Fast Fourier Transform 2D (hereinafter referred to as IFFT2D) is a fast algorithm derived from the Inverse Fast Fourier Transform (hereinafter referred to as IFFT). It efficiently converts two-dimensional data from the frequency domain to the time domain, commonly employed for the restoration of images and other two-dimensional frequency domain data to their original time domain representation.

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

IFFT2D is an extension of the IFFT algorithm, designed to map frequency domain data to time domain data. It operates on two-dimensional data by performing IFFT operations separately along the y and x directions. The specific procedure is outlined as follows:

  1. Perform IFFT 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.
HPL5IFFT2D_y
  1. Building upon the processing in step 1, perform IFFT 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.
HPL5IFFT2D_x
  1. Return the calculation results from step 2.

API Interface

int32_t hbIFFT2D(hbUCPTaskHandle_t *taskHandle, hbHPLImaginaryData *dst,
                 hbHPLImaginaryData const *src, hbIFFT2DParam const *param);

For detailed interface information, please refer to hbIFFT2D

Usage

// Include the header
#include "hobot/hb_ucp.h"
#include "hobot/hpl/hb_hpl.h"
#include "hobot/hpl/hb_ifft_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
hbIFFT2DParam param;
param.nx = HB_FFT_POINT_SIZE_16;
param.ny = HB_FFT_POINT_SIZE_32;
param.normalize = 0;

// init task handle and schedule param
hbUCPTaskHandle_t task_handle{nullptr};
hbUCPSchedParam sched_param{...};

// create task
hbIFFT2D(&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);