File Exchange

image thumbnail

updownsample

version 1.0 (3.1 KB) by

up/down sample an input matrix using the fourier domain.

1 Download

Updated

View License

Up/down sample an image/matrix/vector (can be of complex numbers) using the frequency domain.
The matrix/vector should be continuous of a high degree (has continuous derivatives) in order to obtain a reasonable up/down sampling

Speed-up can be achieved if the user up-samples to a near power of 2. no optimization is done inside this code for efficient fft usage.

Documentation is found inside the *.m file.

type "updownsample" for the example

Comments and Ratings (11)

psucale

correction:
working good, forgot my sampling theory...
n = 5
ts = 1/5
tvec = (0:(n-1))*ts
zMat = hann(n)*hann(n).'
zMatUp = updownsample( abs(zMat), 50, 50, 0, 2)
nUp = 50
tsUp = 1/50
tvecUp = (0:(nUp-1))*tsUp
subplot(121)
imagesc(tvec,tvec,abs(zMat))
subplot(122)
imagesc(tvecUp,tvecUp,abs(zMatUp))

psucale

This code is "off by one" somewhere
If you run the following code you will see that the up sampled peak is in the wrong place.
I will figure this out and upload a fixed file.

zMat = hann(5)*hann(5).'
zMatUp = updownsample( abs(zMat), 50, 50, 0, 2)
subplot(121)
imagesc(abs(zMat))
subplot(122)
imagesc(abs(zMatUp))

@ David Felguera

Well, technically speaking the code is correct - in terms of what _exactly_ is it doing. The code claims to do downSAMPLING, which is just throwing away specified frequencies. Unlike the _decimation_, which uses the low-pass filtering to mitigate the downsampling effects (slower and more complicated).

The effect that you experiencing in this example is called ringing, and this exactly what happens in up/downsampling without filtering.

Aravind Kumar

The code works great ! Thanks.

Sumedh Joshi

Jong Rah

Jeroen Corthout

David Felguera

Problems with circular convolutions ...

Just try:

in_m = ones(10,10);
in_m = [zeros(10,10);in_m;zeros(10,10)];
in_m = [in_m,zeros(30,10)];
figure(100);
imagesc(in_m);
out_x_sz = 320;
out_y_sz = 320;
out_m = updownsample( in_m,out_x_sz,out_y_sz,0,1);
figure(200);
imagesc(out_m);

I dont know exactly if its a circular convolution but it seems to. (could be some kind of aliasing too, when processing some kind of images)

Ahmed Zakzouk

nice work

Aaron Clarke

Nice function. Works great.

MATLAB Release
MATLAB 6.1 (R12.1)
Acknowledgements

Inspired by: fft_upsample

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video