function y=iirfilt(a,x)
% y=iirfilt(a,x)
%	Filter the image x by a causal IIR filter a, using symmetric extension.
%	Example filter parameters:
%		 1.0000    0.2159   -0.0189    0.0084
%		 1.1333   -0.2052    0.0073    0.0086
%		-0.1617   -0.0171    0.0117         0
%		-0.0174    0.0344         0         0
%	Warning: the current implementation is a very slow algorithm.    

y=x;
h=waitbar(0,'IIR filtering',size(x,1));

for i=1:size(x,1),
  waitbar(i);
  for j=1:size(x,2),
    for k=1:size(a,1),
      for l=1:size(a,2),
	if ~(k==1 & l==1),
	  m=i-k+1;
	  n=j-l+1;
	  if m<=0,
	    m=-m+1;
	  end
	  if n<=0,
	    n=-n+1;
	  end	    
	  y(i,j)=y(i,j)+a(k,l)*y(m,n);
	end
      end
    end
  end
end
close(h);
	