FilterSobelBorder
Applies the Sobel 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 filter kernel is a 3x3 or 5x5 matrix mask specified by an input parameter. The kernel has the following values, with the anchor located in the center cell.
1 2 1
0 0 0
-1 -2 -1
1 4 6 4 1
2 8 12 8 2
0 0 0 0 0
-2 -8 -12 -8 -2
-1 -4 -6 -4 -1
The function is declared as follows:
HmppResult HMPPI_FilterSobelHorizBorder_32f_C1R(const float* pSrc, int srcStep, float* pDst, int dstStep, HmppiSize roi, HmppiMaskSize maskSize, HmppiBorderType borderType, float borderValue);
HmppResult HMPPI_FilterSobelNegVertBorder_32f_C1R(const float* pSrc, int srcStep, float* pDst, int dstStep, HmppiSize roi, HmppiMaskSize maskSize, HmppiBorderType borderType, float 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 |
Predefined mask |
HmppMskSize3x3 or HmppMskSize5x5 |
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 SobelBorderExample()
{
HmppiSize roi = { 2, 4 };
const float src[SRC_BUFFER_SIZE_T] = { 9.8375815e-16, 4.5484828e-16, 1.4972698e-14, -1.3397389e+25, 1.9061152e+27, -8.8007769e+17, -217025.86, -6.2768196e+14, 4.4335606e+33, 1.0258707e-13, -9.3150633e-11, -5192.7163, 2.536292e+25, 6.0832354e+15, 8.5712402e+29, -0.15451884, -0.2848247, -2.1714717e+10, 2.7212473e+17, -1.3591454e-22, 7.6473188e+21, -2.2729285e-30, 1129877.1, -1.0089557e-05, -1.1054221e+21, -3.8945858e-19, -6.8345717e-34, 60685416};
float dst[DST_BUFFER_SIZE_T] = {0};
int32_t srcStep = 4 * sizeof(int16_t);
int32_t dstStep = 4 * sizeof(int16_t);
HmppiMaskSize mskSize = HmppMskSize3x3;
HmppResult result = HMPPI_FilterSobelHorizBorder_32f_C1R(src, srcStep, dst, dstStep, roi, mskSize, HMPPI_BORDER_CONST, 0);
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("%e ",dst[i]);
}
printf("\n");
return 0;
}
int main() {
SobelBorderExample();
return 0;
}
Output:
result: 0 dst= -1.339739e+25 -2.679478e+25 3.812230e+27 1.906115e+27 1.339739e+25 2.679478e+25 -3.812230e+27 -1.906115e+27 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00