Vous êtes sur la page 1sur 2

check_filter

file:///C:/Documents%20and%20Settings/shiri/Desktop/%E1%F8%20%E0%E...

%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % check_filter % Builds a butterworth LPF and displays it % Modified by Amir Alush 25.5.09 %- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function check_filter() % Setting the filter's paramters sze = [101 101]; %filter size cutoff = 0.25; n = 2; % Constructing the filter f = lowpassfilter(sze, cutoff, n); % Displaying filter X = (ones(rows,1) * [1:cols] - (fix(cols/2)+1))/cols; Y = ([1:rows]' * ones(1,cols) - (fix(rows/2)+1))/rows; figure; surf(X,Y,f); %- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % lowpassfilter % Constructs a low-pass butterworth filter. % cutoff - cutoff frequency normalized (should be 0-0.5) - meaning % that the cutoff frequency ranges from 0 to M/2,N/2 [cycles per sample(pixel)]. % n - the filter's order % sze - filter's size (number rows[M], number columns[N] ). %- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function f = lowpassfilter(sze, cutoff, n) rows = sze(1); cols = sze(2); % X and Y matrices with ranges normalised to +/- 0.5 x = (ones(rows,1) * [1:cols] - (fix(cols/2)+1))/cols; y = ([1:rows]' * ones(1,cols) - (fix(rows/2)+1))/rows; radius = sqrt(x.^2 + y.^2); % A matrix with every pixel = radius relative to centre. % The filter (note that it's centered!!)

f = 1 ./ (1.0 + (radius ./ cutoff).^(2*n)); end end

1 of 2

25/05/2009 18:20

check_filter

file:///C:/Documents%20and%20Settings/shiri/Desktop/%E1%F8%20%E0%E...

Published with MATLAB 7.6

2 of 2

25/05/2009 18:20

Vous aimerez peut-être aussi