VXLIB User Guide
VXLIB_median

Introduction

Kernel for computing the median pixel over a window of imput image, for each pixel.

Computes the median pixel over a window of imput image, for each pixel. This kernel supports two types on implementaions based on kernel size i.e. 3 X 3 and M X N.

A 3 X 3 implementaion takes all 9 values present in the kernel, sorts them in ascending order and returns the middle i.e. 5th value as median value and the kernel is moved forward with the stride of 1.

A M X N implementaion takes values corresponding to the true values in MASK kernel of size M X N, sorts them in ascending order and returns the median and the kernel is moved forward with the stride of 1.

OpenVX Function Reference Page : https://www.khronos.org/registry/vx/specs/1.1/html/d3/d77/group__group__vision__function__median__image.html

Data Structures

struct  VXLIB_median_InitArgs
 Structure containing the parameters to initialize the kernel. More...
 

Functions

int32_t VXLIB_median_getHandleSize (VXLIB_median_InitArgs *pKerInitArgs)
 This is a query function to calculate the size of internal handle. More...
 
VXLIB_STATUS VXLIB_median_init (VXLIB_kernelHandle handle, VXLIB_bufParams2D_t *bufParamsIn, VXLIB_bufParams2D_t *bufParamsMask, VXLIB_bufParams2D_t *bufParamsOut, VXLIB_bufParams2D_t *bufParamsScratch, const VXLIB_median_InitArgs *pKerInitArgs)
 This function should be called before the VXLIB_median_exec function is called. This function takes care of any one-time operations such as setting up the configuration of required hardware resources such as the streaming engine. The results of these operations are stored in the handle. More...
 
VXLIB_STATUS VXLIB_median_init_checkParams (VXLIB_kernelHandle handle, const VXLIB_bufParams2D_t *bufParamsIn, const VXLIB_bufParams2D_t *bufParamsMask, const VXLIB_bufParams2D_t *bufParamsOut, const VXLIB_bufParams2D_t *bufParamsScratch, const VXLIB_median_InitArgs *pKerInitArgs)
 This function checks the validity of the parameters passed to VXLIB_median_init function. This function is called with the same parameters as the VXLIB_median_init, and this function must be called before the VXLIB_median_init is called. More...
 
VXLIB_STATUS VXLIB_median_exec_checkParams (VXLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pMask, const void *restrict pOut, const void *restrict pScratch)
 This function checks the validity of the parameters passed to VXLIB_median_exec function. This function is called with the same parameters as the VXLIB_median_exec, and this function must be called before the VXLIB_median_exec is called. More...
 
VXLIB_STATUS VXLIB_median_exec (VXLIB_kernelHandle handle, void *restrict pIn, void *restrict pMask, void *restrict pOut, void *restrict pScratch)
 This function is the main kernel compute function. More...
 
void VXLIB_median_perfEst (VXLIB_kernelHandle handle, const VXLIB_bufParams2D_t *bufParamsIn, const VXLIB_bufParams2D_t *bufParamsMask, const VXLIB_bufParams2D_t *bufParamsOut, const VXLIB_bufParams2D_t *bufParamsScratch, const VXLIB_median_InitArgs *pKerInitArgs, size_t *archCycles, size_t *estCycles)
 This function estimates the archCycles and estCycles. More...
 

Function Documentation

◆ VXLIB_median_getHandleSize()

int32_t VXLIB_median_getHandleSize ( VXLIB_median_InitArgs pKerInitArgs)

This is a query function to calculate the size of internal handle.

Parameters
[in]pKerInitArgs: Pointer to structure holding init parameters
Returns
Size of the buffer in bytes
Remarks
Application is expected to allocate buffer of the requested size and provide it as input to other functions requiring it.

Definition at line 49 of file VXLIB_median.cpp.

◆ VXLIB_median_init()

VXLIB_STATUS VXLIB_median_init ( VXLIB_kernelHandle  handle,
VXLIB_bufParams2D_t bufParamsIn,
VXLIB_bufParams2D_t bufParamsMask,
VXLIB_bufParams2D_t bufParamsOut,
VXLIB_bufParams2D_t bufParamsScratch,
const VXLIB_median_InitArgs pKerInitArgs 
)

This function should be called before the VXLIB_median_exec function is called. This function takes care of any one-time operations such as setting up the configuration of required hardware resources such as the streaming engine. The results of these operations are stored in the handle.

Parameters
[in]handle: Active handle to the kernel
[in]bufParamsIn: Pointer to the structure containing dimensional information of input image
[in]bufParamsMask: Pointer to the structure containing dimensional information of mask
[out]bufParamsOut: Pointer to the structure containing dimensional information of output image
[out]bufParamsScratch: Pointer to the structure containing dimensional information of scratch buffer
[in]pKerInitArgs: Pointer to the structure holding init parameters
Returns
Status value indicating success or failure. Refer to VXLIB_STATUS.
Remarks
Application is expected to provide a valid handle.

Definition at line 159 of file VXLIB_median.cpp.

◆ VXLIB_median_init_checkParams()

VXLIB_STATUS VXLIB_median_init_checkParams ( VXLIB_kernelHandle  handle,
const VXLIB_bufParams2D_t bufParamsIn,
const VXLIB_bufParams2D_t bufParamsMask,
const VXLIB_bufParams2D_t bufParamsOut,
const VXLIB_bufParams2D_t bufParamsScratch,
const VXLIB_median_InitArgs pKerInitArgs 
)

This function checks the validity of the parameters passed to VXLIB_median_init function. This function is called with the same parameters as the VXLIB_median_init, and this function must be called before the VXLIB_median_init is called.

Parameters
[in]handle: Active handle to the kernel
[in]bufParamsIn: Pointer to the structure containing dimensional information of input image
[in]bufParamsMask: Pointer to the structure containing dimensional information of mask
[out]bufParamsOut: Pointer to the structure containing dimensional information of output image
[out]bufParamsScratch: Pointer to the structure containing dimensional information of scratch buffer
[in]pKerInitArgs: Pointer to the structure holding init parameters
Returns
Status value indicating success or failure. Refer to VXLIB_STATUS.
Remarks
None

Definition at line 63 of file VXLIB_median.cpp.

◆ VXLIB_median_exec_checkParams()

VXLIB_STATUS VXLIB_median_exec_checkParams ( VXLIB_kernelHandle  handle,
const void *restrict  pIn,
const void *restrict  pMask,
const void *restrict  pOut,
const void *restrict  pScratch 
)

This function checks the validity of the parameters passed to VXLIB_median_exec function. This function is called with the same parameters as the VXLIB_median_exec, and this function must be called before the VXLIB_median_exec is called.

Parameters
[in]handle: Active handle to the kernel
[in]pIn: Pointer to the structure input image
[in]pMask: Pointer to the structure mask
[out]pOut: Pointer to the output buffer
[out]pScratch: Pointer to the scratch buffer
Returns
Status value indicating success or failure. Refer to VXLIB_STATUS.
Remarks
None

Definition at line 131 of file VXLIB_median.cpp.

◆ VXLIB_median_exec()

VXLIB_STATUS VXLIB_median_exec ( VXLIB_kernelHandle  handle,
void *restrict  pIn,
void *restrict  pMask,
void *restrict  pOut,
void *restrict  pScratch 
)

This function is the main kernel compute function.

Please refer to details under VXLIB_median_exec

Parameters
[in]handle: Active handle to the kernel
[in]pIn: Pointer to the structure input image
[in]pMask: Pointer to the structure mask
[out]pOut: Pointer to the output buffer
[out]pScratch: Pointer to the scratch buffer
Diamensions of Input/Output buffers
Buffer Row Column
pIn R C
pMask M N
pOut R - (M - 1) C - (N - 1)
pScratch M * N C
Returns
Status value indicating success or failure. Refer to VXLIB_STATUS.
Assumptions:
  • None
Performance Considerations:
For best performance,
  • The input and output data buffers are expected to be in L2 memory
  • The buffer pointers are assumed to be 64-byte aligned
Remarks
Before calling this function, application is expected to call VXLIB_median_init and VXLIB_median_exec_checkParams functions. This ensures resource configuration and error checks are done only once for several invocations of this function.

Definition at line 282 of file VXLIB_median.cpp.

◆ VXLIB_median_perfEst()

void VXLIB_median_perfEst ( VXLIB_kernelHandle  handle,
const VXLIB_bufParams2D_t bufParamsIn,
const VXLIB_bufParams2D_t bufParamsMask,
const VXLIB_bufParams2D_t bufParamsOut,
const VXLIB_bufParams2D_t bufParamsScratch,
const VXLIB_median_InitArgs pKerInitArgs,
size_t *  archCycles,
size_t *  estCycles 
)

This function estimates the archCycles and estCycles.

Parameters
[in]handle: Active handle to the kernel
[in]bufParamsIn: Pointer to the structure containing dimensional information of input image
[in]bufParamsMask: Pointer to the structure containing dimensional information of mask
[in]bufParamsOut: Pointer to the structure containing dimensional information of output image
[in]bufParamsScratch: Pointer to the structure containing dimensional information of scratch buffer
[in]pKerInitArgs: Pointer to the structure holding init parameters
[out]archCycles: Arch compute cycles obtained from asm.
[out]estCycles: Estimated cycles including overhead.
Returns
None.
Assumptions:
Remarks
This function is expected to be called when the estimation of cycles is needed.

Definition at line 339 of file VXLIB_median_ci.cpp.