Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 3/22/2024
Public

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

Document Table of Contents

LUT

MODIFIED API. Maps an image by applying intensity transformation.

Syntax

Case 1: Not-in-place operation on one-channel integer data

IppStatus ippiLUT_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Supported values for mod:

8u_C1R 16u_C1R 16s_C1R

Case 2: Not-in-place operation on multi-channel integer data

IppStatus ippiLUT_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Supported values for mod:

8u_C3R 16u_C3R 16s_C3R
8u_AC4R 16u_AC4R 16s_AC4R

IppStatus ippiLUT_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Supported values for mod:

8u_C4R 16u_C4R 16s_C4R

Case 3: Not-in-place operation on one-channel floating-point data

IppStatus ippiLUT_32f_C1R(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Case 4: Not-in-place operation on multi-channel floating-point data

IppStatus ippiLUT_<mod>(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Supported values for mod:

32f_C3R
32f_AC4R

IppStatus ippiLUT_32f_C4R(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Case 5: In-place operation on one-channel integer data

IppStatus ippiLUT_<mod>(Ipp<datatype>* pSrcDst, int srcDstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Supported values for mod:

8u_C1IR 16u_C1IR 16s_C1IR

Case 6: In-place operation on multi-channel integer data

IppStatus ippiLUT_<mod>(Ipp<datatype>* pSrcDst, int srcDstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Supported values for mod:

8u_C3IR 16u_C3IR 16s_C3IR
8u_AC4IR 16u_AC4IR 16s_AC4IR

IppStatus ippiLUT_<mod>(Ipp<datatype>* pSrcDst, int srcDstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Supported values for mod:

8u_C4IR 16u_C4IR 16s_C4IR

Case 7: In-place operation on one-channel floating-point data

IppStatus ippiLUT_32f_C1IR(Ipp32f* pSrcDst, int srcDstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Case 8: In-place operation on multi-channel floating-point data

IppStatus ippiLUT_<mod>(Ipp32f* pSrcDst, int srcDstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Supported values for mod:

32f_C3IR
32f_AC4IR

IppStatus ippiLUT_32f_C4IR(Ipp32f* pSrcDst, int srcDstStep, IppiSize roiSize, IppiLUT_Spec* pSpec);

Include Files

ippi.h

Domain Dependencies

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

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

Parameters

pSrc

Pointer to the source image ROI.

srcStep

Distance, in bytes, between the starting points of consecutive lines in the source image.

pDst

Pointer to the destination image ROI.

dstStep

Distance, in bytes, between the starting points of consecutive lines in the destination image.

pSrcDst

Pointer to the source and destination mage ROI for the in-place operation.

srcDstStep

Distance, in bytes, between the starting points of consecutive lines in the source and destination image for the in-place operation.

roiSize

Size of the source ROI, in pixels.

pSpec

Pointer to the LUT specification structure.

Description

IMPORTANT:
The API of this function has been modified in Intel IPP 9.0 release.

This function operates with ROI (see Regions of Interest in Intel IPP).

Before using this function, you need to compute the size of the specification structure using the LUT_GetSize function and initialize the structure using LUT_Init.

This function performs intensity transformation of the source image pSrc using the lookup table (LUT) specified by the arrays pLevels, pValues, and interpolation type specified in the LUT_Init function when pSpec is initialized.

The figure below shows particular curves that are used in all the ippiLUT function flavors for mapping. The level values are 0, 64, 128, 192, 256; the intensity values are 20, 60, 160, 180, 230.



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 when roiSize has a field with a value less than 1.

ippStsStepErr

Indicates an error when srcStep, dstStep, or srcDstStep has a zero or negative value.

ippStsBadArgErr

Indicates an error when pSpec initialization is incorrect.

Example

The code example below demonstrates how to use LUT_GetSize, LUT_Init, and ippiLUT functions.

#include "ippcore.h"
#include "ippi.h"
#include <iostream>
#include <iomanip>

void func_LUTLinear()
{
    IppStatus status;
    Ipp32f pSrc[8 * 8];
    int srcStep = 8 * sizeof(Ipp32f);
    IppiSize roiSize = { 8, 8 };

    Ipp32f pDst[8 * 8];
    int dstStep = 8 * sizeof(Ipp32f);
    Ipp32f pLevels[5] = { 0.0, 0.128, 0.256, 0.512, 1.0 };
    const Ipp32f* ppLevels[1] = { pLevels };
    Ipp32f pValues[5] = { 0.2, 0.4, 0.6, 0.8, 1.0 };
    const Ipp32f* ppValues[1] = { pValues };
    int nLevels[1] = { 5 };
    int specSize;
    IppiLUT_Spec* pSpec;

    status = ippiImageJaehne_32f_C1R(pSrc, srcStep, roiSize);

    std::cout << "pSrc:\n";
    for (int row = 0; row < roiSize.height; row++) {
        for (int col = 0; col < roiSize.width; col++) {
            std::cout << std::fixed << std::setprecision(2) <<pSrc[roiSize.width * row + col] << "\t";
        }
        std::cout << "\n";
    }


    ippiLUT_GetSize(ippLinear, ipp32f, ippC1, roiSize, nLevels, &specSize);

    pSpec = (IppiLUT_Spec*)ippMalloc(specSize);

    ippiLUT_Init_32f(ippLinear, ippC1, roiSize, ppValues, ppLevels, nLevels, pSpec);
    status = ippiLUT_32f_C1R(pSrc, srcStep, pDst, dstStep, roiSize, pSpec);

    std::cout << "pDst:\n";
    for (int row = 0; row < roiSize.height; row++) {
        for (int col = 0; col < roiSize.width; col++) {
            std::cout << pDst[roiSize.width * row + col] << "\t";
        }
        std::cout << "\n";
    }

    ippFree(pSpec);
}

Result:

pSrc:
0.00 0.26 0.65 0.82 0.82 0.65 0.26 0.00
0.26 0.82 1.00 0.98 0.98 1.00 0.82 0.26
0.65 1.00 0.89 0.74 0.74 0.89 1.00 0.65
0.82 0.98 0.74 0.55 0.55 0.74 0.98 0.82
0.82 0.98 0.74 0.55 0.55 0.74 0.98 0.82
0.65 1.00 0.89 0.74 0.74 0.89 1.00 0.65
0.26 0.82 1.00 0.98 0.98 1.00 0.82 0.26
0.00 0.26 0.65 0.82 0.82 0.65 0.26 0.00

pDst:
0.20 0.61 0.85 0.93 0.93 0.85 0.61 0.20
0.61 0.93 1.00 0.99 0.99 1.00 0.93 0.61
0.85 1.00 0.95 0.89 0.89 0.95 1.00 0.85
0.93 0.99 0.89 0.82 0.82 0.89 0.99 0.93
0.93 0.99 0.89 0.82 0.82 0.89 0.99 0.93
0.85 1.00 0.95 0.89 0.89 0.95 1.00 0.85
0.61 0.93 1.00 0.99 0.99 1.00 0.93 0.61
0.20 0.61 0.85 0.93 0.93 0.85 0.61 0.20

See Also