Threshold_GTVal
对图像中的像素进行阈值处理,阈值函数根据图像像素值是否大于阈值来更改像素值。如果输入像素值满足大于阈值条件,则将相应的输出像素设置为参数value的值,否则它不会更改或设置输出像素值。对于具有多通道数据的图像,应分别为每个通道设置比较条件。
计算公式如下:
函数接口声明如下:
- 单通道数据的阈值操作:
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);
- 多通道数据的阈值操作:
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]);
- 单通道数据的原址阈值操作:
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);
- 多通道数据的原址阈值操作:
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]);
参数
参数名 |
描述 |
取值范围 |
输入/输出 |
---|---|---|---|
src |
指向源图像感兴趣区域的指针。 |
非空。 |
输入 |
srcStep |
源图像中连续行起点之间的距离(以字节为单位)。 |
非负整数。 |
输入 |
dst |
指向目标图像感兴趣区域的指针。 |
非空。 |
输入、输出 |
dstStep |
目标图像中连续行的起点之间的距离(以字节为单位)。 |
非负整数。 |
输入 |
srcDst |
指向源和目标图像感兴趣区域的指针(用于原址操作)。 |
非空。 |
输入、输出 |
srcDstStep |
原址操作的源图像和目标图像中连续行起点之间的距离(以字节为单位)。 |
非负整数。 |
输入 |
roiSize |
源和目标图像感兴趣区域的大小(以像素为单位)。 |
roiSize.width∈(0, INT_MAX],roiSize.height∈(0, INT_MAX] |
输入 |
Threshold |
每个像素要使用的阈值水平值;多通道数据下,使用每个颜色通道的阈值数组。 |
输入数据类型的范围。 |
输入 |
Value |
像素值与相应阈值进行比较,满足大于阈值条件时,输出像素取值。多通道下使用value值数组。 |
输入数据类型的范围。 |
输入 |
返回值
- 成功:返回HMPP_STS_NO_ERR。
- 失败:返回错误码。
错误码
错误码 |
描述 |
---|---|
HMPP_STS_NULL_PTR_ERR |
src、dst、srcDst中存在空指针。 |
HMPP_STS_SIZE_ERR |
roiSize的字段为零或负值。 |
HMPP_STS_STEP_ERR |
srcStep、dstStep、srcDstStep中存在零或负值。 |
HMPP_STS_NOT_EVEN_STEP_ERR |
srcStep、dstStep不能被src、dst所属数据类型的字节长度整除的错误条件。 |
HMPP_STS_ROI_ERR |
roiSize.width大于步长。 |
HMPP_STS_NO_ERR |
返回值正确,任何其他值表示错误或警告。 |
示例
#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; }
运行结果:
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