Regions of Interest in Intel IPP

Most Intel IPP image processing functions can operate not only on entire images but also on image areas. Image region of interest (ROI) is a rectangular area that may be either some part of the image or the whole image.

The Intel IPP functions with ROI support are distinguished by the presence of an R descriptor in their names. ROI of an image is defined by the size and offset from the image origin as shown in Figure Image, ROI, and Offsets. The origin of an image is implied to be in the top left corner, with x values increasing from left to right and y values increasing downwards.

Image, ROI, and Offsets



Both the source and destination images can have a region of interest. In such cases the sizes of ROIs are assumed to be the same while offsets may differ. The image processing is then performed on data of the source ROI, and the results are written to the destination ROI. In function call sequences, an ROI is specified by:

Thus, the parameters srcStep, dstStep set steps in bytes through image buffers to start processing a new line in the ROI of an image.

The following code example illustrates the use of the dstStep parameter in function calls:

Using Buffer Step Parameter

IppStatus alignedLine( void ) { Ipp8u x[8*3] = {0}; IppiSize imgSize = {5,3}; /// The image is of size 5x3. Width 8 has been /// chosen by the user to align every line of the image return ippiSet_8u_C1R( 7, x, 8, imgSize); }

The resultant image x contains the following data:

07 07 07 07 07 00 00 00 07 07 07 07 07 00 00 00 07 07 07 07 07 00 00 00

If ROI is present,

The pSrc and pDst parameters are the shifted pointers to the image data. For example, in case of ROI operations on 3-bytes-per-pixel image data (8u_C3R), pSrc points to the start of the source ROI buffer and can be interpreted as follows:

pSrc = pSrcImg + 3*(srcImgSize.width * srcRoiOffset.y + srcRoiOffset.x),

where

pSrcImg

points to the start of the source image buffer

srcImgSize

is the image size in pixels (of the IppiSize type)

srcRoiOffset

determines an offset of ROI relative to the start of the image as shown in Figure Image, ROI, and Offsets.

Another example for operations on four-channel image of 32f data type 32f_AC4:

pSrc = (Ipp32f*)((Ipp8u*)pSrcImg + srcImgStep * srcRoiOffset.y + 4*SizeOf(Ipp32f)*srcRoiOffset.x.

In this example the multiplier 4 is used because the AC4 pixel consists of 4 values - R, G, B, A. Pointer type conversion is required as in Intel IPP all image steps are always in bytes, and it's not recommended to use step/SizeOf(Ipp32f) as in a general case step value may be not a multiple of 4.

For functions using ROI with a neighborhood, you should correctly use values of the pSrc and roiSize parameters. These functions assume that the points in the neighborhood exist and that therefore pSrc is almost never equal to pSrcImg. Figure Using ROI with Neighborhood illustrates the case when neighborhood pixels can fall outside the source image.

Using ROI with Neighborhood



To ensure valid operation when image pixels are processed, the application should correctly define additional border pixels (see Borders).

Warning iconWarning

If the required border pixels are not defined prior to calling neighborhood functions that attempt to process such pixels, you may get memory violation errors.

The following code example shows how to process an image with ROI:

ROI Processing

IppStatus roi( void ) { Ipp8u x[8*3] = {0}; IppiSize roiSize = {3,2}; IppiPoint roiPoint = {2,1}; /// place the pointer to the ROI start position return ippiSet_8u_C1R( 7, x+8*roiPoint.y+roiPoint.x, 8, roiSize ); }

The destination image x will contain the following data

00 00 00 00 00 00 00 00 00 00 07 07 07 00 00 00 00 00 07 07 07 00 00 00


Submit feedback on this help topic

Copyright © 2000 - 2010, Intel Corporation. All rights reserved.