Rate This Document
Findability
Accuracy
Completeness
Readability

Mean_StdDev

Calculates the mean value and standard deviation of image pixel values.

The function interface is declared as follows:

  • Mean value and standard deviation of a single channel:

    HmppResult HMPPI_Mean_StdDev_32f_C1R(const float* pSrc, int srcStep, HmppiSize roiSize, double* pMean, double* pStdDev);

Parameters

Parameter

Description

Value Range

Input/Output

pSrc

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

roiSize

Size of the ROI of the source and destination images, in pixels

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

Input

pMean

Pointer to the mean value of the pixel values

The value cannot be NULL.

Input/Output

pStdDev

Pointer to the standard deviation of the pixel values

The value cannot be NULL.

Input/Output

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 is NULL.

HMPP_STS_SIZE_ERR

The width or height of roiSize is 0 or negative.

HMPP_STS_STEP_ERR

The value of srcStep is 0 or negative.

HMPP_STS_NOT_EVEN_STEP_ERR

The value of srcStep cannot be exactly divided by the byte length of the data type to which src belongs.

Example

void Mean_StdDevExample()
{
    HmppiSize roiSize = {3, 3};
    float pSrc[] = {1.0, 2.0, 3.0,
                    4.0, 5.0, 6.0,
                    7.0, 8.0, 9.0};
    double pMean, pStdDev; 
    int srcStep = roiSize.width * sizeof(float);
    HmppResult result = HMPPI_Mean_StdDev_32f_C1R(pSrc, srcStep, roiSize, &pMean, &pStdDev);
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    printf("%lf %lf\n", pMean, pStdDev);
}

Output:

result = 0
5.000000 2.581989