IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20566


Ignore:
Timestamp:
Nov 6, 2008, 1:36:20 PM (18 years ago)
Author:
Paul Price
Message:

When convolving using an FFT, make the size of images that are FFT-ed
an integer power of two. This has a strong positive effect on the
speed.

File:
1 edited

Legend:

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

    r19058 r20566  
    66/// @author Robert DeSonia, MHPCC
    77///
    8 /// @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    9 /// @date $Date: 2008-08-14 03:23:13 $
     8/// @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     9/// @date $Date: 2008-11-06 23:36:20 $
    1010///
    1111/// Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2020#include <complex.h>
    2121#include <fftw3.h>
     22#include <limits.h>
    2223#include <pthread.h>
    2324
     
    3233#include "psFFT.h"
    3334#include "psImageFFT.h"
     35
     36#define FFT_CONVOLVE_BINARY_SIZE 1               // Scale up to next binary size
    3437
    3538// Lock FFTW access
     
    340343        return NULL;
    341344    }
     345
    342346    int paddedCols = numCols + PS_MAX(-xMin, xMax); // Number of columns in padded image
    343347    int paddedRows = numRows + PS_MAX(-yMin, yMax); // Number of rows in padded image
     348
     349#if CONVOLVE_FFT_BINARY_SIZE
     350    // Make the size an integer power of two
     351    {
     352        int twoCols, twoRows;           // Size that is a factor of two
     353        for (twoCols = 1; twoCols <= paddedCols && twoCols < INT_MAX - 1; twoCols <<= 1); // No action
     354        for (twoRows = 1; twoRows <= paddedRows && twoRows < INT_MAX - 1; twoRows <<= 1); // No action
     355        if (paddedCols > twoCols || paddedRows > twoRows) {
     356            psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Unable to scale size (%dx%d) up to factor of two",
     357                    paddedCols, paddedRows);
     358            return NULL;
     359        }
     360        paddedCols = twoCols;
     361        paddedRows = twoRows;
     362    }
     363#endif
     364
    344365    int numPadded = paddedCols * paddedRows; // Number of pixels in padded image
    345366
Note: See TracChangeset for help on using the changeset viewer.