XMM-Newton SAS Home Page
XMM-Newton Science Analysis System


asmooth (asmooth-2.32) [xmmsas_20211130_0941-20.0.0]


Convolution details

A cyclic convolution of an input image $I_{x,y}$ weighted by $w_{x,y}$ gives output $O_{x,y}$ according to the following prescription:

  $\displaystyle
O_{x,y} = C \ \frac{\sum_{i=L}^{M} \sum_{j=P}^{Q} c_{i,j} \ w_{x-i,y-j} \ I_{x-i,y-j}} {\sum_{i=L}^{M} \sum_{j=P}^{Q} c_{i,j} \ w_{x-i,y-j}},
$ (1)

where $c_{x,y}$ is the convolver and

$\displaystyle C = \sum_{x=L}^{M} \sum_{y=P}^{Q} c_{x,y}.
$

The indices $x-i$ and $y-j$ are calculated modulo the image sizes $X$ and $Y$ respectively, that is, they wrap around the image limits. This cyclic property is unavoidable if it is desired to make efficient use of the Fourier transform in performing the convolution. Potentially this is a nuisance because it means, for example, that values at the left-hand edge of the image can become mixed with values on the right-hand edge, and so forth. The task avoids this by padding the image with zero-valued pixels in both $x$ and $y$ directions. The pad size is equal to the width of the convolver in that direction. If there are multiple convolvers (see sections 3.3.4, 3.3.5 and 3.3.6), the largest convolver sizes are used.

In fact the `blank space' areas around the edges of the image are handled in three steps, as below.

  1. If a smaller rectangle can be excised from the input image such that all the pixels of the excess are zero-valued, this is done.

  2. The pad described above is added.

  3. The Fast Fourier Transform (FFT) algorithm used by the task works most efficiently if each dimension of the image is a multiple of 2, 3, 5 or 7. For each dimension of the working image, asmooth calculates the next largest integer which obeys this condition and adds further blank space to increase the dimension to that value.

After the convolution is done, before the output is written to file, the process is reversed: the pad is first cut away, then the original amount of blank space is restored.

The convolution may be done either directly or via FFT. If left to itself, the task will try to use the method which is quickest. If the image is large and the number of convolvers small, this will generally be the FFT method; however direct convolution becomes more efficient if the image is divided into many small patches of different convolution. If the user desires the convolutions to be unilaterally performed using one method or another, they should make use of the forcecalctype and calcbyfft parameters.

The two methods produce identical outputs except for small differences caused by different propagation of rounding errors. However the FFT method will, because it always acts on the whole image, in general leave few if any pixels in the output which are exactly equal to zero. Use of a mask (section 3.4) or an exposure map (section 3.5) can be helpful in this instance.

XMM-Newton SOC -- 2021-11-30