Replace pixels more than a specified pixels deviant from its neighbors
Computes the mean and standard deviation of pixels in a box centered at
each pixel of the image, but excluding the center pixel. If the center
pixel value exceeds some # of standard deviations from the mean, it is
replaced by the mean in box. Note option to process pixels on the edges.
Result = sigma_filter( image, box_width, N_sigma=(#), /ALL,/MON )
image = 2-D image (matrix)
box_width = width of square filter box, in # pixels (default = 3)
N_sigma = # standard deviations to define outliers, floating point,
recommend > 2, default = 3. For gaussian statistics:
N_sigma = 1 smooths 35% of pixels, 2 = 5%, 3 = 1%.
RADIUS = alternative to specify box radius, so box_width = 2*radius+1.
/ALL_PIXELS causes computation to include edges of image,
/KEEP causes opposite effect: pixels with values outside of specified
deviation are not changed, pixels within deviation are smoothed.
/ITERATE causes sigma_filter to be applied recursively (max = 20 times)
until no more pixels change (only allowed when N_sigma >= 2).
/MONITOR prints information about % pixels replaced.
N_CHANGE = # of pixels changed (replaced with neighborhood mean).
VARIANCE = image of pixel neighborhood variances * (N_sigma)^2,
DEVIATION = image of pixel deviations from neighborhood means, squared.
function filter_image( )
Compute mean over moving box-cars using smooth, subtract center values,
compute variance using smooth on deviations from mean,
check where pixel deviation from mean is within variance of box,
replace those pixels in smoothed image (mean) with orignal values,
return the resulting partial mean image.
Written, 1991, Frank Varosi and Dan Gezari NASA/GSFC
F.V.1992, added optional keywords /ITER,/MON,VAR=,DEV=,N_CHANGE=.
Converted to IDL V5.0 W. Landsman September 1997