Specifications

Image Filtering
6-17
6
ColorMedianFilter
Apply a color median
filter to the image.
void iplColorMedianFilter(IplImage*
srcImage
, IplImage*
dstImage
, int
nCols
, int
nRows
, int
anchorX
, int
anchorY
);
srcImage
Thesourceimage.
dstImage
The resultant image.
nCols
Number of columns in the neighborhood to use.
nRows
Number of rows in the neighborhood to use.
anchorX, anchorY
The [x, y] coordinates of the anchor cell in the
neighborhood.
Discussion
The previously described function iplMedianFilter() processes R, G,
and B color planes of an image separately, and as a result any correlation
between color components is lost. If you want to preserve this information,
use the
iplColorMedianFilter() function instead. For each input pixel,
this function computes differences between red, green, and blue
components of pixels in the neighborhood area of size
nRows
by
nCols
and the input pixel. The ‘distance’ between the input pixel i and the
neighborhood pixel j is formed as sum of absolute values
abs (R(i)-R(j)) + abs (G(i)-G(j)) + abs (B(i)-B(j)) .
After scanning all neighborhood area, the function sets the output value for
pixel i as the value of the neighborhood pixel with the smallest distance to i.
The function
iplColorMedianFilter() supports color images with or
without alpha channel.