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

Scale

Scales pixel values of an image and converts them to another bit depth.

Syntax

Case 1: Scaling with conversion to integer data of increased bit depth

IppStatus ippiScale_<mod>(const Ipp<srcDatatype>* pSrc, int srcStep, Ipp<dstDatatype>* pDst, int dstStep, IppiSize roiSize);

Supported values for mod:

8u16u_C1R 8u16s_C1R 8u32s_C1R
8u16u_C3R 8u16s_C3R 8u32s_C3R
8u16u_C4R 8u16s_C4R 8u32s_C4R

IppStatus ippiScale_<mod>(const Ipp<srcDatatype>* pSrc, int srcStep, Ipp<dstDatatype>* pDst, int dstStep, IppiSize roiSize);

Supported values for mod:

8u16u_AC4R 8u16s_AC4R 8u32s_AC4R

Case 2: Scaling with conversion to floating-point data

IppStatus ippiScale_<mod>(const Ipp8u* pSrc, int srcStep, Ipp32f* pDst, int dstStep, IppiSize roiSize, Ipp32f vMin, Ipp32f vMax);

Supported values for mod:

8u32f_C1R
8u32f_C3R
8u32f_C4R

IppStatus ippiScale_8u32f_AC4R(const Ipp8u* pSrc, int srcStep, Ipp32f* pDst, int dstStep, IppiSize roiSize, Ipp32f vMin, Ipp32f vMax);

Case 3: Scaling of integer data with conversion to reduced bit depth

IppStatus ippiScale_<mod> (const Ipp<srcDatatype>* pSrc, int srcStep, Ipp<dstDatatype>* pDst, int dstStep, IppiSize roiSize, IppHintAlgorithm hint);

Supported values for mod:

16u8u_C1R 16s8u_C1R 32s8u_C1R
16u8u_C3R 16s8u_C3R 32s8u_C3R
16u8u_C4R 16s8u_C4R 32s8u_C4R

IppStatus ippiScale_<mod> (const Ipp<srcDatatype>* pSrc, int srcStep, Ipp<dstDatatype>* pDst, int dstStep, IppiSize roiSize, IppHintAlgorithm hint);

Supported values for mod:

16u8u_AC4R 16s8u_AC4R 32s8u_AC4R

Case 4: Scaling of floating-point data with conversion to integer data type

IppStatus ippiScale_<mod>(const Ipp32f* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize, Ipp32f vMin, Ipp32f vMax);

Supported values for mod:

32f8u_C1R
32f8u_C3R
32f8u_C4R

IppStatus ippiScale_32f8u_AC4R(const Ipp32f* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize, Ipp32f vMin, Ipp32f vMax);

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 bytes of consecutive lines in the destination image.

roiSize

Size of the source and destination ROI in pixels.

vMin, vMax

Minimum and maximum values of the input data.

hint

Option to select the algorithmic implementation of the function (see Hint Arguments for Image Moment Functions).

Description

This function operates with ROI.

This function converts pixel values of a source image ROI pSrc to the destination data type, using a linear mapping. The computation algorithm is specified by the hint argument. For conversion between integer data types, the whole range [src_Min..src_Max] of the input data type is mapped onto the range [dst_Min..dst_Max] of the output data type.

The source pixel p is mapped to the destination pixel p′ by the following formula:

p′ = dst_Min + k*(p - src_Min)

where

k = (dst_Max - dst_Min)/(src_Max - src_Min)

For conversions to and from floating-point data type, the user-defined floating-point data range [vMin..vMax] is mapped onto the source or destination data type range.

If the conversion is from Ipp32f type and some of the input floating-point values are outside the specified input data range [vMin..vMax], the corresponding output values saturate. To determine the actual floating-point data range in your image, use the ippiMinMax function.

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 a zero or negative value.

ippStsStepErr

Indicates an error condition if srcStep or dstStep has a zero or negative value.

ippStsScaleRangeErr

Indicates an error condition if the input data bounds are incorrect, that is, vMax is less than or equal to vMin .

Example

The code example below shows how to use scaling to preserve the data range.

IppStatus scale( void ) {
   IppiSize roi = {5,4};
   Ipp32f x[5*4];
   Ipp8u y[5*4];
   ippiSet_32f_C1R( -1.0f, x, 5*sizeof(Ipp32f), roi );
   x[1] = 300; x[2] = 150;
   return ippiScale_32f8u_C1R( x, 5*sizeof(Ipp32f), y, 5, roi, -1, 300 );
}

The destination image y contains:

00 FF 80 00 00
00 00 00 00 00
00 00 00 00 00
00 00 00 00 00

See Also