0

Let say there is a 7x5 matrix (16-bit image) with the following values, and I want to copy every 3rd value into a new 3x2 matrix using IPP.

enter image description here => enter image description here.

I tried the function ippiCopySubpix_16u_C1R but it copies only the left corner of my origin matrix. Which possibility do I have? here is my test code:

    Ipp16u x[7*5], y[3*2];
    IppiSize roiOrig = {7,5}; IppiSize roiDst = {3,2}; 
    auto * ptr = x; // fill the matrix
    for (int i = 0; i < 7*5; i++)
    {
      *ptr++ = i;
    }

    ippiCopySubpix_16u_C1R(x, 7*2, y, 3*2, roiDst, 3, 3); 
    // result is [0 1 2 7 8 9]
Kara
  • 6,115
  • 16
  • 50
  • 57
alex555
  • 1,676
  • 4
  • 27
  • 45

1 Answers1

0

I don't think ippiCopySubpix_16u_C1R is the right function for the job.
Refer to: http://technion.ac.il/doc/intel/ipp/ipp_manual/IPPI/ippi_ch4/functn_CopySubpix.htm

This function computes the pixel value of the destination image using linear interpolation (see Linear Interpolation in Appendix B) in accordance with the following formula:

enter image description here

where i = 0, ... roiSize.height - 1 , j = 0, ... roiSize.width - 1 .

As you can see, dx and dy are not the distance of pixels to skip, but offset values in sub-pixels.

I think the function you are looking for is: ippiCopy_16u_C3C1R
Refer to: https://software.intel.com/en-us/node/503752

Function skips every third source pixel horizontally.

For vertical skipping, set srcStep to size (in bytes) of 3 rows.

Rotem
  • 30,366
  • 4
  • 32
  • 65