FilterMedianBorder
Applies a median filter to the source image and stores the result to the destination image. The border pixel values are determined based on the specified border type and border value parameters. The kernel size of this filter is defined by input parameters.
The function is declared as follows:
HmppResult HMPPI_FilterMedianBorder_16s_C1R(const int16_t* pSrc, int srcStep, int16_t* pDst, int dstStep, HmppiSize dstRoiSize, HmppiSize maskSize, HmppiBorderType borderType, int16_t borderValue);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
pSrc |
Pointer to the source vector |
The value cannot be NULL. |
Input |
srcStep |
Distance between starts of consecutive lines in the source image, in bytes |
(0, INT_MAX] |
Input |
pDst |
Pointer to the destination vector |
The value cannot be NULL. |
Output |
dstStep |
Distance between starts of consecutive lines in the destination image, in bytes |
(0, INT_MAX] |
Input |
roiSize |
Size of the ROI of the source and destination images, in pixels |
roiSize.width ∈ (0, INT_MAX], roiSize.height ∈ (0, INT_MAX] |
Input |
maskSize |
Mask size |
maskSize.width ≥ 3 (odd number), maskSize.height ≥ 3 (odd number) |
Input |
borderType |
Border type |
The value is one of the following enumerated values of HmppiBorderType: HMPPI_BORDER_CONST HMPPI_BORDER_REPL HMPPI_BORDER_MIRROR |
Input |
borderValue |
Constant value of the constant border pixel. This parameter is valid only when borderType is set to HMPPI_BORDER_CONST. |
Value within the data type range |
Input |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The value of pSrc or pDst is NULL. |
HMPP_STS_SIZE_ERR |
The value of roiSize.width or roiSize.height is less than or equal to 0. |
HMPP_STS_STEP_ERR |
The value of srcStep or dstStep is less than or equal to 0. |
HMPP_STS_ROI_ERR |
The result of roiSize.width x Number of bytes occupied by the data type is greater than the step. |
HMPP_STS_NOT_EVEN_STEP_ERR |
The value of srcStep or dstStep cannot be exactly divided by the byte length of the data type to which src or dst belongs. |
HMPP_STS_BAD_ARG_ERR |
The value of borderType or maskSize is not supported. |
Example
#include <stdio.h>
#include "hmppi.h"
#include "hmpp_type.h"
#define SRC_BUFFER_SIZE_T 28
#define DST_BUFFER_SIZE_T 16
int MedianBorderExample()
{
HmppiSize roi = { 4, 4 };
const int16_t src[SRC_BUFFER_SIZE_T] = { 13, 17, 5, -1, 9, -8, 44, -23, -5, 1, 7, 54, 75, -32, -9, -10, 11, -5, 15, -33, 7, -45, 112, 99, -45, 28, 64, 60};
int16_t dst[DST_BUFFER_SIZE_T] = {0};
int32_t srcStep = 4 * sizeof(int16_t);
int32_t dstStep = 4 * sizeof(int16_t);
HmppiSize mskSize = {3, 3};
HmppResult result = HMPPI_FilterMedianBorder_16s_C1R(src, srcStep, dst, dstStep, roi, mskSize, HMPPI_BORDER_CONST, -1);
if (result != HMPP_STS_NO_ERR) {
printf("result error: %d\n", result);
} else {
printf("result: %d\n", (int)result);
}
printf("dst= ");
for(int32_t i = 0; i < DST_BUFFER_SIZE_T; i++){
printf("%d ",dst[i]);
}
printf("\n");
return 0;
}
int main() {
MedianBorderExample();
return 0;
}
Output:
result: 0 dst= -1 5 -1 -1 -1 7 5 -1 -1 1 -8 -1 -1 -1 -1 -1