FILT_DWMTM Function
Performs a 1D, 2D, or 3D adaptive double-window-modified trimmed mean filter.
Usage
result = FILT_DWMTM(image, noise_std, thresh_factor,
medxdim[, medydim[, medzdim]])
Input Parameters
image—A 1D, 2D or 3D array containing a signal; point or signal-interleaved signals; an image; image, row or pixel interleaved images; or a volume.
noise_std—The standard deviation of the noise in image.
thresh_factor—The factor used to compute the threshold range for points included in the mean calculation. If thresh_factor = 0, then FILT_DWMTM is the same as a median filter.
medxdim—The width of the median filtering window.
medydim—(optional) The height of the median filtering window. (Used for images and volumes only.)
medzdim—(optional) The depth of the 3D median filtering window. (Used for volumes only.)
Returned Value
result—An array of the same size and dimensions as image, unless otherwise affected by using the Edge keyword.
Keywords
Edge—A scalar string indicating how edge effects are handled. (Default: 'zero') Valid strings are:
*'pad'—The input image is padded before the filtering operation with the value specified using the Pad_Value keyword.
*'zero'—Sets the border of the output image to zero. (Default)
*'copy'—Copies the border of the input image to the output image.
*'reduce'—Returns a reduced-size image that is smaller than the input image by the kernel dimensions.
Intleave—A scalar string indicating the type of interleaving of 2D input signals and 3D image arrays. Valid strings and the corresponding interleaving methods are:
*'point'—The 2D input array arrangement is (px) for p  point-interleaved signals of length x.
*'signal'—The 2D input image array arrangement is (xp) for p  signal-interleaved signals of length x.
*'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.
*'volume'—The input image array is treated as a single entity.
Mxdim—The width of the mean filtering window. The value of Mxdim must be medxdim. (Default: medxdim + 2)
Mydim—The height of the mean filtering window. The value of Mydim must be medydim. (Used for images and volumes only.) (Default: medydim + 2)
Mzdim—The depth of the 3D mean filtering window. The value of Mzdim must be medzdim. (Used for volumes only.) (Default: medzdim + 2)
 
note
Mzdim is only used for 3D volumes.
Pad_Value—The value to use for the image padding. (Default: 0)
 
note
The Pad_Value keyword is valid only when Edge = 'pad'.
Spot—This keyword specifies explicit positioning of the element number of the filter window “sweet spot.” The Spot keyword default depends on the setting of the Edge keyword as shown in Table 10-1: Edge and Spot Keywords Relationships.
 
Edge and Spot Keywords Relationships
Edge Keyword
Spot Keyword
Spot Keyword Default Setting
not used
(Default: 'zero')
As specified, or the default.
kernel center
'pad'
Ignored.
kernel center
'zero'
As specified, or the default.
kernel center
'copy'
As specified, or the default.
kernel center
'reduce'
Ignored.
Spot = 0
Zero_Negatives—If set, all negative values in the result image are set to zero.
Discussion
The adaptive double-window-modified trimmed mean filter (DWMTM) is superior to the mean filter for removing Gaussian noise in the presence of impulse noise. The filter operation begins by computing the median value to use for the median filter. An output pixel is then computed from the mean of the mean filtering window. Values in the mean filtering window lying outside the median plus or minus a constant c (where, c = thresh_factor*noise_std) don’t contribute to the mean calculation.
In this way, high and low outliers, such as impulse noise are eliminated from the mean calculation. Typical values for thresh_factor are in the 1.5 to 2.5 range. If thresh_factor = 0, then FILT_DWMTM is the same as a median filter.
Example
; Read an image.
image = IMAGE_READ(!IP_Data + 'face.tif')
; Corrupt the image with Gaussian noise.
noise = NOISE_GEN(image('width'), image('height'), /Normal, $
High = 128.0, Low = 50.0)
noise_image = IPMATH(image('pixels'), '+', noise)
; Corrupt the noise image with impulse noise.
status = NOISE_IMPULSE(0.15, noise_image)
; Try to remove the noise using the DWMTM filter.
dwmtm_image = FILT_DWMTM(noise_image, 1.0, 2.0, 3, 3)
; Display the image.
TVSCL, dwmtm_image
See Also