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

Converting from ippiHistogramEven (IPP 7.0) to ippiHistogram (IPP 2017)

Shai_E_
Beginner
659 Views

Hi,

I'm converting the use of IPP 7.0 to IPP 2017.

I have an issue that ippiHistogram does not produce the same result as ippiHistogramEven.

The levels that ippiHistogramUniformInit generate are different then the levels generated by ippiHistogramEven in IPP 7.0.

Thanks!

0 Kudos
1 Solution
Zhen_Z_Intel
Employee
659 Views

Hi Shai,

I think the result of IPP2017 is more reasonable, for instance, the 10th value should be 65535/20*9=29490.75, IPP2017 adopts truncation, thus, the value is assumed as 29490. However IPP7 gives value 29493. I think the result of IPP 2017 should be acceptable, but IPP7 is not reliable. I think we already fixed problem in IPP7 and the result of IPP2017 is correct.

Best regards,
Fiona

View solution in original post

0 Kudos
4 Replies
Zhen_Z_Intel
Employee
659 Views

Hi Shai,

Could you provide a simple test case to reproduce this problem? Also please provide more version info about IPP 2017, is it gold release or update version? Thanks, I am looking forward your reply.

Best regards,
Fiona

0 Kudos
Shai_E_
Beginner
659 Views

Hi Fiona,

The following code on IPP 7.0:

    const int HEIGHT = 8;
    const int WIDTH = 8;
    Ipp8u pImg[WIDTH*HEIGHT];
    IppiSize roi = { WIDTH, HEIGHT };
    int i;
    IppStatus sts;
    IppsRandUniState_8u* pRUS;
    sts = ippsRandUniformInitAlloc_8u(&pRUS, 0/*low*/, 255/*high*/, 0/*seed*/);
    sts = ippsRandUniform_8u(pImg, WIDTH*HEIGHT, pRUS);
    const int nBins = 20;
    int nLevels[] = { nBins + 1 };
    Ipp32f lowerLevel[] = { 0 };
    Ipp32f upperLevel[] = { USHRT_MAX };
    Ipp32s pLevels[nBins + 1], *ppLevels[1];
    int sizeHistObj, sizeBuffer;
    Ipp8u* pBuffer;
    Ipp32s pHistVec[nBins];
    // calculate histogram
    sts = ippiHistogramEven_8u_C1R(pImg, WIDTH, roi, pHistVec, pLevels, nBins + 1, 0, USHRT_MAX);
    for (auto level : pLevels)
    {
        std::cout << level << " ";
    }

and the following code on IPP 2017 Update 3:

    const int HEIGHT = 8;
    const int WIDTH = 8;
    Ipp8u pImg[WIDTH*HEIGHT];
    IppiSize roi = { WIDTH, HEIGHT };
    int i;
    IppStatus sts;
    const IppLibraryVersion *pp = ippiGetLibVersion();
    IppsRandUniState_8u* pRndObj;
    int sizeRndObj;
    // get spec size
    ippsRandUniformGetSize_8u(&sizeRndObj);
    pRndObj = (IppsRandUniState_8u*)ippsMalloc_8u(sizeRndObj);
    // initialize rnd spec
    ippsRandUniformInit_8u(pRndObj, 0/*low*/, 255/*high*/, 0/*seed*/);
    // fill image
    for (i = 0; i < HEIGHT; i++) {
        sts = ippsRandUniform_8u(pImg + i*WIDTH, WIDTH, pRndObj);
    }
    ippsFree(pRndObj);

    const int nBins = 20;
    int nLevels[] = { nBins + 1 };
    Ipp32f lowerLevel[] = { 0 };
    Ipp32f upperLevel[] = { USHRT_MAX };
    Ipp32f pLevels[nBins + 1], *ppLevels[1];
    int sizeHistObj, sizeBuffer;
    IppiHistogramSpec* pHistObj;
    Ipp8u* pBuffer;
    Ipp32u pHistVec[nBins];
    // get sizes for spec and buffer
    ippiHistogramGetBufferSize(ipp8u, roi, nLevels, 1/*nChan*/, 1/*uniform*/, &sizeHistObj,
        &sizeBuffer);
    pHistObj = (IppiHistogramSpec*)ippsMalloc_8u(sizeHistObj);
    pBuffer = (Ipp8u*)ippsMalloc_8u(sizeBuffer);
    // initialize spec
    ippiHistogramUniformInit(ipp8u, lowerLevel, upperLevel, nLevels, 1, pHistObj);
    // check levels of bins
    ppLevels[0] = pLevels;
    sts = ippiHistogramGetLevels(pHistObj, ppLevels);

    for (auto level : pLevels)
    {
        std::cout << level << " ";
    }

The levels computed in IPP 7.0 are:

0 3277 6554 9831 13108 16385 19662 22939 26216 29493 32770 36047 39324 42601 45878 49155 52431 55707 58983 62259 65535

and on IPP 2017 :

0 3276 6553 9830 13107 16383 19660 22937 26214 29490 32767 36044 39321 42597 45874 49151 52428 55704 58981 62258 65535

As you can see, the levels are different, I would expect them to be the same.

 

Thanks,

Shai

0 Kudos
Zhen_Z_Intel
Employee
659 Views

Hi Shai,

Seems we changed rounding of calculation pLevel to truncation. I will check with developing team, thanks.

Best regards,
Fiona

0 Kudos
Zhen_Z_Intel
Employee
660 Views

Hi Shai,

I think the result of IPP2017 is more reasonable, for instance, the 10th value should be 65535/20*9=29490.75, IPP2017 adopts truncation, thus, the value is assumed as 29490. However IPP7 gives value 29493. I think the result of IPP 2017 should be acceptable, but IPP7 is not reliable. I think we already fixed problem in IPP7 and the result of IPP2017 is correct.

Best regards,
Fiona

0 Kudos
Reply