Rate This Document
Findability
Accuracy
Completeness
Readability

ResizeCubic

Adjusts the image size using the two-parameter cubic interpolation algorithm.

Before calling the ResizeCubic function, you need to call Init for initialization, call the main function of the ResizeCubic function, and then call Release to release the related space.

The function interface is declared as follows:

  • Initialization function:

    HmppResult HMPPI_ResizeCubicInit_32f(HmppiSize srcSize, HmppiSize dstSize, float B, float C, HmppiResizePolicy_32f** pSpec);

  • Main function:

    HmppResult HMPPI_ResizeCubic_32f_C1R(const float* pSrc, int32_t srcStep, float* pDst, int32_t dstStep, HmppiPoint dstOffset, HmppiSize dstSize, HmppiBorderType border, const float* pBorderValue, const HmppiResizePolicy_32f* pSpec);

  • Release function:

    HmppResult HMPPI_ResizeCubicRelease_32f(HmppiResizePolicy_32f *policy);

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

srcSize

Size of the source image block

Positive integer

Input

pDst

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

dstOffset

Offset of the destination image block

The value must be zero or a positive integer.

Input

dstSize

Size of the destination image block

Positive integer

Input

B

First parameter of the cubic filter

Real number

Input

C

Second parameter of the cubic filter

Real number

Input

border

Border handling algorithm

The following algorithms are supported:

HMPPI_BORDER_REPL

HMPPI_BORDER_MIRROR

HMPPI_BORDER_MIRROR_R

Input

borderValue

Border value

Border value when border is set to HMPPI_BORDER_CONST

Input

pSpec

Pointer to the special structure

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_NO_OPERATION

This is an alarm and no operation is performed. The width or height in srcSize and dstSize is 0.

HMPP_STS_NULL_PTR_ERR

A null pointer exists.

HMPP_STS_MALLOC_FAILED

Failed to allocate memory during policy initialization.

HMPP_STS_SIZE_ERR

The width or height in srcSize and dstSize is a negative value.

Alternatively, the value of srcSize is less than 2 x 2.

HMPP_STS_BORDER_ERR

The specified border algorithm type is not supported.

HMPP_STS_STEP_ERR

  • srcStep or dstStep is not an integer multiple of the float byte length.
  • srcStep or dstStep is less than the product of the float byte length and srcwidth or dstwidth.

HMPP_STS_OUT_OF_RANGE_ERR

The offset of the destination image block is greater than the width or height of the destination image block input by the Init function.

HMPP_STS_SIZE_WRN

The width or height of the destination image block is greater than the width or height of the destination image block input by the Init function.

Example

void ResizeCubicExample()
{
    HmppiSize srcSize = {4, 4};
    HmppiSize dstSize = {6, 6};
    HmppiPoint dstOffset = {0, 0};
    int srcStep = srcSize.width * sizeof(float);
    int dstStep = dstSize.width * sizeof(float);
    HmppiResizePolicy_32f *pSpec; 
    float pSrc[] = {0.0, 255.0, 3.0, 6.0, 255.0, 0.0, 2.0, 1.0, 3.0,
            0.0, 255.0, 3.0, 6.0, 255.0, 0.0, 2.0};
    int dstLen = dstSize.width * dstSize.height;
    float *pDst = HMPPS_Malloc_32f(dstLen);
    double B = 0.5;
    double C = 0.5;
    HmppResult result = HMPPI_ResizeCubicInit_32f(srcSize, dstSize, B, C, &pSpec);
    HmppiBorderType border = HMPPI_BORDER_REPL;
    float borderValue = pSrc[0];
    result = HMPPI_ResizeCubic_32f_C1R(pSrc, srcStep, pDst, dstStep, dstOffset, dstSize, border, &borderValue, pSpec);
 
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    for (int i = 0; i < dstLen; i++){
        printf("%f ", pDst[i]);
    }
    printf("\n");
    HMPPI_ResizeCubicRelease_32f(pSpec);
}

Output:

result = 0
-4.966425 140.752594 205.351364 60.469444 -8.723660 6.077533 140.751587 141.259216 97.576118 18.680174 -10.837348 3.531568 205.383133 95.673416 7.140303 43.515594 33.608219 0.835248 60.508411 16.424671 41.026234 159.661621 113.710358 0.589375 -9.937934 58.751194 133.184296 140.705246 72.326935 1.272445 3.603872 145.281662 204.080536 56.064888 -13.772015 2.033274