Developer Reference

  • 2020
  • 07/15/2020
  • Public Content
Contents

ResizeAntialiasing

Changes an image size using the chosen interpolation method with antialiasing.

Syntax

IppStatus ippiResizeAntialiasing_<data_type>_<chan>(const Ipp<data_type>*
pSrc
, Ipp32s
srcStep
, Ipp<data_type>*
pDst
, Ipp32s
dstStep
, IppiPoint
dstOffset
, IppiSize
dstSize
, IppiBorderType
border
, const Ipp<data_type>*
pBorderValue
, const IppiResizeSpec_32f*
pSpec
, Ipp8u*
pBuffer
);
Supported values for
data_type
:
8u
16u
16s
32f
Supported values for
chan
:
C1R
C3R
C4R
Platform-aware functions
IppStatus ippiResizeAntialiasing_<data_type>_<chan>_L(const Ipp<data_type>*
pSrc
, IppSizeL
srcStep
, Ipp<data_type>*
pDst
, IppSizeL
dstStep
, IppiPointL
dstOffset
, IppiSizeL
dstSize
, IppiBorderType
border
, const Ipp<data_type>*
pBorderValue
, const IppiResizeSpec*
pSpec
, Ipp8u*
pBuffer
);
Supported values for
data_type
:
8u
16u
16s
32f
Supported values for
chan
:
C1R
C3R
C4R
Threading layer (TL) functions
IppStatus ippiResizeAntialiasing_<data_type>_<chan>_LT(const Ipp<data_type>*
pSrc
, IppSizeL
srcStep
, Ipp<data_type>*
pDst
, IppSizeL
dstStep
, IppiBorderType
border
, const Ipp<data_type>*
pBorderValue
, const IppiResizeSpec_LT*
pSpec
, Ipp8u*
pBuffer
);
Supported values for
data_type
:
8u
16u
16s
32f
Supported values for
chan
:
C1R
C3R
C4R
Include Files
ippi.h
Flavors with the
_LT
suffix:
ippi_tl.h
Flavors with the
_L
suffix:
ippi_l.h
Domain Dependencies
Flavors declared in
ippi.h
:
Headers:
ippcore.h
,
ippvm.h
,
ipps.h
Libraries:
ippcore.lib
,
ippvm.lib
,
ipps.lib
Flavors declared in
ippi_tl.h
:
Libraries:
ippcore.lib
,
ippvm.lib
,
ipps.lib
,
ippi.lib
,
ippcore_tl.lib
,
ippi_tl.lib
Parameters
pSrc
Pointer to the source image.
srcStep
Distance, in bytes, between the starting points of consecutive lines in the source image buffer.
pDst
Pointer to the destination image.
dstStep
Distance, in bytes, between the starting points of consecutive lines in the destination image buffer.
dstOffset
Offset of the tiled destination image with respect to the destination image origin.
dstSize
Size of the destination image, in pixels.
border
Type of border. Possible values are:
ippBorderRepl
Border is replicated from the edge pixels.
ippBorderConst
Border pixels are set to constants.
ippBorderInMem
Border is obtained from the source image pixels in memory.
Mixed borders are also supported. They can be obtained by the bitwise operation
OR
between the
ippBorderRepl
type and the
ippBorderInMemTop
,
ippBorderInMemBottom
,
ippBorderInMemLeft
,
ippBorderInMemRight
types.
pBorderValue
Pointer to the constant value to assign to pixels of the constant border. This parameter is applicable only to the
ippBorderConst
border type.
pSpec
Pointer to the specification structure for the resize filter.
pBuffer
Pointer to the external buffer.
Description
The
ippiResizeAntialiasing
function changes the size of an image using the chosen interpolation method with antialiasing. The interpolation method to be applied is defined by the function that you use for the resize filter initialization. Use this function to reduce the image size with minimization of moire artifacts. For more information about the implemented algorithm, refer to [ SCHU92 ].
If you use
ippiResizeAntialiasing
to increase the image size, the function applies the same algorithm as one of the following resize functions, depending on the interpolation type chosen at the initialization stage:
ippiResizeLinear
,
ippiResizeCubic
, or
ippiResizeLanczos
.
This function operates with ROI. It resizes the source image ROI origin to the destination image ROI origin. Define the destination image ROI origin by the following parameters: the offset of the tiled destination image with respect to the destination image origin and the destination image size. The source image ROI origin is defined automatically. To obtain the source image ROI, use the corresponding flavor of the
ippiResizeGetSrcRoi
function. To obtain the source image ROI origin offset, call the corresponding flavor of the
ippiResizeGetSrcOffset
function. Parameters
pSrc
and
pDst
must point to the processed source and destination image ROI origins, respectively.
The interpolation algorithm applied uses edge pixels of the source image that are out of the image origin. The
ippiResizeAntialiasing
function uses the weighted values of these outer pixels. To obtain the size of the out of the source image origin, call the corresponding flavor of the
ippiResizeGetBorderSize
function.
Before using the
ippiResizeAntialiasing
function, you need to initialize the
IppiResizeSpec_32f
structure using one of the following functions, depending on the interpolation method to be applied:
ippiResizeAntialiasingLinearInit
,
ippiResizeAntialiasingCubicInit
, or
ippiResizeAntialiasingLanczosInit
, and compute the size of the external buffer
pBuffer
using the corresponding flavor of the
ippiResizeGetBufferSize
function.
For more information about the supported border types, see User-defined Border Types .
Return Values
ippStsNoErr
Indicates no error.
ippStsNullPtrErr
Indicates an error when one of the specified pointers is
NULL
.
ippStsNoOperation
Indicates a warning when width or height of the destination image is equal to zero.
ippStsBorderErr
Indicates an error when the
border
value is illegal.
ippStsContextMatchErr
Indicates an error when a pointer to the specification structure is invalid.
ippStsNotSupportedModeErr
Indicates an error when the requested mode is not supported.
ippStsSizeErr
Indicates an error when width or height of the destination image is negative.
ippStsStepErr
Indicates an error when the step value is not data type multiple.
ippStsOutOfRangeErr
Indicates an error when the destination image offset point is outside the destination image origin.
ippStsSizeWrn
Indicates a warning when the destination image size is more than the destination image origin size.

Example

/******************************************************************************* * Copyright 2015-2020 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 changing an image size by different interpolation // methods with antialiasing technique using Intel(R) Integrated Primitives (Intel(R) IPP) functions: // ippiResizeGetSize_8u // ippiResizeAntialiasingLinearInit // ippiResizeGetBufferSize_8u // ippiResizeAntialiasing_8u_C3R #include <stdio.h> #include "ipp.h" #define SRC_WIDTH 128 /* source image width */ #define SRC_HEIGHT 64 /* source image height */ #define DST_WIDTH 64 /* source image width */ #define DST_HEIGHT 128 /* source image height */ /* 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; Ipp8u* pSrc = NULL, *pDst = NULL; /* Pointers to source/destination images */ int srcStep = 0, dstStep = 0; /* Steps, in bytes through the source/destination images */ IppiSize srcSize = { SRC_WIDTH, SRC_HEIGHT }; /* Size of source ROI in pixels */ IppiSize dstSize = { DST_WIDTH, DST_HEIGHT }; /* Size of destination ROI in pixels */ Ipp8u *pBuffer = NULL; /* Pointer to the work buffer */ IppiResizeSpec_32f *pSpec = NULL; Ipp8u *pInit = NULL; int specSize = 0, initSize = 0, bufSize = 0; IppiPoint dstOffset = { 0, 0 }; IppiInterpolationType interpolation = ippLinear; IppiBorderType borderType = ippBorderRepl; pSrc = ippiMalloc_8u_C3(srcSize.width, srcSize.height, &srcStep); pDst = ippiMalloc_8u_C3(dstSize.width, dstSize.height, &dstStep); /* Calculation of work buffer size */ check_sts( status = ippiResizeGetSize_8u(srcSize, dstSize, interpolation, 1, &specSize, &initSize) ) /* Memory allocation */ pSpec = (IppiResizeSpec_32f*)ippsMalloc_8u(specSize + initSize); pInit = (Ipp8u*)pSpec + initSize; /* Filter initialization */ check_sts( status = ippiResizeAntialiasingLinearInit(srcSize, dstSize, pSpec, pInit) ) check_sts( status = ippiResizeGetBufferSize_8u(pSpec, dstSize, 3, &bufSize) ) pBuffer = ippsMalloc_8u(bufSize); /* Function call */ check_sts( status = ippiResizeAntialiasing_8u_C3R(pSrc, srcStep, pDst, dstStep, dstOffset, dstSize, borderType, 0, pSpec, pBuffer) ) EXIT_MAIN ippiFree(pSrc); ippiFree(pDst); ippsFree(pSpec); ippsFree(pBuffer); printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status)); return (int)status; }
The figure below demonstrates the results of reducing a 1751x1044 image by five times with antialiasing (a) and without (b).

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804