Threshold_LT
Compares pixel values in an image with the specified threshold and changes pixel values less than the threshold to the threshold.
This operation uses the comparison for "greater than", that is, level is the lower boundary of the source vector. The calculation formula is as follows:

The function interface declaration is as follows:
- Thresholding for single-channel data:
HmppResult HMPPI_Threshold_LT_8u_C1R(const uint8_t* src, int32_t srcStep, uint8_t* dst, int32_t dstStep, HmppiSize roiSize, uint8_t threshold);
HmppResult HMPPI_Threshold_LT_16u_C1R(const uint16_t* src, int32_t srcStep, uint16_t* dst, int32_t dstStep, HmppiSize roiSize, uint16_t threshold);
HmppResult HMPPI_Threshold_LT_16s_C1R(const int16_t* src, int32_t srcStep, int16_t* dst, int32_t dstStep, HmppiSize roiSize, int16_t threshold);
HmppResult HMPPI_Threshold_LT_32f_C1R(const float* src, int32_t srcStep, float* dst, int32_t dstStep, HmppiSize roiSize, float threshold);
- Thresholding for multi-channel data:
HmppResult HMPPI_Threshold_LT_8u_C3R(const uint8_t *src, int32_t srcStep, uint8_t*dst, int32_t dstStep, HmppiSize roiSize, const uint8_t threshold[3]);
HmppResult HMPPI_Threshold_LT_16u_C3R(const uint16_t *src, int32_t srcStep, uint16_t*dst, int32_t dstStep, HmppiSize roiSize, const uint16_t threshold[3]);
HmppResult HMPPI_Threshold_LT_16s_C3R(const int16_t *src, int32_t srcStep, int16_t*dst, int32_t dstStep, HmppiSize roiSize, const int16_t threshold[3]);
HmppResult HMPPI_Threshold_LT_32f_C3R(const float *src, int32_t srcStep, float*dst, int32_t dstStep, HmppiSize roiSize, const float threshold[3]);
HmppResult HMPPI_Threshold_LT_8u_AC4R(const uint8_t *src, int32_t srcStep, uint8_t*dst, int32_t dstStep, HmppiSize roiSize, const uint8_t threshold[3]);
HmppResult HMPPI_Threshold_LT_16u_AC4R(const uint16_t *src, int32_t srcStep, uint16_t*dst, int32_t dstStep, HmppiSize roiSize, const uint16_t threshold[3]);
HmppResult HMPPI_Threshold_LT_16s_AC4R(const int16_t *src, int32_t srcStep, int16_t*dst, int32_t dstStep, HmppiSizeroiSize, const int16_t threshold[3]);
HmppResult HMPPI_Threshold_LT_32f_AC4R(const float *src, int32_t srcStep, float*dst, int32_t dstStep, HmppiSizeroiSize, const float threshold[3]);
- In-place thresholding for single-channel data:
HmppResult HMPPI_Threshold_LT_8u_C1IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, uint8_t threshold);
HmppResult HMPPI_Threshold_LT_16u_C1IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, uint16_t threshold);
HmppResult HMPPI_Threshold_LT_16s_C1IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, int16_t threshold);
HmppResult HMPPI_Threshold_LT_32f_C1IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize, float threshold);
- In-place thresholding for multi-channel data:
HmppResult HMPPI_Threshold_LT_8u_C3IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint8_t threshold[3]);
HmppResult HMPPI_Threshold_LT_16u_C3IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint16_t threshold[3]);
HmppResult HMPPI_Threshold_LT_16s_C3IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const int16_t threshold[3]);
HmppResult HMPPI_Threshold_LT_32f_C3IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize, const float threshold[3]);
HmppResult HMPPI_Threshold_LT_8u_AC4IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint8_t threshold[3]);
HmppResult HMPPI_Threshold_LT_16u_AC4IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const uint16_t threshold[3]);
HmppResult HMPPI_Threshold_LT_16s_AC4IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize, const int16_t threshold[3]);
HmppResult HMPPI_Threshold_LT_32f_AC4IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize, const float threshold[3]);
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 cannot be NULL. |
Input |
dst |
Pointer to the destination image ROI |
The value cannot be NULL. |
Output |
dstStep |
Distance between starts of consecutive lines in the destination image, in bytes |
The value is greater than 0. |
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 is greater than 0. |
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. |
It can be any value. |
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 width or height of roiSize is zero 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 |
roiSize.width > Step |
Example
#define BUFFER_SIZE_T 52
int ThresholdLTExample(){
HmppiSize roi = {4,3};
uint8_t src[BUFFER_SIZE_T] = { 1, 4, 8, 13, 16, 20, 24, 28, 32, 36, 40, 44, 48,
1, 4, 8, 13, 16, 20, 24, 28, 32, 36, 40, 44, 48,
1, 4, 8, 13, 16, 20, 24, 28, 32, 36, 40, 44, 48,
1, 4, 8, 13, 16, 20, 24, 28, 32, 36, 40, 44, 48};
uint8_t dst[BUFFER_SIZE_T] = {0};
uint8_t threshold[3] = {18,30,35};
int32_t srcStep=13*sizeof(uint8_t);
int32_t dstStep=13*sizeof(uint8_t);
HmppResult result = HMPPI_Threshold_LT_8u_C3R(src, srcStep, dst, dstStep, roi, threshold);
printf("result = %d \ndst =", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
for (int i = 0; i < 4; i++){
for (int j = 0; j < 13; j++){
printf("%4d ", dst[i * 13 + j]);
}
printf("\n");
}
return 0;
}
Output:
result = 0
dst = 18 30 35 18 30 35 24 30 35 36 40 44 0
18 30 35 18 30 35 24 30 35 36 40 44 0
18 30 35 18 30 35 24 30 35 36 40 44 0
0 0 0 0 0 0 0 0 0 0 0 0 0