Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::convolution Namespace Reference

Helper functions for 1D convolution via VNL Fourier transformation. More...

Functions

itk::Array< double > wrap1d (itk::Array< double > kernel)
 Wraps (circularly shifts) a 1D convolution kernel. More...
 
itk::Array< double > zeropadding1d (itk::Array< double > unpaddedSpectrum, int paddedDimension)
 Zero-pads a 1D array to a specified size. More...
 
itk::Array< double > unpadAndScale (itk::Array< double > convolutionResult, int initialDimension)
 Removes padding and scales the result after inverse FFT. More...
 
void prepareConvolution (const itk::Array< double > &kernel, const itk::Array< double > &spectrum, itk::Array< double > &preparedKernel, itk::Array< double > &preparedSpectrum)
 Prepares two arrays for FFT-based convolution. More...
 

Detailed Description

Helper functions for 1D convolution via VNL Fourier transformation.

This namespace provides utility functions for preparing arrays for convolution using vnl_fft_1d, including kernel wrapping (circular shift) and zero-padding to avoid boundary artefacts.

See also
convoluteAIFWithExponential, convoluteAIFWithConstant

Function Documentation

◆ prepareConvolution()

void mitk::convolution::prepareConvolution ( const itk::Array< double > &  kernel,
const itk::Array< double > &  spectrum,
itk::Array< double > &  preparedKernel,
itk::Array< double > &  preparedSpectrum 
)
inline

Prepares two arrays for FFT-based convolution.

Zero-pads both the kernel and spectrum arrays to the sum of their sizes so they are ready for forward FFT transformation.

Parameters
[in]kernelThe convolution kernel array.
[in]spectrumThe signal array to be convolved.
[out]preparedKernelThe zero-padded kernel.
[out]preparedSpectrumThe zero-padded spectrum.

Definition at line 107 of file mitkConvolutionHelper.h.

References zeropadding1d().

◆ unpadAndScale()

itk::Array<double> mitk::convolution::unpadAndScale ( itk::Array< double >  convolutionResult,
int  initialDimension 
)
inline

Removes padding and scales the result after inverse FFT.

After the backward FFT transformation, this function extracts the valid portion of the result (removing padding) and divides by the transform size to correct the FFT scaling.

Parameters
[in]convolutionResultThe raw inverse-FFT output.
[in]initialDimensionThe original (unpadded) array size.
Returns
The unpadded and scaled convolution result.

Definition at line 84 of file mitkConvolutionHelper.h.

◆ wrap1d()

itk::Array<double> mitk::convolution::wrap1d ( itk::Array< double >  kernel)
inline

Wraps (circularly shifts) a 1D convolution kernel.

Performs a circular shift of the kernel by half its length, which is required for proper FFT-based convolution.

Parameters
[in]kernelThe input kernel array.
Returns
The wrapped kernel array.

Definition at line 36 of file mitkConvolutionHelper.h.

◆ zeropadding1d()

itk::Array<double> mitk::convolution::zeropadding1d ( itk::Array< double >  unpaddedSpectrum,
int  paddedDimension 
)
inline

Zero-pads a 1D array to a specified size.

Adds zeros symmetrically around the input array so it reaches the desired padded dimension. This prevents circular convolution artefacts in FFT-based convolution.

Parameters
[in]unpaddedSpectrumThe input array to be padded.
[in]paddedDimensionThe target size after padding (sum of both convolution operand sizes).
Returns
The zero-padded array.

Definition at line 56 of file mitkConvolutionHelper.h.

Referenced by prepareConvolution().