ippiResizeSqrPixel_

ippiResizeSqrPixel_

I am using ref function to filter/zoom/pan an image in one step. The problem is that it performs the zoom first, then the pan. Is there a way to reverse that so that it pans first, then zoom centered on the pan center?

I could of course make this 2 separate calls but would require an intermediate byte array to hold the panned image before zooming. Would be nice to do this in one call...

Thank you!

publicaciones de 7 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

Not sure which function you're using as a reference, but you may be able to do a limited combination of zoom and panning with IPP's resize. You'll need a bigger buffer for the destination than the destination image. You can then offset the destination address to anywhere you want within that bigger buffer, which hopefully is close to what you'd like to do. The resize updates in IPP 7.1 make this easier to do. Please see http://software.intel.com/en-us/articles/intel-ipp-71-resize-changes/ for more info on the new resize updates.

Thank you Jeffrey. What you suggest is exactly what I am doing, a zoom followed by a pan, in 2 steps. The topic of this thread should indicate that I am using the latest resize capability of IPP 7.1, namely ippiResizeSqrPixel_.

So again, my question is, is there a way to achieve a pan/zoom operation of a given souce image ROI in a source image to go into a destination ROI of a destination image, all in one single ippiResizeSqrPixel_ call? I am trying to prevent having to call this twice, once for zoom, and then once for pan. It seems this should be possible to do in a single ippiResizeSqrPixel_ call?

Thank you again!

If your destination image buffer is bigger than your destination size, yes, you can do something like resize+pan in a single call.

What I'm thinking of is a case like this:

IppiSize srcsize={64,64}; //the source image
IppiSize dstsize={256,256}; //the output buffer, bigger than the resize output
IppiRect srcRoi={0, 0, srcsize.width, srcsize.height}; // Source ROI is the full source image
IppiRect dstRoi={0, 0, 96, 96}; //destination ROI, which in this case is the full destination image. ROI width/height is destination width/height

int cpan=64, rpan=64; //rows and columns to translate in the larger output buffer
...

ippiResizeSqrPixel_8u_C1R(pSrc, srcsize, stridesrc, srcRoi,
pDst+(rpan*stridedst)+cpan, stridedst, dstRoi,
(double)dstRoi.width/(double)srcRoi.width,
(double)dstRoi.height/(double)srcRoi.height, 0, 0,
IPPI_INTER_LANCZOS, pBuffer);

As you can see, resize outputs to a translated address in the output buffer. This will achieve a translation and resize in one operation as long as the translation is fully within the larger output buffer. In theory this could be made more general by adjusting the source ROI when part of the translated output would go beyond the output buffer boundary, but this would be more complicated.

Is this close to what you're looking for?

Actually, you may get closer to "pan first, then zoom" with a small change to the scenario described above. That is more like "zoom first, then pan".

If the source image is inside a larger buffer, you can also move the pointer to the source ROI.

Ipp8u* pSrc2=pSrc+64+(64*stridesrc); //true source image is offset by 64 rows and 64 columns in the larger source buffer

ippiResizeSqrPixel_8u_C1R(pSrc2-32, srcsize, stridesrc, srcRoi,
pDst, stridedst, dstRoi,
(double)dstRoi.width/(double)srcRoi.width,
(double)dstRoi.height/(double)srcRoi.height, 0,0,
IPPI_INTER_LANCZOS, pBuffer);

Here the resize window is offset by 32 columns, though it is a lot of extra work on empty pixels. In the end it may be more efficient to do the operation in 2 steps.

Thank you Jeffrey!

Will the srcROI not have to be adjusted in your latter example since it is using pSrc2 as the source data pointer?

Thanks!

You're right. The ROIs are different. In the first example (resize, then pan) the output buffer was bigger than the output from resize so resize could write it out with an offset and not go beyond the bounds of the output buffer. The ROIs were set to accomplish this. In the second example (pan, then resize) the source buffer is bigger than the source image so that the sampling window for resize could be offset. This is how I'd set up the sizes in my test:

IppiSize imgsize={128,128}; // the image to pan+resize
IppiSize srcsize={256,256}; // a smaller image of imgsize (128x128) centered in this larger buffer
IppiSize dstsize={256,256}; // destination image zoomed to 256x256
IppiRect srcRoi={0, 0, imgsize.width, imgsize.height};
IppiRect dstRoi={0, 0, 256, 256};

Inicie sesión para dejar un comentario.