| October 13, 2009 7:00 AM PDT | |
The Intel® IPP Resize function ippiResizeSqrPixel crashed when the image size is less than 6 and use interpolation method LANCZOS or CUBIC. It is an issue we recently identified in IPP v 6.0
Here is sample code. main_ippiResize.cpp
It calls ippiResizeSqrPixel_8u_C3R() to stretch 3x4 source image to 17x23 image
The fix have been available in Intel® IPP 6.1 update 1 (6.1.1.035).
A quick workaround is to change interpolation type for very small source images. Please add the below code after line 9:
Other common errors:
1. Wrong stepBytes value
For example,
the srcStep != channel*srcWidth in most of cases.
It may be = ((nChannel*srcWidth+3)>>2)<<2 if a bmp image with 4 bytes-aligned,
or = a multiple of 32 when use ippiMalloc() as each row is 32 bytes-aligned
2. Wrong factor value
xFactor and yFactor are double type. For example, for accurate stretch src image to dst image, it should be double xFactor = (double)dstWidth / srcWidth;not double xFactor = dstWidth / srcWidth;
The four double parameters allow full coordinates transformation
|dX| |xFactor 0 | |sX| |xShift|
| | = | | * | | + | |
|dY| | 0 yFactor| |sY | |yShift|
3. About srcROI and dstROI
Please see the discussion and illustrated figure on forum
Here is sample code. main_ippiResize.cpp
It calls ippiResizeSqrPixel_8u_C3R() to stretch 3x4 source image to 17x23 image
/* set/calculate of the x, y dimensions Factors,Shift Value,Interpolation value
please note, xFactor is double type float point number.
*/
double xFactor = (double)dstWidth / srcWidth;
double yFactor = (double)dstHeight / srcHeight;
double xShift = 0.0;
double yShift = 0.0;
/* interploation options are:
IPPI_INTER_NN||IPPI_INTER_LINEAR|| IPPI_INTER_CUBIC
IPPI_INTER_CUBIC2P_BSPLINE||IPPI_INTER_CUBIC2P_CATMULLROM||PPI_INTER_CUBIC2P_B05C03
IPPI_INTER_SUPER||IPPI_INTER_LANCZOS */
int interpolation = IPPI_INTER_LANCZOS;
/* calculation of work buffer size */
Ipp8u * pBuffer;
int bufSize = 0;
ippiResizeGetBufSize(srcRoi, dstRoi, nChannel, interpolation, &bufSize );
pBuffer= ippsMalloc_8u(bufSize );
/* Resize Image */
status=ippiResizeSqrPixel_8u_C3R(pSrc, srcSize, srcStep, srcRoi, pDst, dstStep,
dstRoi, xFactor, yFactor, xShift, yShift, interpolation, pBuffer);
printf("%d : %s\n", status, ippGetStatusString(status));
The fix have been available in Intel® IPP 6.1 update 1 (6.1.1.035).
A quick workaround is to change interpolation type for very small source images. Please add the below code after line 9:
if (srcWidth < 6 || srcHeight< 6) {
if (interpolation == IPPI_INTER_LANCZOS)
interpolation = IPPI_INTER_CUBIC;
if (srcWidth < 4 || srcHeight < 4) {
if ((interpolation == IPPI_INTER_CUBIC) ||
(interpolation == IPPI_INTER_CUBIC2P_BSPLINE) ||
(interpolation == IPPI_INTER_CUBIC2P_CATMULLROM) ||
(interpolation == IPPI_INTER_CUBIC2P_B05C03))
interpolation = IPPI_INTER_LINEAR;
}
}
Other common errors:
1. Wrong stepBytes value
For example,
the srcStep != channel*srcWidth in most of cases.
It may be = ((nChannel*srcWidth+3)>>2)<<2 if a bmp image with 4 bytes-aligned,
or = a multiple of 32 when use ippiMalloc() as each row is 32 bytes-aligned
2. Wrong factor value
xFactor and yFactor are double type. For example, for accurate stretch src image to dst image, it should be double xFactor = (double)dstWidth / srcWidth;not double xFactor = dstWidth / srcWidth;
The four double parameters allow full coordinates transformation
|dX| |xFactor 0 | |sX| |xShift|
| | = | | * | | + | |
|dY| | 0 yFactor| |sY | |yShift|
3. About srcROI and dstROI
Please see the discussion and illustrated figure on forum
Do you need more help?
Article Attachments
This article applies to: Intel® Integrated Performance Primitives Knowledge Base
For more complete information about compiler optimizations, see our Optimization Notice.
Comments (0) 
Trackbacks (0)
Leave a comment 
To obtain technical support, please go to Software Support.

