Intel® Integrated Performance Primitives Developer Guide and Reference

ID 790148
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

QualityIndex

Computes the universal image quality index.

Syntax

Case 1: Operation on one-channel data

IppStatus ippiQualityIndex_<mod>(const Ipp<srcDatatype>* pSrc1, int src1Step, const Ipp<srcDatatype>* pSrc2, int src2Step, IppiSize roiSize, Ipp<dstDatatype> pQualityIndex[1], Ipp8u* pBuffer);

Supported values for mod:

8u32f_C1R

16u32f_C1R

32f_C1R

Case 2: Operation on multi-channel data

IppStatus ippiQualityIndex_<mod>(const Ipp<srcDatatype>* pSrc1, int src1Step, const Ipp<srcDatatype>* pSrc2, int src2Step, IppiSize roiSize, Ipp<dstDatatype> pQualityIndex[3], Ipp8u* pBuffer);

Supported values for mod:

8u32f_C3R

16u32f_C3R

32f_C3R

8u32f_AC4R

16u32f_AC4R

32f_AC4R

Include Files

ippi.h

Domain Dependencies

Headers: ippcore.h, ippvm.h, ipps.h

Libraries: ippcore.lib, ippvm.lib, ipps.lib

Parameters

pSrc1, pSrc2

Pointers to the source images ROI.

src1Step, src2Step

Distance in bytes between starts of consecutive lines in the source images.

roiSize

Size of the source ROI in pixels.

pQualityIndex

Pointer to the computed quality index value.

pBuffer

Pointer to the buffer for internal calculations. To compute the size of the buffer, use the QualityIndexGetBufferSize function.

Description

This function operates with ROI (see Regions of Interest in Intel IPP). This function computes the universal image quality index for two images pSrc1 and pSrc2 according to the formula in the introduction section above. The computed value of the index is stored in pQualityIndex.

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error or a warning.

ippStsNullPtrErr

Indicates an error when any of the specified pointers is NULL.

ippStsSizeErr

Indicates an error condition if roiSize has a field with zero or negative value.

ippStsStepErr

Indicates an error condition if src1Step or src2Step has a zero or negative value.

ippStsQualityIndexErr

Indicates an error condition if pixel values of one of the images are constant.

ippStsMemAllocErr

Indicates an error condition if memory allocation fails.

Example

/*******************************************************************************
* Copyright 2015 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/

//    A simple example of computing the universal image quality index for two images.
// implemented with Intel(R) Integrated Primitives (Intel(R) IPP) functions:
//     ippiImageJaehne_32f_C1R
//     ippiImageJaehne_32f_C1R
//     ippiAddRandUniform_32f_C1IR
//     ippiQualityIndexGetBufferSize
//     ippiQualityIndex_32f_C1R

#include <stdio.h>
#include "ipp.h"

/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine:                                  /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */

/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status  */

int main(void)
{
    IppStatus status = ippStsNoErr;
    /* Pointers to source images */
    Ipp32f pSrc1[256*256];
    Ipp32f pSrc2[256*256];
    /* Distance in bytes between starts of consecutive lines in the source images */
    int src1Step = 256*sizeof(Ipp32f);
    int src2Step = 256*sizeof(Ipp32f);
    Ipp32f qIndex = 0;  /* quality index value */
    IppiSize roiSize = {256,256};
    unsigned int pSeed = 3;
    int bufSize = 0;        /* work buffer size */
    Ipp8u *pBuffer = NULL;  /* pointer to the work buffer */

    /* create reference image (image1) */
    check_sts( status = ippiImageJaehne_32f_C1R( pSrc1, src1Step, roiSize ) )

    /* ... and distorted image (image2 = image1 + RandUniform) */
    check_sts( status = ippiImageJaehne_32f_C1R( pSrc2, src2Step, roiSize ) )

    check_sts( status = ippiAddRandUniform_32f_C1IR(pSrc2, src2Step, roiSize, 0, 1, &pSeed) )

    check_sts( status = ippiQualityIndexGetBufferSize( ipp32f, ippC1, roiSize, &bufSize ) )

    /* work buffer memory allocation */
    pBuffer = (Ipp8u*)ippMalloc( bufSize );

    /* computes the universal image quality index for two images pSrc1 and pSrc2 */
    check_sts( status = ippiQualityIndex_32f_C1R( pSrc1, src1Step, pSrc2, src2Step, roiSize, &qIndex, pBuffer ) )

EXIT_MAIN
    ippFree( pBuffer );
    printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
    return (int)status;
}


See Also