VPI - Vision Programming Interface

4.0 Release

Median Filter

Runs a 2D median filter over the input image. More...

Functions

VPIStatus vpiSubmitMedianFilter (VPIStream stream, uint64_t backend, VPIImage input, VPIImage output, int32_t kernelWidth, int32_t kernelHeight, const int8_t *kernelData, VPIBorderExtension border)
 Runs a 2D median filter over an image. More...
 

Detailed Description

Runs a 2D median filter over the input image.

Refer to Median Filter for more details and usage examples regarding Median Filter.

Function Documentation

◆ vpiSubmitMedianFilter()

VPIStatus vpiSubmitMedianFilter ( VPIStream  stream,
uint64_t  backend,
VPIImage  input,
VPIImage  output,
int32_t  kernelWidth,
int32_t  kernelHeight,
const int8_t *  kernelData,
VPIBorderExtension  border 
)

#include <vpi/algo/MedianFilter.h>

Runs a 2D median filter over an image.

Parameters
[in]streamA stream handle where the operation will be queued into.
[in]backendBackend that will execute the algorithm.
[in]inputInput image to be denoised.
[out]outputOutput image where the result is written to.
  • Must not be NULL.
  • Must have same format and dimensions as input image.
  • Image must have enabled the backends that will execute the algorithm.
[in]kernelWidth,kernelHeightKernel dimensions. The coordinate of the kernel weight that is aligned with the source pixel is given by the following formula:

\begin{align*} k_x &= \mathit{kernelWidth}/2 \\ k_y &= \mathit{kernelHeight}/2 \end{align*}

  • Must be between 1x1 and 11x11, can be non square.
  • Must be 3x3 for PVA backend.
[in]kernelDataMedian kernel binary mask. It defines the structuring element, or median calculation mask, in row-major layout. Input pixels corresponding to an element of value 0 will be excluded from the median calculation. The contents of kernelData will be copied, so the buffer is safe to destroy on return from vpiSubmitMedianFilter.
  • NULL may be used as a shortcut to mean all elements are non-zero.
  • If not NULL, it must point to a buffer with kernelWidth * kernelHeight elements.
  • For PVA backend, kernelData must be NULL or contain only non-zero elements.
[in]borderHow to handle pixels outside image boundaries.
Return values
VPI_ERROR_INVALID_ARGUMENTstream is NULL.
VPI_ERROR_INVALID_ARGUMENTinput or output are NULL.
VPI_ERROR_INVALID_ARGUMENTinput and output image dimensions and formats do not match.
VPI_ERROR_INVALID_ARGUMENTImage dimensions aren't supported for given format.
VPI_ERROR_INVALID_ARGUMENTborder not supported.
VPI_ERROR_INVALID_ARGUMENTbackend is invalid or unknown.
VPI_ERROR_INVALID_IMAGE_FORMATinput and output formats aren't supported
VPI_ERROR_NOT_IMPLEMENTEDMedian filter algorithm is not supported by given backend.
VPI_ERROR_INVALID_OPERATIONBackend hardware not available.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in stream, input or output.
VPI_SUCCESSOperation executed successfully.