Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
12 Views

ipp 2017 Big Images - C#

Using images of ~8gb or more

1. Copy functions Should work with those sizes ?

2. ErodeBorder 
    since there is no "In Place" , should i allocate additional temp buffer ?

3. ErodeBorder few iterations 
    possible to get an example ?

0 Kudos
1 Reply
Highlighted
Employee
12 Views

Hi,

Using images of ~8gb or more

1. Copy functions Should work with those sizes ?

It depends on image parameters. If your image width, height and step does not exceed IPP_MAX_32S, then function should work.

2. ErodeBorder 
    since there is no "In Place" , should i allocate additional temp buffer ?

Yes, for functions without "I" suffix, you should use temporary buffer if you want to emulate in-place behavior.

3. ErodeBorder few iterations 
    possible to get an example ?

I don't have C# on my hands but in C++ it could look like this:

#include "ippcv.h"
Status opMorphology_ipp(Image &src, Image &dst)
{
    src.ConvertColor(CF_GRAY);
    dst = src;
    dst.Alloc();

    Ipp8u   *pSrc      = (Ipp8u*)src.ptr();
    int      srcStep   = src.m_step;
    Ipp8u   *pDst      = (Ipp8u*)dst.ptr();
    int      dstStep   = dst.m_step;
    Ipp8u   *pInter    = NULL;
    int      interStep = 0;
    IppiSize size      = {src.m_size.width, src.m_size.height};
    Ipp8u    mask[]    = {0, 1, 0,
                          1, 1, 1,
                          0, 1, 0};
    IppiSize maskSize  = {3, 3};
    int iterations     = 4;

    IppStatus       status;
    IppiMorphState *pState     = NULL;
    int             stateSize  = 0;
    Ipp8u          *pBuffer    = NULL;
    int             bufferSize = 0;

    status = ippiMorphologyBorderGetSize_8u_C1R(size, maskSize, &stateSize, &bufferSize);
    if(status < 0)
        return STS_ERR_FAILED;

    pState = (IppiMorphState*)ippMalloc(stateSize);
    if(!pState)
        return STS_ERR_FAILED;

    pBuffer = (Ipp8u*)ippMalloc(bufferSize);
    if(bufferSize && !pBuffer)
        return STS_ERR_FAILED;

    status = ippiMorphologyBorderInit_8u_C1R(size, mask, maskSize, pState, pBuffer);
    if(status < 0)
        return STS_ERR_FAILED;

    if(iterations > 1)
        pInter = ippiMalloc_8u_C1(size.width, size.height, &interStep);

    status = ippiErodeBorder_8u_C1R(pSrc, srcStep, pDst, dstStep, size, ippBorderRepl, 0, pState, pBuffer);
    if(status < 0)
        return STS_ERR_FAILED;

    for(int i = 1; i < iterations; i++)
    {
        Ipp8u *pInpl1;
        int    step1;
        Ipp8u *pInpl2;
        int    step2;
        if(i%2)
        {
            pInpl1 = pDst;
            step1  = dstStep;
            pInpl2 = pInter;
            step2  = interStep;
        }
        else
        {
            pInpl1 = pInter;
            step1  = interStep;
            pInpl2 = pDst;
            step2  = dstStep;
        }

        status = ippiErodeBorder_8u_C1R(pInpl1, step1, pInpl2, step2, size, ippBorderRepl, 0, pState, pBuffer);
        if(status < 0)
            return STS_ERR_FAILED;
    }
    if(!(iterations%2))
    {
        status = ippiCopy_8u_C1R(pInter, interStep, pDst, dstStep, size);
        if(status < 0)
            return STS_ERR_FAILED;
    }

    if(pInter)
        ippiFree(pInter);

    return STS_OK;
}
0 Kudos