low-pass exponential filter - fourier space
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Aude Rapet
le 27 Oct 2016
Commenté : David Goodmanson
le 4 Nov 2016
Hello,
I am a beginner in Matlab and I have to understand a code. The part I don't understand is to calculate filter for displacement datas (in Fourier space) (low-pass exponential filter).
qmax=nr2/(pi*min_feature_size); %min_feature_size: spatial resolution of the stress measurement in units of the grid spacing.
%nr2=number of rows and columns across field (must be square)
% Get distance from of a grid point from the centre of the array
y=repmat((1:nr2)'-nr2/2,1,nr2);
x=y';
q=sqrt(x.^2+y.^2);
% Make the filter
qmsk=exp(-(q./qmax).^2);
qmsk=ifftshift(qmsk)
I have difficutlies understanding what he is doing exactly...what is the iffshift for? and what is this filter doing excalty
Thank you for your help Aude
0 commentaires
Réponse acceptée
David Goodmanson
le 27 Oct 2016
Hi Aude, To construct a filter in this situation it's convenient to use a frequency array with zero frequency in the center. In one dimension the lowpass filter might look like
f = -50:49; y = exp(-f.^2/100); plot(f,y)
(it's more properly called a gaussian than an exponential). But to do an fft or an ifft, Matlab wants zero frequency at the beginning of the array, not the middle. The ifftshift function swaps halves of the y array to put zero frequency at the beginning. So
ff = 0:99; plot(ff,ifftshift(y))
puts the center of the gaussian down at zero frequency, and the negative frequency part of the gaussian into the upper half of the frequency array. Your code does the same in two dimensions.
6 commentaires
David Goodmanson
le 4 Nov 2016
It is a gaussian filter, because you can write it as exp( -(q.^2) / (qmax^2) ). Then if you define sigma in terms of qmax with the expression 2*sigma^2 = qmax^2, you get same formula for a gaussian as in one of your earlier comments. Except for the normalizing factor in front. Again, I don't know why the are not using that.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Filter Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!