Rate This Document
Findability
Accuracy
Completeness
Readability

Threshold_GTVal

Performs thresholding on pixels in an image. This function changes pixel values that are greater than the threshold to a specified value. If the comparison condition is met, the corresponding output pixel is set to the value of value. Otherwise, the output pixel value is not changed or set. For images with multi-channel data, you need to set comparison conditions for each channel.

The formula is as follows:

The function interface declaration is as follows:

  • Thresholding for single-channel data:

    HmppResult HMPPI_Threshold_GTVal_8u_C1R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, uint8_t threshold, uint8_t value);

    HmppResult HMPPI_Threshold_GTVal_16u_C1R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, uint16_t threshold, uint16_t value);

    HmppResult HMPPI_Threshold_GTVal_16s_C1R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep, HmppiSize roiSize, int16_t threshold, int16_t value);

    HmppResult HMPPI_Threshold_GTVal_32f_C1R(const float *src, int32_t srcStep, float *dst, int32_t dstStep, HmppiSize roiSize, float threshold, float value);

  • Thresholding for multi-channel data:

    HmppResult HMPPI_Threshold_GTVal_8u_C3R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, const uint8_t threshold[3], const uint8_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_16u_C3R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, const uint16_t threshold[3], const uint16_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_16s_C3R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep, HmppiSize roiSize, const int16_t threshold[3], const int16_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_32f_C3R(const float *src, int32_t srcStep, float *dst, int32_t dstStep, HmppiSize roiSize, const float threshold[3], const float value[3]);

    HmppResult HMPPI_Threshold_GTVal_8u_AC4R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, const uint8_t threshold[3], const uint8_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_16u_AC4R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, const uint16_t threshold[3], const uint16_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_16s_AC4R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep, HmppiSize roiSize, const int16_t threshold[3], const int16_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_32f_AC4R(const float *src, int32_t srcStep, float *dst, int32_t dstStep, HmppiSize roiSize, const float threshold[3], const float value[3]);

    HmppResult HMPPI_Threshold_GTVal_8u_C4R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, const uint8_t threshold[4], const uint8_t value[4]);

    HmppResult HMPPI_Threshold_GTVal_16u_C4R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, const uint16_t threshold[4], const uint16_t value[4]);

    HmppResult HMPPI_Threshold_GTVal_16s_C4R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep, HmppiSize roiSize, const int16_t threshold[4], const int16_t value[4]);

    HmppResult HMPPI_Threshold_GTVal_32f_C4R(const float *src, int32_t srcStep, float *dst, int32_t dstStep, HmppiSize roiSize, const float threshold[4], const float value[4]);

  • In-place thresholding for single-channel data:

    HmppResult HMPPI_Threshold_GTVal_8u_C1IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, uint8_t threshold, uint8_t value);

    HmppResult HMPPI_Threshold_GTVal_16u_C1IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, uint16_t threshold, uint16_t value);

    HmppResult HMPPI_Threshold_GTVal_16s_C1IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, int16_t threshold, int16_t value);

    HmppResult HMPPI_Threshold_GTVal_32f_C1IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize, float threshold, float value);

  • In-place thresholding for multi-channel data:

    HmppResult HMPPI_Threshold_GTVal_8u_C3IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint8_t threshold[3], const uint8_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_16u_C3IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint16_t threshold[3], const uint16_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_16s_C3IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const int16_t threshold[3], const int16_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_32f_C3IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize, const float threshold[3], const float value[3]);

    HmppResult HMPPI_Threshold_GTVal_8u_AC4IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint8_t threshold[3], const uint8_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_16u_AC4IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint16_t threshold[3], const uint16_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_16s_AC4IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const int16_t threshold[3], const int16_t value[3]);

    HmppResult HMPPI_Threshold_GTVal_32f_AC4IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize, const float threshold[3], const float value[3]);

    HmppResult HMPPI_Threshold_GTVal_8u_C4IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint8_t threshold[4], const uint8_t value[4]);

    HmppResult HMPPI_Threshold_GTVal_16u_C4IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint16_t threshold[4], const uint16_t value[4]);

    HmppResult HMPPI_Threshold_GTVal_16s_C4IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const int16_t threshold[4], const int16_t value[4]);

    HmppResult HMPPI_Threshold_GTVal_32f_C4IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize, const float threshold[4], const float value[4]);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source image ROI

The value cannot be NULL.

Input

srcStep

Distance between starts of consecutive lines in the source image, in bytes

The value must be zero or a positive integer.

Input

dst

Pointer to the destination image ROI

The value cannot be NULL.

Input/Output

dstStep

Distance between starts of consecutive lines in the destination image, in bytes

The value must be zero or a positive integer.

Input

srcDst

Pointer to the ROI of the source and destination image (for in-place operations)

The value cannot be NULL.

Input/Output

srcDstStep

Distance between starts of consecutive lines in the source and destination image (in-place operations), in bytes

The value must be zero or a positive integer.

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

Threshold

Threshold value used by each pixel. In the case of multi-channel data, an array of threshold values for each color channel is used.

Range of the input data type

Input

Value

Output pixel value for each pixel that satisfies the "greater than" comparison condition. In the case of multi-channel data, an array of values is used.

Range of the input data type

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 src, dst, or srcDst is NULL.

HMPP_STS_SIZE_ERR

The value of roiSize is 0 or negative.

HMPP_STS_STEP_ERR

The value of srcStep, dstStep, or srcDstStep is zero or negative.

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_ROI_ERR

The value of roiSize.width is greater than the step.

HMPP_STS_NO_ERR

No error occurs.

Example

#define BUFFER_SIZE_T 36
int ThresholGTValExample()
{
    HmppiSize roi = { 2, 4 };
    int16_t srcDst[BUFFER_SIZE_T] = { 1, 2, 4, 8, 16, 8, 4, 2, 1,
                            1, 2, 4, 8, 16, 8, 4, 2, 1,
                            1, 2, 4, 8, 16, 8, 4, 2, 1,
                            1, 2, 4, 8, 16, 8, 4, 2, 1};
    int16_t threshold[3] = {8, 8, 8};
    int16_t value[3] = { 6, 6, 6 };
    int srcDstStep = 9 * sizeof(int16_t);
    HmppResult result = HMPPI_Threshold_GTVal_16s_AC4IR(srcDst, srcDstStep, roi, threshold, value);

    printf("result = %d \n dst = ", result);
    if (result != HMPP_STS_NO_ERR) {
        printf("result error: %d\n", result);
    }

    int dstWidth = srcDstStep / sizeof(int16_t);
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 9; j++) {
            printf("%4d ", srcDst[i * dstWidth + j]);
        }
        printf("\n");
    }
    return 0;
}

Output:

 result = 0
 dst =  1    2    4    8    6    8    4    2    1
        1    2    4    8    6    8    4    2    1
        1    2    4    8    6    8    4    2    1
        1    2    4    8    6    8    4    2    1