FILT_WIENER Function
Computes and applies a parametric Wiener filter to an image that is either in the spatial or the spatial frequency domain.
Usage
result = FILT_WIENER(gamma, image, degrad, noise[, original])
Input Parameters
gamma—A scalar float that controls the least-squared error constraint of the Wiener filter.
image—The input corrupted image to be filtered as a 2D array containing a single image, or a 3D array containing interleaved images in ‘image’ ‘row’ or ‘pixel’ form (see intleave keyword below). This and the following three parameters must all be in either the spatial or in the frequency domain.
degrad—The degradation function as a scalar, or as a 2D array of a single image, or as a 3D array of interleaved images in ‘image’, ‘row’, or ‘pixel’ form.
noise—An estimate of the noise contained in the corrupted input image, as: a constant scalar, or as a 2D array of a single image, or a 3D array of interleaved images in ‘image’, ‘row’, or ‘pixel’ form.
original—Optional. An estimate of the original uncorrupted image as: a scalar estimate of its magnitude, or as a 2D array of a single image, or as a 3D array of interleaved images in ‘image’, ‘row’, or ‘pixel’ form.
 
note
The input parameters: image, degrad, noise, and original must all be in either the spatial or in the frequency domain. The input parameters: degrad, noise, and original must all three be of the same size and dimensions. For example, if degrad is a scalar, noise and original must also be scalars.
Returned Value
result—A complex array of the same size and dimensions as the corrupted image.
Keywords
Intleave—A scalar string indicating the type of interleaving of 3D input image arrays. Valid strings and the corresponding interleaving methods are:
*'pixel'—The input array arrangement is (pxy) for p  pixel-interleaved images of x-by-y.
*'row'—The 3D image array arrangement is (xpy) for p  row-interleaved images of x-by-y.
*'image'—The 3D image array arrangement is (xyp) for p  image-interleaved images of x-by-y.
Imag—If set, returns only the imaginary portion of the result.
Mag—If set, the magnitude of the computed result is returned.
Real—If set, only the real portion of the computed result is returned.
Spatial—If set, parameters image, degrad, noise, and original are all assumed to be in the spatial domain. Otherwise, they are all assumed to be in the spatial frequency domain.
Wiener—Specifies a variable to receive the computed Wiener filter. The filter is in the frequency domain and is a complex array.
Discussion
The Wiener filter, also known as the least mean square (LMS) filter, is useful in restoring an image when a priori knowledge of the degradation process is known. The equation for the parametric Wiener filter, in the frequency domain, is:
where (u, v) are the frequency coordinates, H(uv) is the degradation function, G(uv) is the degraded image, Sf(uv) is the spectrum of the original image estimate, and Sn(uv) is the noise spectrum.
Example
In this example, we work in the spatial domain. We create the corrupted image by first blurring the original with a smoothing function and then adding noise to it in the frequency domain. We then transform the result in the spatial domain.
; Define the directory where the image resides.
IMAGE_DATA = getenv('RW_DIR')+'/image-1_0/data/'
; Read an image. For example, teluride24.jpg.
test_image = IMAGE_READ( IMAGE_DATA + 'teluride24.jpg')
wd = test_image('width')
ht = test_image('height')
original = test_image('pixels')
WINDOW, 0, xsiz=wd, ysiz=ht, xpos=0, ypos=5, title='ORIGINAL'
; Display the original image.
TVSCL, original, true=3
degrad   = FLTARR(wd, ht, 3) 
FOR i=0,2 DO degrad(wd/2,ht/2,i) = 1.0  
; replace each pixel value by box-car average of a 5x5 window.
d=5 
; Provide degradation function h(x,y) estimate in spatial domain. 
; For example, degrad = h(x,y) may be a smoothing function (such 
; as a blurred point source).
degrad = SMOOTH(degrad,d,intleave='image')
; Blur the original in the frequency domain:
freq_blurred = wd*ht*fft(degrad,-1,intleave='image')* $
fft(original,-1,intleave='image')
high = 25.0
low  = 0.00001
gauss_noise = low + (high-low) * RANDOMU(Seed,wd,ht,3) 
; Generate the noise to add to the blurred image.
freq_corrupted = freq_blurred + fft(gauss_noise, -1, $
intleave='image')
; Transform into spatial domain.
corrupted = fft(freq_corrupted, 1, intleave='image')
WINDOW, 1, xsiz=wd, ysiz=ht, xpos=0.5*wd, ypos=5, $
title='CORRUPTED'
; Display the corrupted image.
TVSCL, shift(corrupted,wd/2,ht/2,0), true=3 
; In the case that an estimate of original is not provided gamma
; greater 1. For example for the teluride24.jpg gamma =300. 
gamma = 1.0 
; Now use Wiener filtering to restore the image.
restored_image = FILT_WIENER(gamma, corrupted, degrad, $
gauss_noise, original, /Spatial)
WINDOW, 2, xsiz=wd, ysiz=ht, xpos=wd, ypos=5, title='RESTORED'
; Display the result.
TVSCL, restored_image, true=3
See Also