Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Replicate border of 1D data array

gilles73
Beginner
975 Views

Hi,

Do you know a function or a code like the function CopyReplicateBorder in the library of image processing to obtain the fast copy with the borders replication of  an one-dimensional array Ipp32f ?

 

Thanks in advance

G.

0 Kudos
1 Solution
Andrey_B_Intel
Employee
846 Views

Hi Gilles.

You can either use ippiCopyReplicateBorder_32f_C1R for 1d vector too or use pipeline of ippsSet_32f+ippsCopy_32f functions. See details in code below:

#include <stdio.h>
#include "ipp.h"

#define LEN  16
#define BRD  4

IppStatus CopyReplicateBorder(const Ipp32f* pSrc, int srcLen,
    Ipp32f* pDst, int dstLen,    int left)
{
#define MIN(A,B) ((A)<(B))?(A):(B)
    ippsSet_32f(pSrc[0], pDst, MIN(left,dstLen));
    dstLen -= left;
    if (dstLen > 0) {
        pDst += left;
      ippsCopy_32f(pSrc, pDst, MIN(srcLen, dstLen));
      dstLen -= srcLen;
    }
    if (dstLen > 0) {
        pDst += srcLen;
        ippsSet_32f(pSrc[srcLen-1], pDst, dstLen);
    }
}
int main()
{
    Ipp32f pSrc[LEN];
    Ipp32f pDst[LEN+2*BRD];
    int n;
    for (n = 0; n < LEN; n++) {
        pSrc[n] = n + 1;
    }

#if 1
    IppiSize srcroi = {LEN          , 1};
    IppiSize dstroi = {LEN + 2 * BRD, 1};
    int topBorderHeight = 0;
    int leftBorderWidth = BRD;
    ippiCopyReplicateBorder_32f_C1R(
      pSrc, LEN*sizeof(Ipp32f), srcroi,
      pDst,(LEN+2*BRD) * sizeof(Ipp32f), dstroi,
        topBorderHeight, leftBorderWidth);
#else
    CopyReplicateBorder(pSrc,LEN,pDst, LEN+2*BRD, BRD);

#endif
    printf("pSrc:\n");
    for (n = 0; n < LEN; n++) {
        printf("%.2f ", pSrc[n]);
    }
    printf("\n");
    printf("pDst:\n");
    for (n = 0; n < LEN+2*BRD; n++) {
        printf("%.2f ", pDst[n]);
    }
    printf("\n");

    return 0;
}

 Andrey B.

View solution in original post

0 Kudos
3 Replies
ShanmukhS_Intel
Moderator
928 Views

Hi,


Thanks for reaching out to us.


>>Do you know a function or a code like the function CopyReplicateBorder in the library of image processing?

Please refer the below link which might help you.

https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/top/volume-2-image-processing/image-data-exchange-and-initialization-functions/copyreplicateborder.html


If this is not what you are looking for, Kindly provide us details more specific on the functionality so that we could assist you.


Best Regards,

Shanmukh.SS


0 Kudos
gilles73
Beginner
910 Views

Hi Shanmukh,

As explained, my input is a pointer to an 1D array of float (Ipp32f), not of image type. But, it seems as a "Pointer to the source image ROI" is not be different from a pointer to an array, is it ?

I will try to use CopyReplicateBoder with a vector of float as input data.

 

Thanks

Gilles

0 Kudos
Andrey_B_Intel
Employee
847 Views

Hi Gilles.

You can either use ippiCopyReplicateBorder_32f_C1R for 1d vector too or use pipeline of ippsSet_32f+ippsCopy_32f functions. See details in code below:

#include <stdio.h>
#include "ipp.h"

#define LEN  16
#define BRD  4

IppStatus CopyReplicateBorder(const Ipp32f* pSrc, int srcLen,
    Ipp32f* pDst, int dstLen,    int left)
{
#define MIN(A,B) ((A)<(B))?(A):(B)
    ippsSet_32f(pSrc[0], pDst, MIN(left,dstLen));
    dstLen -= left;
    if (dstLen > 0) {
        pDst += left;
      ippsCopy_32f(pSrc, pDst, MIN(srcLen, dstLen));
      dstLen -= srcLen;
    }
    if (dstLen > 0) {
        pDst += srcLen;
        ippsSet_32f(pSrc[srcLen-1], pDst, dstLen);
    }
}
int main()
{
    Ipp32f pSrc[LEN];
    Ipp32f pDst[LEN+2*BRD];
    int n;
    for (n = 0; n < LEN; n++) {
        pSrc[n] = n + 1;
    }

#if 1
    IppiSize srcroi = {LEN          , 1};
    IppiSize dstroi = {LEN + 2 * BRD, 1};
    int topBorderHeight = 0;
    int leftBorderWidth = BRD;
    ippiCopyReplicateBorder_32f_C1R(
      pSrc, LEN*sizeof(Ipp32f), srcroi,
      pDst,(LEN+2*BRD) * sizeof(Ipp32f), dstroi,
        topBorderHeight, leftBorderWidth);
#else
    CopyReplicateBorder(pSrc,LEN,pDst, LEN+2*BRD, BRD);

#endif
    printf("pSrc:\n");
    for (n = 0; n < LEN; n++) {
        printf("%.2f ", pSrc[n]);
    }
    printf("\n");
    printf("pDst:\n");
    for (n = 0; n < LEN+2*BRD; n++) {
        printf("%.2f ", pDst[n]);
    }
    printf("\n");

    return 0;
}

 Andrey B.

0 Kudos
Reply