Scales pixel values of an image and converts them to another bit depth.
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 |
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, Ippi32f vMin, Ippi32f vMax);
Supported values for mod:
8u32f_C1R |
8u32f_C3R |
8u32f_C4R |
8u32f_AC4R |
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 |
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, Ippi32f vMin, Ippi32f vMax);
Supported values for mod:
32f8u_C1R |
32f8u_C3R |
32f8u_C4R |
32f8u_AC4R |
pSrc |
Pointer to the source image ROI. |
srcStep |
Distance in bytes between starts of consecutive lines in the source image. |
pDst |
Pointer to the destination image ROI. |
dstStep |
Distance in bytes between starts 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. |
The function ippiScale is declared in the ippi.h file. It operates with ROI (see Regions of Interest in Intel IPP).
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 (see Table Hint Arguments for Image Moment Functions). 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 (see Intel® Integrated Performance Primitives Concepts for more information on data types and ranges).
The following scaling formula to map the source pixel p to the destination pixel p′ is used:
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 will saturate. To determine the actual floating-point data range in your image, use the function ippiMinMax.
Example “Data Conversion with Scaling” shows how to use scaling to preserve the data range.
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 . |
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
Copyright © 2000 - 2011, Intel Corporation. All rights reserved.