MCPcopy Create free account
hub / github.com/MITK/MITK / zeropadding1d

Function zeropadding1d

Modules/Pharmacokinetics/include/mitkConvolutionHelper.h:56–74  ·  view source on GitHub ↗

\brief 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. * \param[in] unpaddedSpectrum The input array to be padded. * \param[in] paddedDimension The target size after padding (sum of both convolution operand sizes

Source from the content-addressed store, hash-verified

54 * \param[in] paddedDimension The target size after padding (sum of both convolution operand sizes).
55 * \return The zero-padded array. */
56 inline itk::Array<double> zeropadding1d(itk::Array<double> unpaddedSpectrum, int paddedDimension)
57 {
58
59 int initialDimension = unpaddedSpectrum.GetNumberOfElements();
60
61 itk::Array<double> paddedSpectrum(paddedDimension);
62 paddedSpectrum.fill(0.);
63
64 if(paddedDimension > initialDimension)
65 {
66 unsigned int padding = paddedDimension - initialDimension;
67
68 for(int i=0; i<initialDimension ;++i)
69 {
70 paddedSpectrum.SetElement(i+padding/2, unpaddedSpectrum.GetElement(i));
71 }
72 }
73 return paddedSpectrum;
74 }
75
76 /** \brief Removes padding and scales the result after inverse FFT.
77 *

Callers 1

prepareConvolutionFunction · 0.85

Calls 2

GetNumberOfElementsMethod · 0.80
GetElementMethod · 0.45

Tested by

no test coverage detected