The C++ interface for medfilt. More...

array medfilt (const array &image, const unsigned height=3, const unsigned width=3)
 Median filtering within window (default 3x3) More...
 

Detailed Description

The C++ interface for medfilt.

Apply a median filter of a given size to an image. A median filter is similar to the arbitrary filter except that instead of a weighted sum, the median value of the pixels covered by the kernel is returned.

For instance, if we apply a median filter to an simple sequential image:

array = array(seq(1,16), 4, 4);
print(a);
//a = 1.0000 5.0000 9.0000 13.0000
// 2.0000 6.0000 10.0000 14.0000
// 3.0000 7.0000 11.0000 15.0000
// 4.0000 8.0000 12.0000 16.0000
print(medfilt(a, 3, 3));
// 0.0000 2.0000 6.0000 0.0000
// 2.0000 6.0000 10.0000 10.0000
// 3.0000 7.0000 11.0000 11.0000
// 0.0000 4.0000 8.0000 0.0000

This example highlights that pixels outside the image are treated as zeros. So, for the first pixel, the neighborhood looks like:

0 0 0
0 1 5
0 2 6

the median of which is zero.

Function Documentation

array af::medfilt ( const array &  image,
const unsigned  height = 3,
const unsigned  width = 3 
)

Median filtering within window (default 3x3)

// median filter an image with a 5x5 kernel
array img_out = medfilt(img_in, 5, 5);
// median filter an image with the default 3x3 kernel
array img_out = medfilt(img_in);
Parameters
[in]image
[in]heightof window (default 3)
[in]widthof window (default 3)
GFOR Support
No support for images smaller then 2x2.
CUDA Support