3

I'm trying to use NVIDIA NPP to experiment with some image resizing routines. I want to resize to an exact dimension. I've been looking at image resizing using NVIDIA NPP but all of its resize functions take scale factors for X and Y Dimensions, and I could not see any API taking direct destination dimensions.

As an example, this is one API:

NppStatus nppiResizeSqrPixel_8u_C1R(const Npp8u * pSrc, NppiSize oSrcSize, int nSrcStep, NppiRect oSrcROI, Npp8u * pDst, int nDstStep, NppiRect oDstROI, double nXFactor, double nYFactor, double nXShift, double nYShift, int eInterpolation);

I realize one way could be to find the appropriate scale factor the destination dimension, but we don't exactly know how the API decides destination ROI based on scale factor (since it is floating point math). We could reverse the calculation in the jpegNPP sample to find the scale factor, but the API itself does not make any guarantees so I'm not sure how safe it is. Any ideas what are the possibilities?

As a side question, the API also takes two params, nXShift and nYShift, but just says "Source pixel shift in x-direction". I'm not exactly clear what shift is being talked about here. Do you have an idea?

  • npp now has resize functions that allow you resize from exact dimensions (W1,H1) to exact dimensions (W2,H2). The scale factor is computed by npp. See [here](https://docs.nvidia.com/cuda/npp/group__image__resize.html) – Robert Crovella Oct 14 '19 at 21:49

1 Answers1

1

If I wanted to map the whole SRC image to the smaller rectangle in the DST image as shown in the image below I would use xFactor = yFactor = 0.5 and xShift = 0.5*DST.width and yShift = 0.

Mapping src to half size destination image

In other words, the pixel at (x,y) in the SRC is mapped to the pixel (x',y') in the DST as

 x' = xFactor * x + xShift
 y' = yFactor * y + yShift

In this case, both the source and dest ROI could be the entire support of the respective images.

wcochran
  • 10,089
  • 6
  • 61
  • 69