Order Statistic Filter Class
This class implements order-statistic image processing filters.
You're viewing an older version of this page (#882). View the current version.
Interface
#include <codecogs/computing/graphics/order statistic filter class.h>
using namespace Computing::Graphics;
float *alpha(float out[], const float in[], int nx, int ny, int trim);float *max(float out[], const float in[], int nx, int ny);float *median(float out[], const float in[], int nx, int ny);float *midpoint(float out[], const float in[], int nx, int ny);float *min(float out[], const float in[], int nx, int ny);typedef float (*selfunc)(windat *w);float *filt(float out[], const float in[], int nx, int ny, selfunc pf, int trim = -1);static float alphaval(windat *w);static float maxval(windat *w);static float medval(windat *w);static float midval(windat *w);static float minval(windat *w);static int fcmp(const void *p1, const void *p2);float *fillborder(float img[], int nx, int ny);float *Filt::alpha(float out[], const float in[], int nx, int ny, int trim)float *Filt::max(float out[], const float in[], int nx, int ny)float *Filt::median(float out[], const float in[], int nx, int ny)float *Filt::midpoint(float out[], const float in[], int nx, int ny)float *Filt::min(float out[], const float in[], int nx, int ny)float Filt::alphaval(windat *w)float Filt::minval(windat *w)float Filt::maxval(windat *w)float Filt::medval(windat *w)float Filt::midval(windat *w)float *Filt::filt(float out[], const float in[], int nx, int ny, selfunc pf, int trim)float *Filt::fillborder(float img[], int nx, int ny)int Filt::fcmp(const void *p1, const void *p2)
Overview
Order-statistic filters are used for eliminating or reducing noise in images. Like other spatial filters, these filters assign to each pixel in an image a value based on the values of the pixels in the neighborhood or window surrounding (and including) the pixel. What characterizes order-statistic filters is that the replacement value is based on an ordering or ranking, from smallest to largest, of the values of the pixels in the window. The max filter assigns to each pixel the maximum value of the pixels in the window, the min filter the minimum value, the median filter the median value, and the midpoint filter the mean of the minimum and maximum values. The alpha-trimmed mean filter ignores the lowest and highest values of the pixels in the window, and finds the mean of the remaining values; the number of values ignored is determined by the trim value, with the trim/2 lowest and highest values ignored. In the limiting case of trim = 0, the filter becomes an averaging (mean) filter. In the other limiting case of M*N - 1, where M is the length of the window and N is the width of the window, the filter becomes a median filter.(Note that in this implementation the trim/2 value is truncated as an integer.)
Different order-statistic filters are suited for removing or reducing different kinds of noise. The median filter removes impulse or salt-and-pepper noise -- that is, small, scattered areas of low- and high-value pixels -- while preserving the edges of objects. The min filter enhances areas of images with low-value pixels and removes salt noise. The max filter enhances areas of images with high-value pixels and removes pepper noise. The mid-point filter reduces noise that takes on a range of values, such as noise with a Gaussian or uniform distribution of values. The alpha-trimmed mean filter is useful where there are different kinds of noise, such as a combination of impulse and Gaussian noise.
The actual filtering of the image occurs in filt(). The selfunc parameter is the function that selects the values to be assigned to each pixel in the image by operating on the values of the pixels in the window after the values have been ordered. The particular function passed as an argument to filt() depends on the filter being applied. This is reflected in the naming scheme, with maxval() passed for the max filter, minval() passed for the min filter, and so on.
There are various ways to deal with the pixels on the border. In this implementation, the pixels are assigned the value of the nearest interior pixel. This is done in fillborder().
The selection functions (i.e. the *val() functions) are static so they can be passed as arguments to filt() with a much simpler syntax than if they were not static. fcmp() must be static so it can be passed as an argument to the qsort() function.
Members of Filt
CLASS METHOD
alpha
CLASS METHOD
max
CLASS METHOD
median
CLASS METHOD
midpoint
CLASS METHOD
min
CLASS METHOD
float
CLASS METHOD
filt
STATIC CLASS METHOD
alphaval
STATIC CLASS METHOD
maxval
STATIC CLASS METHOD
medval
STATIC CLASS METHOD
midval
STATIC CLASS METHOD
minval
STATIC CLASS METHOD
fcmp
CLASS METHOD
fillborder
CLASS METHOD
alpha
Parameters
Returns
Steve Simon (April 2009)
References
- Gonzalez, R. and Woods, R. "Digital Image Processing," 3rd ed., pp. 156-157 and 325-330.
CLASS METHOD
max
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
median
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
midpoint
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
min
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
alphaval
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
minval
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
maxval
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
medval
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
midval
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
filt
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
fillborder
Parameters
Returns
Steve Simon (April 2009)
CLASS METHOD
fcmp
Parameters
Returns
Steve Simon (April 2009)
References
- Kernighan, B. and Pike, R. "The Practice of Programming." Section 2.3.