This class holds data and functions relating to FFT-based convolution of a point-spread-function (PSF) image with an input image (e.g., the model image computed by ModelObject).

An instance of this class is set up and used by main’s ModelObject instance to handle standard PSF convolution of the whole model image. In addition, if there are any oversampled regions, then each OversampledRegion instance will have its own Convolver instance to handle convolution with the appropriate (oversampled) PSF image.

Setup and Use

To set up a Convolver object, you first call its SetupPSF method and pass in the PSF image data, size, and whether the PSF should be normalized. Then you call the SetupImage method to tell the Convolver object about the size of the image that will be convolved with the PSF, and finally you call the DoFullSetup to tell the Convolver object to do the necessary allocations and FFT setup.

To use the Convolver object, you simply call its ConvolveImage method with the image array as input; the input image will be updated in place.

(In Imfit, this is all done within the ModelObject class.)


Files: core/convolver.h, core/convolver.cpp

class Convolver

Class for handling PSF convolution (stores PSF, performs convolutions with input model images)

Public Functions


Constructor for Convolver class.


Destructor for Convolver class.

void SetMaxThreads(int maximumThreadNumber)

Set maximum number of FFTW threads.

User specifies maximum number of FFTW threads to use (ignored if not compiled with multithreaded FFTW library)

void SetupPSF(double *psfPixels_input, int nColumns, int nRows, bool normalize = true)

Supply PSF image to Convolver object.

Pass in a pointer to the pixel vector for the input PSF image, as well as the image dimensions and whether PSF needs to be normalized.

void SetupImage(int nColumns, int nRows)

Pass in the dimensions of the image we’ll be convolving with the PSF.

int DoFullSetup(int debugLevel = 0, bool doFFTWMeasure = false)

Do final setup work (allocate things, generate FT of PSF image, etc.)

General setup prior to actually supplying the image data and doing the convolution: determine padding dimensions; allocate FFTW arrays and plans; normalize, shift, and Fourier transform the PSF image.

void ConvolveImage(double *pixelVector)

Replace input model image (pixelVector) with convolution using stored PSF.

Given an input image (pointer to its pixel vector), convolve it with the PSF by: 1) Copying image to image_in_padded array (with zero-padding); 2) Taking FFT of image; 3) Multiplying transform of image by transform of PSF; 4) Taking inverse FFT of product; 5) Copying (and rescaling) result back into input image.

Private Functions

void ShiftAndWrapPSF()

Takes the input PSF (assumed to be centered in the central pixel of the image) and copy it into the (padded) image, with the PSF wrapped into the corners, suitable for convolutions.