# Sinc Based Multi Dimension Signal Resampling on the Fourier Spectrum (DFT)

As a generalization of the following questions:

I would like to know how to handle the n dimensional general case both for Upsampling and Downsampling.
The above questions deals with 1D and 2D and I wonder how to handle the general nD case.
The answer should be practical, namely emphasize implementation considerations.

• the same; the thing you want is inherently a separable kernel, so you can fist 1-D interpolate in one, then in the other dimension. Feb 20, 2022 at 19:29
• @MarcusMüller, It's a bit trickier in high dimensions. As the slice is N - 1 which requires a delicate handling.
– Royi
Feb 28, 2022 at 17:45
• @Royi interesting! Reading up on this :) Feb 28, 2022 at 20:05

The general $$n$$ dimension case can be solved with the following loop:

for dimIdx in 1:ndims(tX)
tXDft = fft(tX, dimIdx);
tXDft = FixSlice(tXDft, dimIdx)
tX    = ifft(tXDft, dimIdx);
end


The tricky parts are handling the cropping (Downsampling) or padding (Upsampling) for the $$n - 1$$ dimensions slice.

One way to solve it is to recursively work on smaller dimensions slices until we get to 1D / 2D slice which is solved in the questions you linked to.

Another way is to define a slice indexing.
Assume the array has indices of: (1:5, 1:10, 1:15, 1:20) then the the $$i$$ -th slice in the $$d$$ -th dimensions has the indices, for i = 4 and d = 2 (1:5, 4, 1:15, 1:20).

Those slices are the elements we can treat as scalars in the 1D case. Namely split them or add them in order to compensate for Upsampling / Downsampling.

So basically we do, 1D DFT, then we apply cropping / padding according to need at the dimension in work, then we extract the slices at the bin which needs to be fixed and add them / split them then Inverse DFT.

• Please elaborate on the implementation.
– Mark
Feb 28, 2022 at 17:33