中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

Threshold_LTValGTVal

对图像中的像素进行阈值处理,阈值函数根据图像像素值是小于较低阈值还是大于较高阈值,将相应的输出像素设置为低或高的输出值,否则它不会更改或设置输出像素值。对于具有多通道数据的图像,应分别为每个通道设置比较条件。

计算公式如下:

函数接口声明如下:

  • 单通道数据的阈值操作:

    HmppResult HMPPI_Threshold_LTValGTVal_8u_C1R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, uint8_t thresholdLT, uint8_t valueLT, uint8_t thresholdGT, uint8_t valueGT);

    HmppResult HMPPI_Threshold_LTValGTVal_16u_C1R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, uint16_t thresholdLT, uint16_t valueLT, uint16_t thresholdGT, uint16_t valueGT);

    HmppResult HMPPI_Threshold_LTValGTVal_16s_C1R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep, HmppiSize roiSize, int16_t thresholdLT, int16_t valueLT, int16_t thresholdGT, int16_t valueGT);

    HmppResult HMPPI_Threshold_LTValGTVal_32f_C1R(const float *src, int32_t srcStep, float *dst, int32_t dstStep, HmppiSize roiSize, float thresholdLT, float valueLT, float thresholdGT, float valueGT);

  • 多通道数据的阈值操作:

    HmppResult HMPPI_Threshold_LTValGTVal_8u_C3R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, const uint8_t thresholdLT[3], const uint8_t valueLT[3], const uint8_t thresholdGT[3], const uint8_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_16u_C3R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep, HmppiSize roiSize, const uint16_t thresholdLT[3], const uint16_t valueLT[3], const uint16_t thresholdGT[3], const uint16_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_16s_C3R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep HmppiSize roiSize, const int16_t thresholdLT[3], const int16_t valueLT[3] const int16_t thresholdGT[3], const int16_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_32f_C3R(const float *src, int32_t srcStep, float *dst, int32_t dstStep HmppiSize roiSize, const float thresholdLT[3], const float valueLT[3] const float thresholdGT[3], const float valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_8u_AC4R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep HmppiSize roiSize, const uint8_t thresholdLT[3], const uint8_t valueLT[3] const uint8_t thresholdGT[3], const uint8_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_16u_AC4R(const uint16_t *src, int32_t srcStep, uint16_t *dst, int32_t dstStep HmppiSize roiSize, const uint16_t thresholdLT[3] const uint16_t valueLT[3], const uint16_t thresholdGT[3] const uint16_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_16s_AC4R(const int16_t *src, int32_t srcStep, int16_t *dst, int32_t dstStep HmppiSize roiSize, const int16_t thresholdLT[3] const int16_t valueLT[3], const int16_t thresholdGT[3] const int16_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_32f_AC4R(const float *src, int32_t srcStep, float *dst, int32_t dstStep HmppiSize roiSize, const float thresholdLT[3], const float valueLT[3] const float thresholdGT[3], const float valueGT[3]);

  • 单通道数据的原址阈值操作:

    HmppResult HMPPI_Threshold_LTValGTVal_8u_C1IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize uint8_t thresholdLT, uint8_t valueLT, uint8_t thresholdGT uint8_t valueGT);

    HmppResult HMPPI_Threshold_LTValGTVal_16u_C1IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize uint16_t thresholdLT, uint16_t valueLT, uint16_t thresholdGT uint16_t valueGT);

    HmppResult HMPPI_Threshold_LTValGTVal_16s_C1IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize int16_t thresholdLT, int16_t valueLT, int16_t thresholdGT int16_t valueGT);

    HmppResult HMPPI_Threshold_LTValGTVal_32f_C1IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize float thresholdLT, float valueLT, float thresholdGT, float valueGT);

  • 多通道数据的原址阈值操作:

    HmppResult HMPPI_Threshold_LTValGTVal_8u_C3IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize const uint8_t thresholdLT[3], const uint8_t valueLT[3] const uint8_t thresholdGT[3], const uint8_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_16u_C3IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize const uint16_t thresholdLT[3], const uint16_t valueLT[3] const uint16_t thresholdGT[3], const uint16_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_16s_C3IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize const int16_t thresholdLT[3], const int16_t valueLT[3] const int16_t thresholdGT[3], const int16_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_32f_C3IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize const float thresholdLT[3], const float valueLT[3] const float thresholdGT[3], const float valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_8u_AC4IR(uint8_t *srcDst, int32_t srcDstStep, HmppiSize roiSize const uint8_t thresholdLT[3], const uint8_t valueLT[3] const uint8_t thresholdGT[3], const uint8_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_16u_AC4IR(uint16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize const uint16_t thresholdLT[3], const uint16_t valueLT[3] const uint16_t thresholdGT[3], const uint16_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_16s_AC4IR(int16_t *srcDst, int32_t srcDstStep, HmppiSize roiSize const int16_t thresholdLT[3], const int16_t valueLT[3] const int16_t thresholdGT[3], const int16_t valueGT[3]);

    HmppResult HMPPI_Threshold_LTValGTVal_32f_AC4IR(float *srcDst, int32_t srcDstStep, HmppiSize roiSize const float thresholdLT[3], const float valueLT[3] const float thresholdGT[3], const float valueGT[3]);

参数

参数名

描述

取值范围

输入/输出

src

指向源图像感兴趣区域的指针。

非空。

输入

srcStep

源图像中连续行起点之间的距离(以字节为单位)。

非负整数。

输入

dst

指向目标图像感兴趣区域的指针。

非空。

输出

dstStep

目标图像中连续行的起点之间的距离(以字节为单位)。

非负整数。

输入

srcDst

指向源和目标图像感兴趣区域的指针(用于原址操作)。

非空。

输入、输出

srcDstStep

原址操作的源图像和目标图像中连续行起点之间的距离(以字节为单位)。

非负整数。

输入

roiSize

源和目标图像感兴趣区域的大小(以像素为单位)。

roiSize.width∈(0, INT_MAX],roiSize.height∈(0, INT_MAX]

输入

thresholdLT

每个像素要使用的较低阈值。

输入数据类型的范围。

输入

valueLT

像素值小于较低阈值时,设定的较低输出值。

非负整数。

输入

thresholdGT

每个像素要使用的较高阈值。

输入数据类型的范围。

输入

valueGT

像素值大于较大阈值时,设定的较高输出值。

非负整数。

输入

返回值

  • 成功:返回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_THRESHOLD_ERR

thresholdLT小于thresholdGT。

HMPP_STS_NO_ERR

返回值正确,任何其他值表示错误或警告。

示例

#define BUFFER_SIZE_T 36
int ThresholdLTValGTValExample()
{
    HmppiSize roi = { 3, 4 };
    uint16_t src[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};
    uint16_t dst[BUFFER_SIZE_T] = {0};
    uint16_t thresholdLT[3] = {2, 2, 2};
    uint16_t valueLT[3] = {3, 3, 3};
    uint16_t thresholdGT[3] = {9, 9, 9};
    uint16_t valueGT[3] = {8, 8, 8};
    int srcStep = 9 * sizeof(uint16_t);
    int dstStep = 9 * sizeof(uint16_t);
    HmppResult result = HMPPI_Threshold_LTValGTVal_16u_C3R(src, srcStep, dst, dstStep, roi, thresholdLT, valueLT, thresholdGT, valueGT);
    printf("result = %d \n dst = ", result);
    if (result != HMPP_STS_NO_ERR) {
        printf("result error: %d\n", result);
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 9; j++) {
            printf("%4d ", dst[i * 9 + j]);
        }
        printf("\n");
    }
    return 0;
}

运行结果:

result = 0
dst =    3    2    4    8    8    8    4    2    3
         3    2    4    8    8    8    4    2    3
         3    2    4    8    8    8    4    2    3
         3    2    4    8    8    8    4    2    3