thank's all of you
I writed the Function This way
where im is an image matrix
this is a butterworth filter
is it true?
/////////////////////////////////////////////
butterworth filter has an integer parameter and I ignored the parameter (n=1)
the parameter is kind of sharp rate for an image
/////////////////////////////////////////////
function lowpassFilter(im, cutoff)
im=rgb2gray(im);
sizeIm=size(im);
if cutoff < 0 | cutoff > 0.5
error('cutoff frequency must be between 0 and 0.5');
end
rows = sizeIm(1);
cols = sizeIm(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.
f = 1 ./ (1.0 + (radius ./ cutoff).^(2)); % The filter
fim=fftshift(fft2(im));
result=f.*fim;
imshow(ifft2(ifftshift(result)));
end