View License

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

» Watch video

Highlights from

4.8 | 8 ratings Rate this file 7 Downloads (last 30 days) File Size: 3.1 KB File ID: #4658 Version: 1.0
image thumbnail



Ohad Gal (view profile)


21 Mar 2004 (Updated )

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

| Watch this File

File Information

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


Fft Upsample inspired this file.

MATLAB release MATLAB 6.1 (R12.1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
22 Jan 2015 psucale

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

21 Jan 2015 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)

Comment only
21 Sep 2014 Mikhail Konnik

@ 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.

Comment only
21 Sep 2014 Mikhail Konnik

29 Sep 2010 Aravind Kumar

The code works great ! Thanks.

31 Mar 2010 Sumedh Joshi

26 Nov 2009 Jong Rah

14 Sep 2007 Jeroen Corthout

12 Jan 2005 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)];
out_x_sz = 320;
out_y_sz = 320;
out_m = updownsample( in_m,out_x_sz,out_y_sz,0,1);

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)

10 Apr 2004 Ahmed Zakzouk

nice work

Comment only
09 Apr 2004 Aaron Clarke

Nice function. Works great.

Contact us