int i, x, y, val;           

    complex_num *data;     /* 1차원 FFT를 위한 데이터 배열 */ 

    int log2N;             /* FFT 단계수 */ 

    int num;           

   unsigned char **tmpImg; 

    /* 영상의 폭에 대한 log2N을 계산 */ 

    num = imageWidth; 

    log2N = 0; 

    while(num >= 2) 

   { 

       num >>= 1; 

       log2N++; 

   } 


    /* 1차원 FFT를 위한 기억장소 할당 */ 

    * malloc(sizeof(complex_num)*imageWidth); 

   // FFT 변환 결과를 저장하기 위한 기억 장소 할당 

   fft_result = (complex_num **) malloc(sizeof(complex_num *) * imageHeight); 

   for (i = 0; i < imageHeight; i++) 

       fft_result[i] = (complex_num *) malloc(sizeof(complex_num) * imageWidth); 

   // 임시 기억 장소 할당 

   tmpImg = (unsigned char **) malloc(sizeof (unsigned char *) * imageHeight); 

   for (i = 0; i < imageHeight; i++) 

       tmpImg[i] = (unsigned char *) malloc(imageWidth); 


   for(y=0; y<imageHeight; y++)              // 영상의 각 행에 대하여 FFT 수행 

   { 

       for(x=0; x<imageWidth; x++)           // 한 행을 data 배열에 복사 

       { 

               data[x].re = inputImg[y][x];  // 실수부는 영상의 픽셀 값으로 설정 

               data[x].im = 0;               // 허수부 값을 0으로 설정  

       } 

        

       FFT_1D(data, imageWidth, log2N);      // 1차원 FFT 수행 

        

       for(x=0; x<imageWidth; x++)           // 결과 저장 

       { 

               fft_result[y][x].re = data[x].re; 

               fft_result[y][x].im = data[x].im; 

       } 

   } 


      // 영상의 높이에 대한 log2N 계산 

   num = imageHeight; 

    log2N = 0; 

    while(num >= 2) 

   { 

       num >>= 1; 

       log2N++; 

   } 

   // 기억장소 할당 

   free(data); 

    *) malloc(sizeof(complex_num)*imageHeight); 


       for(x=0; x<imageWidth; x++) 

   { 

       for(y=0; y<imageHeight; y++)       // 행에 대한 FFT 결과의 한 열을 복사 

       { 

           data[y].re = fft_result[y][x].re; 

           data[y].im = fft_result[y][x].im; 

       } 

        

       FFT_1D(data, imageHeight, log2N);        // 1차원 FFT 수행 

       for(y=0; y<imageHeight; y++)             // 결과 저장 

       { 

           fft_result[y][x].re = data[y].re; 

           fft_result[y][x].im = data[y].im; 

       } 

   } 


      // FFT 결과값을 영상으로 보여주기 위해 변환 

        for (y = 0; y < imageHeight; y++) 

           for (x = 0; x < imageWidth; x++) { 

               val = 20 * (int) log (fabs(sqrt(fft_result[y][x].re*fft_result[y][x].re+ 

                                      fft_result[y][x].im*fft_result[y][x].im))); 

               if (val > 255) val = 255; 

               if (val < 0) val = 0; 

               resultImg[y][x] = (unsigned char ) val; 

           } 


      // FFT 결과 이미지의 중심점을 기준으로 이미지를 4등분하고 

   // 각 사분면의 내용을 상하 대칭 및 좌우 대칭시킴     

   for(i = 0; i < imageHeight; i += imageHeight / 2){ 

       for(int j = 0; j < imageWidth; j += imageWidth / 2){ 

           for(int row = 0; row < imageHeight / 2; row++){ 

               for(int col = 0; col < imageWidth / 2; col++){ 

                   tmpImg[(imageHeight/2-1)-row+i][(imageWidth/2-1)-col+j] = 

                       resultImg[i+row][j+col]; 

               } 

           } 

       } 

   } 

   for (y = 0; y < imageHeight; y++) 

       for (x = 0; x < imageWidth; x++) 

           resultImg[y][x] = tmpImg[y][x]; 



이게 지금 FFT 변환식인데 이것을 DFT로 바꿔야하는데 어떻게 바꾸는지 알려줘