A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
medfilt
ArrayFire Functions | ArrayFire Functions by Category » Image Processing » Filters

Median Filter More...

## Functions
AFAPI array | medfilt (const array &in, const dim_t wind_length=3, const dim_t wind_width=3, const borderType edge_pad=AF_PAD_ZERO)
| C++ Interface for median filter.
AFAPI array | medfilt1 (const array &in, const dim_t wind_width=3, const borderType edge_pad=AF_PAD_ZERO)
| C++ Interface for median filter.
AFAPI array | medfilt2 (const array &in, const dim_t wind_length=3, const dim_t wind_width=3, const borderType edge_pad=AF_PAD_ZERO)
| C++ Interface for median filter.
AFAPI af_err | af_medfilt (af_array *out, const af_array in, const dim_t wind_length, const dim_t wind_width, const af_border_type edge_pad)
| C Interface for median filter.
AFAPI af_err | af_medfilt1 (af_array *out, const af_array in, const dim_t wind_width, const af_border_type edge_pad)
| C Interface for 1D median filter.
AFAPI af_err | af_medfilt2 (af_array *out, const af_array in, const dim_t wind_length, const dim_t wind_width, const af_border_type edge_pad)
| C Interface for median filter.

## Detailed Description

Median Filter

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.

## Function Documentation

## ◆ af_medfilt()

AFAPI af_err af_medfilt | ( | af_array * | out,
|  | const af_array | in,
|  | const dim_t | wind_length,
|  | const dim_t | wind_width,
|  | const af_border_type | edge_pad )

C Interface for median filter.

Parameters

  [out] | out | array is the processed image
  [in] | in | array is the input image
  [in] | wind_length | is the kernel height
  [in] | wind_width | is the kernel width
  [in] | edge_pad | value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM]

Returns
  AF_SUCCESS if the median filter is applied successfully, otherwise an appropriate error code is returned.

## ◆ af_medfilt1()

AFAPI af_err af_medfilt1 | ( | af_array * | out,
|  | const af_array | in,
|  | const dim_t | wind_width,
|  | const af_border_type | edge_pad )

C Interface for 1D median filter.

Parameters

  [out] | out | array is the processed signal
  [in] | in | array is the input signal
  [in] | wind_width | is the kernel width
  [in] | edge_pad | value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM]

Returns
  AF_SUCCESS if the median filter is applied successfully, otherwise an appropriate error code is returned.

## ◆ af_medfilt2()

AFAPI af_err af_medfilt2 | ( | af_array * | out,
|  | const af_array | in,
|  | const dim_t | wind_length,
|  | const dim_t | wind_width,
|  | const af_border_type | edge_pad )

C Interface for median filter.

Parameters

  [out] | out | array is the processed image
  [in] | in | array is the input image
  [in] | wind_length | is the kernel height
  [in] | wind_width | is the kernel width
  [in] | edge_pad | value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM]

Returns
  AF_SUCCESS if the median filter is applied successfully, otherwise an appropriate error code is returned.

## ◆ medfilt()

AFAPI array medfilt | ( | const array & | in,
|  | const dim_t | wind_length = 3,
|  | const dim_t | wind_width = 3,
|  | const borderType | edge_pad = AF_PAD_ZERO )

C++ Interface for median filter.

array a = array(4, 4, input);
// af_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
array b = medfilt(a, 3, 3, AF_PAD_ZERO);
// af_print(b);
// b= 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

Parameters

  [in] | in | array is the input image
  [in] | wind_length | is the kernel height
  [in] | wind_width | is the kernel width
  [in] | edge_pad | value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM]

Returns
  the processed image

## ◆ medfilt1()

AFAPI array medfilt1 | ( | const array & | in,
|  | const dim_t | wind_width = 3,
|  | const borderType | edge_pad = AF_PAD_ZERO )

C++ Interface for median filter.

array a = array(4, 4, input);
// af_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
array b = medfilt(a, 3, 3, AF_PAD_ZERO);
// af_print(b);
// b= 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

Parameters

  [in] | in | array is the input signal
  [in] | wind_width | is the kernel width
  [in] | edge_pad | value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM]

Returns
  the processed signal

## ◆ medfilt2()

AFAPI array medfilt2 | ( | const array & | in,
|  | const dim_t | wind_length = 3,
|  | const dim_t | wind_width = 3,
|  | const borderType | edge_pad = AF_PAD_ZERO )

C++ Interface for median filter.

array a = array(4, 4, input);
// af_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
array b = medfilt(a, 3, 3, AF_PAD_ZERO);
// af_print(b);
// b= 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

Parameters

  [in] | in | array is the input image
  [in] | wind_length | is the kernel height
  [in] | wind_width | is the kernel width
  [in] | edge_pad | value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM]

Returns
  the processed image