IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 14, 2005, 2:12:09 PM (21 years ago)
Author:
desonia
Message:

fixed image FFT and image convolution. The FFTW call had the wrong order
of dimensions, and the scaling was incorrect.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImageFFT.c

    r3671 r3702  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-04-06 01:12:58 $
     7 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-04-15 00:12:08 $
    99 *
    1010 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7474    // n.b. FFTW can perform a in-place transform at the same rate or faster than out-of-place.
    7575    psS32 sign = ((direction & PS_FFT_FORWARD) != 0) ? FFTW_FORWARD : FFTW_BACKWARD;
    76     out = psImageCopy(out, in, PS_TYPE_C32);
    77     plan = fftwf_plan_dft_2d(numCols, numRows,
    78                              out->data.C32[0],
    79                              out->data.C32[0],
     76
     77    fftwf_complex* outBuffer = fftwf_malloc(numRows*numCols*sizeof(fftwf_complex));
     78    p_psImageCopyToRawBuffer(outBuffer, in, PS_TYPE_C32);
     79
     80    plan = fftwf_plan_dft_2d(numRows, numCols,
     81                             outBuffer,
     82                             outBuffer,
    8083                             sign,
    8184                             PS_FFTW_PLAN_RIGOR);
     
    101104        // becomes an issue, the use of fftwf_plan_dft_r2c should be considered
    102105        // as well as fftwf_plan_dft_c2r.
    103         psImage* realOut = psImageCopy(NULL,out,PS_TYPE_F32);
    104         psFree(out);
    105         out = realOut;
    106     }
     106        out = psImageRecycle(out,numCols,numRows,PS_TYPE_F32);
     107        int index = 0;
     108        for (int row=0; row < numRows; row++) {
     109            psF32* outRow = out->data.F32[row];
     110            for (int col=0; col < numCols; col++) {
     111                outRow[col] = crealf(outBuffer[index++]); // take just the real part
     112            }
     113        }
     114    } else {
     115        out = psImageRecycle(out,numCols,numRows,PS_TYPE_C32);
     116        int index = 0;
     117        for (int row=0; row < numRows; row++) {
     118            psC32* outRow = out->data.C32[row];
     119            for (int col=0; col < numCols; col++) {
     120                outRow[col] = outBuffer[index++]; // take just the real part
     121            }
     122        }
     123        //        memcpy(out->rawDataBuffer, outBuffer, numRows*numCols*sizeof(fftwf_complex));
     124    }
     125
     126    fftwf_free(outBuffer);
    107127
    108128    return out;
Note: See TracChangeset for help on using the changeset viewer.