I have an original image $\ I(x_i,y_j)$ where
$\ x_i = i*\Delta x, 0<= i < n_i $
$\ y_j = j*\Delta y, 0<= j < n_j$
I am trying to implement a function that resamples the image to:
$\ I(x_k,y_l)$ where
$\ x_k = k*\Delta xx, 0<= k < n_k $
$\ y_l = l*\Delta yy, 0<= l < n_l$
The case when $\ \Delta xx <= \Delta x $ and $\ \Delta yy <= \Delta y $ : upsampling, is quite easy (?).
Linear interpolation between nearest neighbours should do a decent job?
Downsampling on the other hand is more tricky.
To make sure Nyquist is followed so that no aliasing occurs; I must lowpass filter before decimating.
How do I do this an good yet simple manner?
I was thinking maybe using the FFT to do both upsampling and downsampling:
- take the FFT of the image
- zero pad or truncate the FFT
- inverse FFT
In the case of zero padding this amount to sinc interpolation (which is better than linear interpolation)?
In the case of truncation this amount to (ideal) lowpass filtering?
So this should be a both simple to implement and very good solution?
I guess one thing to look out for is edge effects.
How do I best avoid this?
I was thinking repeating the image twice in x and y and then circulary shifting it half the width and height of the image. That should make the padded image cyclical periodic.