
The Fourier Transform 189
MATLAB/Octave
if nargin
<2,
type=’log’;
end
if (type==’log’)
fl = log(1+abs(f));
fm =
max
(fl(:));
imshow(im2uint8(fl/fm))
elseif (type==’abs’)
fa=abs(f);
fm=max(fa(:));
imshow(fa/fm)
else
error(’TYPE
must be abs or log.’);
end;
And here is
homfilt
first f or MATLAB or Octave:
MATLAB/Octave
function res=homfilt(im,cutoff,order,lowgain,highgain)
% HOMFILT(IMAGE,FILTER) applies homomorphic filtering to the image IMAGE
% with the given parameters
u = im2uint8(im);
height = size(im,1);
width = size(im,2);
[x,y] = meshgrid(-floor(width/2):floor((width-1)/2),...
-floor(height/2):floor((height-1)/2));
lbutter = 1./(1+(sqrt(2)-1)
*
((x.^2+y.^2)/cutoff^2).^order); ...