function fft_smooth,img,low=low,high=high

;+
;NAME:
;	fft_smooth
;SAMPLE CALLING SEQUENCE:
;	out = fft_smooth(image, low = 2)
;	out = fft_smooth(image, high = 250)
;PURPOSE:
;	To use the fast fourier transform technique to remove low or
;	high frequency components of the image.
;INPUT:
;	image = the image to be smoothed
;OUTPUTS:
;	out = the smoothed image
;KEYWORD INPUTS:
;	low, if you want to remove low frequency components of the image
;		(range of low is normally 1 to 25)
;	high, if you want to remove high frequency components
;		The maximum value for HIGH is set by the user library
;		function DIST which is called to generate the filter.
;		IDL> f = dist(xx,yy)
;		IDL> print, max(f)
;	      Representative values are:
;		Image size   Max value for high
;		64x64		 45
;		128x128		 90
;		256x256		181
;		512x512		362
;		1024x512	527
;		1024x1024	724
;RESTRICTIONS:
;	Use only on a single image at a time, not an array of images.
;HISTORY:
;	Written by L. Acton on 2/22/94.
;	10-Dec-94 (LWA) Removed obsolete parameter.
;	23-May=03 Incorporated Wiener filter.
;-

siz=size(img)

f=dist(siz(1),siz(2))

if keyword_set(low) then begin
  f=f gt low
  r=fft(fft(img,-1)*f*wiener(img),1)
endif

if keyword_set(high) then begin
  f=f lt high
  r=fft(fft(img,-1)*f*wiener(img),1)
endif

out=float(r)

return, out

end


