Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.

Resize Image using ROI Processing


I've been trying to update our video tiling (for displaying multiple input images in a single output image) implementation to support a particular scenario.  Simply put, I need to resize an input image of arbitrary dimensions / aspect ratio into a region (also of arbitrary dimensions / aspect ratios and position in the destination image) of an output / destination image (also of arbitrary dimensions / aspect ratios).  We have had much of this working for sometime with one key limitation, we have not tried cropping the source image.  The existing functionality works even after upgrading a while back to the newer ippiResizeNearest API.

I am now struggling to allow for cropping of the source image such that it fits into the destination region, maintaining the source image aspect ratio.  Let's say, for example, the source image is 720p, the  destination image is also 720p, and the destination region within the destination image is VGA (or something smaller with similar aspect ratio).  Since 720p is wider than VGA I want to crop the left and right of the source image and resize to fit into the region.  As far as I can tell, the only use case close to this has to do with tiling an image into n smaller images and resizing these tiles individually.  Seems more to enable parallel processing of the tiles.

Anyway, I have all the details needed for the source / destination ROI, source / destination offsets, etc., but the ippiResizeNearest (nor any other resize API I have found) does not accept the source offset, just the width / height of the ROI.  Is there something I am missing here?  I believe this was pretty easy to implement using the old 'resize square pixel' API.  The documentation seems to indicate the source ROI is driven off the destination ROI and you must retrieve the ROI and offsets with a 'get' API.

Given a simple example . . .

Source image 1280x720

Output image 1280x720

Region in output image 600x360

Source ROI IppiRect {40, 0, 1200, 720} (x, y, w, h) - takes the center 1200 pixel width and full height

Destination ROI IppiRect {?, ? 600, 360} (x, y, w, h) - scales the cropped source by half and places in region (wherever it is located in destination image)

0 Kudos
1 Reply

Managed to get this working, mostly.  Seems the 'get ROI' functions are for the 'Intel tiled image' use case.  For my use case the functions only return {0, 0} origin and offset.  If I use my own offset added to the source image pointer I can crop the source image as needed.  Still have some issues with the U and V planes in specific scenarios but this is likely a bug in my calculations.

Feel free to close this.