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

pLevels of ippiHistogramEven_8u_C1R

Jamie_F_
Beginner
318 Views

Hello, I am wondering how do they calculate the pLevels in ippiHistogramEven_8u_C1R function? More specifically, if the lower level is 0, upper level is 255 and nLevels is 13, the returned pLevels of the function would be looked like this: { 0,22,44,66,87,108,129,150,171,192,213,234,255}

Now, for some reasons I need to reproduce the exact same sequence, I've tried some rounding methods such as round, floor and ceil, and so far still couldn't make it work.

Can anyone kindly tell me what method or equation do I need to use in order to get the same pLevels ??

Below is an example that I used to calculate pLevels (using round method):

   int nBins = nLevels-1;
   float binSize = (float)(upperLevel - lowerLevel) / (float)(nBins);
   for(int i=0; i<nLevels; ++i)
   {      
      float level = (float)i * binSize;

      if(level > 0)
      {
         level = floor(level + 0.5);
      }
      else
      {
         level = ceil(level - 0.5);
      }
      pLevels = lowerLevel + (Ipp32s)level;
   }

And the result I get is
{0,21,43,64,85,106,128,149,170,191,213,234,255}

Any suggestions would be appreciated!

0 Kudos
1 Reply
Igor_A_Intel
Employee
318 Views

Hi Jamie,

here it is:

    nBins = nLevels - 1;
    diap = upperLevel - lowerLevel;
    ni = diap / nBins;
    nj = diap % nBins;
    pLevels[0] = lowerLevel;
    for (i = 1; i <= nBins; i ++) {
        pLevels = pLevels[i-1] + ni + (nj > 0 ? 1 : 0);
        nj --;
    }
 

regards, Igor

0 Kudos
Reply