SIP Toolbox
gsm - 1D gaussian smoothing
Calling Sequence
- [xsm, Xsm] = gsm(x [, sigma, delta, in, out])
- [xsm, Xsm] = gsm(x, <named_args>)
Input Parameters
-
x:
the vector to be smoothed (row or column vector), real or complex.
-
sigma:
the standard deviation of the gaussian kernel. If sigma is zero, gsm returns the input vector unaltered in xsm. (Defaults to 5)
-
delta:
a double number. If the input is in the time domain, this is the time between samples (delta t), and defaults to 1. If the input is in the frequency domain, this is the frequency increment between samples (delta f), and defaults to 1/N, where N is the number of samples.
-
in:
indicates if the input, x, is a function of time (no FFT has been applied) or frequency (FFT has already been applied). Can be 'time' or 'frequency'. (Defaults to 'time')
-
out:
indicates if the output, xsm, is a function of time (inverse FFT will be applied) or frequency (inverse FFT will not be applied). Can be 'time' or 'frequency'. (Defaults to 'time') This is a sequence of statements key1=value1, key2=value2,... where key1, key2,... can be any of the optional arguments above (sigma, in, out), in any order.
Output Parameters
-
xsm:
the smoothed vector in "time" or "frequency" domain.
-
Xsm:
the smoothed vector in "frequency" domain.
Description
Function gsm performs gaussian smoothing of the vector x, with
standard deviation sigma, using FFT. The optional arguments in
and out enables the user to reuse previously done FFTs. Here are
some possible uses of gsm:
- xsm = gsm(x)
-
sigma defaults to 5, in and out both defaults to 'time'.
- xsm = gsm(x,15)
-
sigma equals 15, in and out both defaults to 'time'.
- xsm = gsm(x,15, out='frequency')
-
x in time domain.
xsm in frequency domain (inverse fft is NOT done by gsm)
- xsm = gsm(x,15,in='frequency', out='frequency')
-
xsm = gsm(x,15,in='frequency', out='frequency')
x in frequency domain (fft has already been done).
xsm in frequency domain (inverse fft is NOT done by gsm)
- xsm = gsm(x, 'frequency', delta=0.1)
-
delta f is 0.1
sigma defaults to 5
x in frequency domain.
xsm in time domain (inverse fft is done by gsm)
In all above examples, Xsm is in the frequency domain. It is the second output parameter, and thus it was discarded in the above examples.
Examples
initial_dir = PWD;
chdir (SIPDIR + 'images');
Img = imread('star.bmp');
xset('window',0);
xbasc()
imshow(Img,2);
[x,y] = follow(Img); // get the parametric contour
t=1:size(x,'*');
xset('window',1)
xbasc()
subplot(121)
plot2d(t,x,2);
subplot(122)
plot2d(t,y,1);
xsm = gsm(x,15); // gaussian-smooth the contour
ysm = gsm(y,15);
subplot(121)
plot2d(t,xsm,2);
subplot(122)
plot2d(t,ysm,1);
// builds an image from parametric contour:
Img2=unfollow(xsm,ysm,size(Img));
xset('window',0);
xbasc()
imshow(Img2,2);
chdir(initial_dir);
Authors
-
Ricardo Fabbri <ricardofabbri (AT) users DOT sf DOT net>
Availability
The latest version of the Scilab Image Processing toolbox can be found at
http://siptoolbox.sourceforge.net
See Also
gsm2d, fft,